Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 415a048

Browse files
Merge pull request #5 from webrtc/addLinting
Add linting
2 parents 6e45fec + aef645d commit 415a048

File tree

16 files changed

+323
-134
lines changed

16 files changed

+323
-134
lines changed

.csslintrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"box-model": false,
3+
"ids": false,
4+
"known-properties": false,
5+
"overqualified-elements": false,
6+
"unique-headings": false
7+
}

.eslintrc

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"rules": {
3+
"array-bracket-spacing": 2,
4+
"block-spacing": [2, "never"],
5+
"brace-style": [2, "1tbs", { "allowSingleLine": false }],
6+
"camelcase": [2, {"properties": "always"}],
7+
"curly": 2,
8+
"default-case": 2,
9+
"dot-notation": 2,
10+
"eqeqeq": 2,
11+
"indent": [
12+
2,
13+
2
14+
],
15+
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
16+
"max-len": [2, 80, 2, {"ignoreUrls": true}],
17+
"new-cap": 2,
18+
"no-console": 0,
19+
"no-else-return": 2,
20+
"no-eval": 2,
21+
"no-multi-spaces": 2,
22+
"no-multiple-empty-lines": [2, {"max": 2}],
23+
"no-shadow": 2,
24+
"no-trailing-spaces": 2,
25+
"no-unused-expressions": 2,
26+
"no-unused-vars": [2, {"args": "none"}],
27+
"object-curly-spacing": [2, "never"],
28+
"padded-blocks": [2, "never"],
29+
"quotes": [
30+
2,
31+
"single"
32+
],
33+
"semi": [
34+
2,
35+
"always"
36+
],
37+
"space-before-blocks": 2,
38+
"space-before-function-paren": [2, "never"],
39+
"spaced-comment": 2,
40+
"valid-typeof": 2
41+
},
42+
"env": {
43+
"es6": true,
44+
"browser": true,
45+
"node": false
46+
},
47+
"extends": ["eslint:recommended", "webrtc"],
48+
"globals": {
49+
"adapter": true,
50+
"audioContext": true,
51+
"browserSupportsIPHandlingPolicy": true,
52+
"browserSupportsNonProxiedUdpBoolean": true,
53+
"chrome": true,
54+
"ga": true,
55+
"getPolicyFromBooleans": true,
56+
"trace": true,
57+
}
58+
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.DS_Store
3+
.eslintcache

.travis.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
dist: trusty
2+
language: node_js
3+
cache:
4+
- node_modules
5+
node_js:
6+
- 6
7+
8+
branches:
9+
only:
10+
- gh-pages
11+
12+
script:
13+
- grunt

Gruntfile.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
'use strict';
2+
3+
/* globals module */
4+
5+
module.exports = function(grunt) {
6+
// configure project
7+
grunt.initConfig({
8+
// make node configurations available
9+
pkg: grunt.file.readJSON('package.json'),
10+
csslint: {
11+
options: {
12+
csslintrc: '.csslintrc'
13+
},
14+
src: ['css/*.css', 'src/css/*.css']
15+
},
16+
eslint: {
17+
options: {
18+
configFile: '.eslintrc',
19+
cache: true
20+
},
21+
target: ['src/**/*.js']
22+
},
23+
// Runs the npm test command which has access to the grunt path.
24+
githooks: {
25+
all: {
26+
options: {
27+
command: 'npm',
28+
},
29+
'pre-commit': 'test'
30+
}
31+
},
32+
htmlhint: {
33+
html1: {
34+
src: ['src/**/*.html']
35+
},
36+
html2: {
37+
src: ['index.html']
38+
}
39+
},
40+
});
41+
42+
// enable plugins
43+
grunt.loadNpmTasks('grunt-contrib-csslint');
44+
grunt.loadNpmTasks('grunt-eslint');
45+
grunt.loadNpmTasks('grunt-githooks');
46+
grunt.loadNpmTasks('grunt-htmlhint');
47+
48+
// set default tasks to run when grunt is called without parameters
49+
grunt.registerTask('default', ['csslint', 'htmlhint', 'eslint']);
50+
};

css/landing_page.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ a:hover {
1717
}
1818

1919
a#viewSource {
20-
display: block;
21-
margin: 1.3em 0 0 0;
2220
border-top: 1px solid #999;
21+
display: block;
22+
margin: 1.3em 0 .0 0;
2323
padding: 1em 0 0 0;
2424
}
2525

2626
body {
2727
font-family: 'Roboto', sans-serif;
28+
font-weight: 300;
2829
margin: 0;
2930
padding: 1em;
3031
word-break: break-word;
31-
font-weight: 300;
3232
}
3333

3434
div#container {

package.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "test-pages",
3+
"description": "Test pages",
4+
"keywords": [
5+
"webrtc",
6+
"demos",
7+
"samples",
8+
"javascript"
9+
],
10+
"homepage": "https://github.com/webrtc/test-pages",
11+
"bugs": {
12+
"url": "https://github.com/webrtc/test-pages/issues"
13+
},
14+
"license": "BSD-3-Clause",
15+
"author": "The WebRTC project authors",
16+
"main": "index.html",
17+
"repository": {
18+
"type": "git",
19+
"url": "https://github.com/webrtc/test-pages.git"
20+
},
21+
"scripts": {
22+
"test": "grunt",
23+
"postinstall": "grunt githooks"
24+
},
25+
"devDependencies": {
26+
"eslint-config-webrtc": ">=1.0.0",
27+
"express": "^4.14.1",
28+
"grunt": ">=0.4.5",
29+
"grunt-cli": ">=0.1.9",
30+
"grunt-contrib-csslint": ">=0.3.1",
31+
"grunt-eslint": ">=17.2.0",
32+
"grunt-githooks": ">=0.3.1",
33+
"grunt-htmlhint": ">=0.9.12",
34+
"pem": ">=1.9.4"
35+
}
36+
}

