Skip to content

Commit b431843

Browse files
author
Cathy Siller
authored
Merge pull request #84 from rackerlabs/surf-672-automated-linting-rebased
surf-672-automated-linting-rebased
2 parents f575eea + daa79d5 commit b431843

File tree

14 files changed

+545
-43
lines changed

14 files changed

+545
-43
lines changed

.eslintignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# directories
2+
bin/*
3+
lib/*
4+
node_modules/*
5+
public/*
6+
source/vendor/*
7+
test/*
8+
9+
# files
10+
_config.*

.eslintrc.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"extends": "eslint:recommended",
7+
"parserOptions": {
8+
"sourceType": "module"
9+
},
10+
"globals": {
11+
"$": false,
12+
"module": false,
13+
"require": false,
14+
"ShadyCSS": false
15+
},
16+
"rules": {
17+
"brace-style": [2, "1tbs", {
18+
"allowSingleLine": true
19+
}],
20+
"camelcase": 2,
21+
"comma-dangle": [2, "always-multiline"],
22+
"comma-style": [2, "last"],
23+
"complexity": [2, 10],
24+
"curly": [2, "all"],
25+
"eol-last": 2,
26+
"eqeqeq": 2,
27+
"guard-for-in": 2,
28+
"indent": [2, 4, { "SwitchCase": 1 }],
29+
"keyword-spacing": 2,
30+
"max-depth": [2, 3],
31+
"max-len": [2, 120, { "ignoreUrls": true }],
32+
"new-cap": 2,
33+
"no-bitwise": 2,
34+
"no-caller": 2,
35+
"no-empty": 2,
36+
"no-multiple-empty-lines": [2, {
37+
"max": 1,
38+
"maxBOF": 0
39+
}],
40+
"no-undef": 2,
41+
"no-unused-expressions": [2, {
42+
"allowTernary": true,
43+
"allowShortCircuit": true
44+
}],
45+
"no-unused-vars": 2,
46+
"no-use-before-define": [2, { "functions": false }],
47+
"object-curly-spacing": [2, "always"],
48+
"quotes": [2, "single"],
49+
"space-before-function-paren": [2, "always"],
50+
"space-in-parens": [2, "never"],
51+
"space-infix-ops": 2,
52+
"space-unary-ops": 2,
53+
"strict": 0,
54+
"wrap-iife": [2, "inside"]
55+
}
56+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
node_modules
33
*.swp
44
debug.log
5+
package-lock.json
56

67
# Generated Hexo Files/Directories
78
db.json

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const bumpFiles = [ './package.json' ];
1111
'preminor',
1212
'prepatch',
1313
'prerelease'
14-
].forEach( (ilk) => {
14+
].forEach((ilk) => {
1515
gulp.task(`bump:${ilk}`, function () {
1616
gulp.src(bumpFiles)
1717
.pipe(bump({ type: ilk }))

lib/webpack.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// See https://webpack.js.org/api/node/
44

5+
56
const CONFIG = require('../_config');
67
const path = require('path');
78
const webpack = require('webpack');
@@ -40,12 +41,17 @@ const compiler = webpack({
4041
{
4142
test: /\.js$/,
4243
exclude: /(node_modules|bower_components)/,
43-
use: {
44-
loader: 'babel-loader',
45-
options: {
46-
presets: ['es2015']
44+
use: [
45+
{
46+
loader: 'babel-loader',
47+
options: {
48+
presets: ['es2015']
49+
}
50+
},
51+
{
52+
loader: 'eslint-loader'
4753
}
48-
}
54+
]
4955
}
5056
]
5157
},

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"babel-preset-es2015": "^6.24.1",
1010
"browser-sync": "2.x",
1111
"cheerio": "^1.0.0-rc.2",
12+
"eslint": "4.x",
13+
"eslint-loader": "^1.9.0",
1214
"front-matter": "^2.2.0",
1315
"fs-extra": "^4.0.2",
1416
"gh-pages": "^1.0.0",
@@ -31,6 +33,7 @@
3133
"build": "bin/build.js",
3234
"clean": "rm -fr node_modules",
3335
"deploy": "bin/deploy.js",
36+
"lint": "eslint -c .eslintrc.json source",
3437
"postinstall": "cd test; yarn install; yarn run webdriver:update; cd -;",
3538
"publish": "bin/publish.js",
3639
"start": "bin/start.js",

source/components/checkbox/HxCheckbox.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ window.addEventListener('WebComponentsReady', function () {
1616
`;
1717

1818
function _preventScroll (event) {
19-
if (event.keyCode == KEY.Space) {
19+
if (event.keyCode === KEY.Space) {
2020
event.preventDefault();
2121
}
2222
}
@@ -30,13 +30,13 @@ window.addEventListener('WebComponentsReady', function () {
3030
return [
3131
'checked',
3232
'disabled',
33-
'indeterminate'
33+
'indeterminate',
3434
];
3535
}
3636

3737
constructor () {
3838
super();
39-
this.attachShadow({mode: 'open'});
39+
this.attachShadow({ mode: 'open' });
4040
if (window.ShadyCSS) {
4141
ShadyCSS.prepareTemplate(template, tagName);
4242
ShadyCSS.styleElement(this);
@@ -68,7 +68,7 @@ window.addEventListener('WebComponentsReady', function () {
6868
}
6969

7070
set checked (value) {
71-
if (Boolean(value)) {
71+
if (value) {
7272
this.setAttribute('checked', '');
7373
} else {
7474
this.removeAttribute('checked');
@@ -80,7 +80,7 @@ window.addEventListener('WebComponentsReady', function () {
8080
}
8181

8282
set disabled (value) {
83-
if (Boolean(value)) {
83+
if (value) {
8484
this.setAttribute('disabled', '');
8585
} else {
8686
this.removeAttribute('disabled');
@@ -92,7 +92,7 @@ window.addEventListener('WebComponentsReady', function () {
9292
}
9393

9494
set indeterminate (value) {
95-
if (Boolean(value)) {
95+
if (value) {
9696
this.setAttribute('indeterminate', '');
9797
} else {
9898
this.removeAttribute('indeterminate');
@@ -110,13 +110,13 @@ window.addEventListener('WebComponentsReady', function () {
110110
if (hasValue) {
111111
this.setAttribute('aria-checked', 'mixed');
112112
}
113-
break;
113+
break;
114114

115115
case 'checked':
116116
if (!this.indeterminate) {
117117
this.setAttribute('aria-checked', hasValue);
118118
}
119-
break;
119+
break;
120120

121121
case 'disabled':
122122
this.setAttribute('aria-disabled', hasValue);
@@ -126,7 +126,7 @@ window.addEventListener('WebComponentsReady', function () {
126126
} else {
127127
this.setAttribute('tabindex', '0');
128128
}
129-
break;
129+
break;
130130
}
131131
}//attributeChangedCallback()
132132

@@ -135,13 +135,13 @@ window.addEventListener('WebComponentsReady', function () {
135135
return;
136136
}
137137

138-
if (event.keyCode == KEY.Space) {
138+
if (event.keyCode === KEY.Space) {
139139
event.preventDefault();
140140
this._toggleChecked();
141141
}
142142
}
143143

144-
_onClick (event) {
144+
_onClick () {
145145
this._toggleChecked();
146146
}
147147

@@ -154,9 +154,9 @@ window.addEventListener('WebComponentsReady', function () {
154154

155155
let changeEvent = new CustomEvent('change', {
156156
detail: {
157-
checked: this.checked
157+
checked: this.checked,
158158
},
159-
bubbles: true
159+
bubbles: true,
160160
});
161161

162162
this.dispatchEvent(changeEvent);
@@ -173,6 +173,6 @@ window.addEventListener('WebComponentsReady', function () {
173173
this[prop] = value;
174174
}
175175
}
176-
}
176+
}
177177
customElements.define(HxCheckbox.is, HxCheckbox)
178178
});

source/components/icon/HxIcon.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ window.addEventListener('WebComponentsReady', function () {
7171
return tagName;
7272
}
7373

74-
static get observedAttributes() {
74+
static get observedAttributes () {
7575
return ['type'];
7676
}
7777

@@ -81,8 +81,8 @@ window.addEventListener('WebComponentsReady', function () {
8181

8282
constructor (type) {
8383
super();
84-
this.attachShadow({mode: 'open'});
85-
if (window.ShadyCSS ) {
84+
this.attachShadow({ mode: 'open' });
85+
if (window.ShadyCSS) {
8686
ShadyCSS.prepareTemplate(template, tagName);
8787
ShadyCSS.styleElement(this);
8888
}
@@ -97,7 +97,7 @@ window.addEventListener('WebComponentsReady', function () {
9797
this._render();
9898
}
9999

100-
attributeChangedCallback (attr, oldValue, newValue) {
100+
attributeChangedCallback (attr) {
101101
if (attr === 'type') {
102102
this._render();
103103
}

source/components/reveal/HxReveal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ window.addEventListener('WebComponentsReady', function () {
1818

1919
constructor () {
2020
super();
21-
this.attachShadow({mode: 'open'});
21+
this.attachShadow({ mode: 'open' });
2222
if (window.ShadyCSS) {
2323
ShadyCSS.prepareTemplate(template, tagName);
2424
ShadyCSS.styleElement(this);
@@ -43,7 +43,7 @@ window.addEventListener('WebComponentsReady', function () {
4343
}
4444

4545
set open (value) {
46-
if (Boolean(value)) {
46+
if (value) {
4747
this.setAttribute('open', '');
4848
} else {
4949
this.removeAttribute('open');

source/components/tabset/HxTabpanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ window.addEventListener('WebComponentsReady', function () {
2929
}
3030

3131
set open (value) {
32-
if (Boolean(value)) {
32+
if (value) {
3333
this.setAttribute('open', '');
3434
} else {
3535
this.removeAttribute('open');

0 commit comments

Comments
 (0)