Skip to content

Commit 76bc0c1

Browse files
committed
Install ESLint
1 parent 4a314c5 commit 76bc0c1

File tree

4 files changed

+169
-3
lines changed

4 files changed

+169
-3
lines changed

.eslintrc

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"extends": "eslint:recommended",
3+
"parser": "babel-eslint",
4+
"env": {
5+
"browser": true,
6+
"node": true,
7+
"mocha": true,
8+
"es6": true
9+
},
10+
"plugins": [
11+
"react",
12+
"babel"
13+
],
14+
"rules": {
15+
# Posible errors
16+
"no-extra-parens": 0,
17+
"valid-jsdoc": [1, { "requireReturn": false }],
18+
# Best practices
19+
"accessor-pairs": 1,
20+
"block-scoped-var": 1,
21+
"complexity": 1,
22+
"consistent-return": 1,
23+
"curly": [1, "multi-line"],
24+
"dot-location": [1, "property"],
25+
"dot-notation": 1,
26+
"eqeqeq": [1, "smart"],
27+
"guard-for-in": 1,
28+
"no-alert": 1,
29+
"no-caller": 2,
30+
"no-div-regex": 1,
31+
"no-else-return": 1,
32+
"no-eq-null": 1,
33+
"no-eval": 2,
34+
"no-extend-native": 2,
35+
"no-extra-bind": 1,
36+
"no-floating-decimal": 1,
37+
"no-implicit-coercion": 1,
38+
"no-implied-eval": 1,
39+
"no-invalid-this": 0,
40+
"babel/no-invalid-this": 1,
41+
"no-iterator": 2,
42+
"no-labels": 1,
43+
"no-lone-blocks": 1,
44+
"no-loop-func": 1,
45+
"no-magic-numbers": 0,
46+
"no-multi-spaces": 1,
47+
"no-multi-str": 1,
48+
"no-new-func": 1,
49+
"no-new-wrappers": 1,
50+
"no-new": 1,
51+
"no-octal-escape": 2,
52+
"no-param-reassign": 1,
53+
"no-proto": 1,
54+
"no-return-assign": 1,
55+
"no-script-url": 1,
56+
"no-self-compare": 1,
57+
"no-sequences": 1,
58+
"no-throw-literal": 1,
59+
"no-unused-expressions": 1,
60+
"no-unused-vars": 0,
61+
"no-useless-call": 1,
62+
"no-useless-concat": 1,
63+
"no-void": 1,
64+
"no-warning-comments": 0,
65+
"no-with": 1,
66+
"radix": 0,
67+
"vars-on-top": 0,
68+
"wrap-iife": 1,
69+
"yoda": 1,
70+
# Variables
71+
"init-declarations": 1,
72+
"no-catch-shadow": 1,
73+
"no-label-var": 1,
74+
"no-shadow-restricted-names": 1,
75+
"no-shadow": 1,
76+
"no-undef-init": 1,
77+
"no-undefined": 1,
78+
"no-use-before-define": 1,
79+
# Stylistic issues
80+
"array-bracket-spacing": [1, "never"],
81+
"block-spacing": [1, "always"],
82+
"brace-style": 1,
83+
"camelcase": 1,
84+
"comma-dangle": 1,
85+
"comma-spacing": 1,
86+
"comma-style": 1,
87+
"computed-property-spacing": 1,
88+
"consistent-this": 1,
89+
"eol-last": 1,
90+
"func-names": 0,
91+
"func-style": 0,
92+
"id-length": 0,
93+
"id-match": 1,
94+
"indent": [1, 2, { "SwitchCase": 1 }],
95+
"jsx-quotes": 1,
96+
"key-spacing": 1,
97+
"line-comment-position": 0,
98+
"linebreak-style": 1,
99+
"lines-around-comment": 0,
100+
"max-depth": 1,
101+
"max-len": [1, { "ignoreUrls": true }],
102+
"max-nested-callbacks": 1,
103+
"max-params": [1, 4],
104+
"max-statements": 1,
105+
"multiline-ternary": 0,
106+
"new-cap": 1,
107+
"new-parens": 1,
108+
"newline-after-var": 1,
109+
"newline-before-return": 1,
110+
"no-array-constructor": 1,
111+
"no-bitwise": 1,
112+
"no-continue": 0,
113+
"no-inline-comments": 0,
114+
"no-lonely-if": 1,
115+
"no-multiple-empty-lines": 1,
116+
"no-negated-condition": 1,
117+
"no-nested-ternary": 1,
118+
"no-new-object": 1,
119+
"no-plusplus": 0,
120+
"no-restricted-syntax": 1,
121+
"no-ternary": 0,
122+
"no-trailing-spaces": 1,
123+
"no-underscore-dangle": 1,
124+
"no-unreachable": 1,
125+
"no-unneeded-ternary": 1,
126+
"object-curly-spacing": [1, "always"],
127+
"object-property-newline": 0,
128+
"one-var-declaration-per-line": 0,
129+
"one-var": 0,
130+
"operator-assignment": 1,
131+
"operator-linebreak": [1, "after"],
132+
"padded-blocks": [1, "never"],
133+
"quote-props": [1, "as-needed"],
134+
"quotes": [1, 'single'],
135+
"require-jsdoc": 1,
136+
"semi-spacing": 1,
137+
"semi": 1,
138+
"sort-keys": 0,
139+
"sort-vars": 0,
140+
"space-before-blocks": 1,
141+
"space-before-function-paren": [1, "never"],
142+
"space-in-parens": 1,
143+
"space-infix-ops": 1,
144+
"space-unary-ops": 1,
145+
"spaced-comment": 1,
146+
"wrap-regex": 0,
147+
# Other
148+
"no-console": 0,
149+
"strict": 0,
150+
"react/jsx-no-undef": 1,
151+
"react/jsx-uses-react": 1,
152+
"react/jsx-uses-vars": 1
153+
}
154+
}

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99
"devDependencies": {
1010
"babel-cli": "^6.24.1",
1111
"babel-core": "^6.26.0",
12+
"babel-eslint": "^8.2.2",
1213
"babel-jest": "^22.4.0",
1314
"babel-loader": "^7.1.2",
1415
"babel-plugin-transform-object-rest-spread": "^6.26.0",
1516
"babel-preset-env": "^1.6.1",
1617
"babel-preset-react": "^6.24.1",
18+
"eslint": "^4.18.1",
19+
"eslint-loader": "^1.9.0",
20+
"eslint-plugin-babel": "^4.1.2",
21+
"eslint-plugin-react": "^7.7.0",
1722
"jest": "^22.4.0",
1823
"path": "^0.12.7",
1924
"react-dom": "^16.2.0",

src/components/LazyLoadImage.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class LazyLoadImage extends React.Component {
77

88
this.state = {
99
visible: false
10-
}
10+
};
1111

1212
this.previousBoundingBox = {
1313
bottom: -1,
@@ -78,14 +78,15 @@ class LazyLoadImage extends React.Component {
7878

7979
getPlaceholder() {
8080
const { className, height, placeholder, width } = this.props;
81+
8182
if (placeholder) {
8283
return placeholder;
8384
}
8485

8586
return (
8687
<span className={'lazy-load-image-placeholder ' + className}
8788
ref="placeholder"
88-
style={{height, width}}>
89+
style={{ height, width }}>
8990
</span>
9091
);
9192
}

webpack.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ module.exports = {
99
module: {
1010
rules: [
1111
{
12-
test: /\.(js|jsx)$/,
12+
enforce: 'pre',
13+
test: /\.jsx?$/,
14+
loaders: ['eslint-loader'],
15+
include: path.resolve(__dirname, 'src'),
16+
exclude: /(node_modules|bower_components|build)/
17+
}, {
18+
test: /\.jsx?$/,
1319
include: path.resolve(__dirname, 'src'),
1420
exclude: /(node_modules|bower_components|build)/,
1521
use: {

0 commit comments

Comments
 (0)