src/canvas-capture/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<div id="container">
1515
<h1>Canvas capture stream to peerConnection</h1>
1616

17-
<canvas id="canvas" width=32 height=24></canvas>
18-
<video id="remoteVideo" width=32 height=24 autoplay=""></video>
17+
<canvas id="canvas" width="32" height="24"></canvas>
18+
<video id="remoteVideo" width="32" height="24" autoplay=""></video>
1919

2020
<div>
2121
<button id="startButton" class="green">Start test</button>

src/canvas-capture/js/main.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ function draw() {
3232
context.rect(0, 0, canvas.clientWidth, canvas.clientHeight);
3333
var randomNumber = Math.random();
3434
var hue;
35-
if (randomNumber < 0.33)
35+
if (randomNumber < 0.33) {
3636
hue = 'red';
37-
else if (randomNumber < 0.66)
37+
} else if (randomNumber < 0.66) {
3838
hue = 'green';
39-
else
39+
} else {
4040
hue = 'blue';
41+
}
4142
context.fillStyle = hue;
4243
context.fill();
4344
}

src/css/main.css

+20-20
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
* tree.
77
*/
88
.drop-down {
9-
width: 65%;
109
font-size: 10px;
11-
white-space: nowrap
10+
white-space: nowrap;
11+
width: 65%;
1212
}
1313

1414
.constraints {
15-
width: 75%;
15+
display: none;
1616
height: auto;
17-
position: absolute;
1817
overflow: scroll;
19-
display: none;
18+
position: absolute;
19+
width: 75%;
2020
}
2121

2222
.float-left {
@@ -25,8 +25,8 @@
2525
}
2626

2727
.float-clear-left {
28-
float: left;
2928
clear: left;
29+
float: left;
3030
width: 100%;
3131
}
3232

@@ -39,9 +39,9 @@
3939
}
4040

4141
#messages {
42-
word-wrap: break-word;
43-
white-space: pre-wrap;
4442
font-size: 0.7em;
43+
white-space: pre-wrap;
44+
word-wrap: break-word;
4545
}
4646

4747
#audio-source {
@@ -64,14 +64,14 @@
6464
}
6565

6666
#pc-server {
67-
width: 98%;
6867
margin-left: 0.1em;
6968
margin-top: 0.1em;
69+
width: 98%;
7070
}
7171

7272
#peer-id-container {
73-
margin-left: 60%;
7473
height: 1.5em;
74+
margin-left: 60%;
7575
}
7676

7777
#peer-id {
@@ -84,11 +84,11 @@
8484
}
8585

8686
#pc-server-container {
87-
position: absolute;
87+
height: 1.5em;
8888
margin: 0 0 0 12%;
89-
width: 40%;
9089
overflow: hidden;
91-
height: 1.5em;
90+
position: absolute;
91+
width: 40%;
9292
}
9393

9494
#pc-constraints-left {
@@ -107,8 +107,8 @@
107107
}
108108

109109
.float-clear-left {
110-
float: left;
111110
clear: left;
111+
float: left;
112112
width: 100%;
113113
}
114114

@@ -185,8 +185,8 @@ div#container {
185185
margin: 0 auto 0 auto;
186186
max-width: 40em;
187187
padding: 0 1.5em 1.3em 1.5em;
188-
z-index: 2;
189188
position: relative;
189+
z-index: 2;
190190
}
191191

192192
h2 {
@@ -220,22 +220,22 @@ video {
220220

221221
#log {
222222
float: left;
223-
position: fixed;
223+
left: 0;
224224
overflow: auto;
225+
padding: 16px;
226+
position: fixed;
225227
top: 0;
226-
left: 0;
227228
width: 20%;
228-
padding: 16px;
229229
word-wrap: break-word;
230230
z-index: 1;
231231
}
232232

233233
@media screen and (max-width: 1200px) {
234234
div#log {
235235
float: none;
236-
width: 100%;
237-
position: inherit;
238236
padding: 0;
237+
position: inherit;
238+
width: 100%;
239239
}
240240
button {
241241
padding: 0.7em;

src/multiple-peerconnections/js/main.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* tree.
77
*/
88

9-
/*jshint esversion: 6 */
9+
/* jshint esversion: 6 */
1010

1111
'use strict';
1212

@@ -47,8 +47,8 @@ function PeerConnection(id, cpuOveruseDetection) {
4747
audio: true,
4848
video: true
4949
})
50-
.then(onGetUserMediaSuccess)
51-
.catch(logError);
50+
.then(onGetUserMediaSuccess)
51+
.catch(logError);
5252
};
5353

5454
this.onGetUserMediaSuccess = function(stream) {
@@ -82,7 +82,7 @@ function PeerConnection(id, cpuOveruseDetection) {
8282
offerToReceiveAudio: 1,
8383
offerToReceiveVideo: 1
8484
})
85-
.then(onCreateOfferSuccess, logError);
85+
.then(onCreateOfferSuccess, logError);
8686
};
8787

8888
this.onCreateOfferSuccess = function(desc) {
@@ -91,7 +91,7 @@ function PeerConnection(id, cpuOveruseDetection) {
9191

9292
var onCreateAnswerSuccess = this.onCreateAnswerSuccess.bind(this);
9393
this.remoteConnection.createAnswer()
94-
.then(onCreateAnswerSuccess, logError);
94+
.then(onCreateAnswerSuccess, logError);
9595
};
9696

9797
this.onCreateAnswerSuccess = function(desc) {

0 commit comments

Comments
 (0)