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

Commit 1c00286

Browse files
committed
feat: add and configure eslint
1 parent a671e07 commit 1c00286

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

.eslintrc

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"parser": "babel-eslint",
3+
"plugins": [
4+
"react",
5+
"flowtype"
6+
],
7+
"parserOptions": {
8+
"ecmaVersion": 6,
9+
"sourceType": "module",
10+
"ecmaFeatures": {
11+
"jsx": true,
12+
"impliedStrict": true
13+
}
14+
},
15+
"env": {
16+
"browser": true,
17+
"amd": true,
18+
"es6": true,
19+
"node": true,
20+
"mocha": true
21+
},
22+
"extends": ["eslint:recommended", "plugin:react/recommended"],
23+
"rules": {
24+
"no-undef": ["warn"],
25+
"global-strict": ["off"],
26+
"no-extra-semi": ["warn"],
27+
"no-underscore-dangle": ["off"],
28+
"no-console": ["off"],
29+
"no-unused-vars": ["off"],
30+
"no-trailing-spaces": ["warn", {
31+
"skipBlankLines": true
32+
}],
33+
"no-unreachable": ["warn"],
34+
"no-spaced-func": ["warn"],
35+
"no-new-func": ["error"],
36+
"no-new-wrappers": ["error"],
37+
"no-invalid-regexp": ["error"],
38+
"no-extra-bind": ["error"],
39+
"no-magic-numbers": ["error"],
40+
"consistent-return": ["error"],
41+
"valid-jsdoc": ["error"],
42+
"no-use-before-define": ["error"],
43+
"camelcase": ["warn"],
44+
"array-callback-return": ["error"],
45+
"dot-location": ["warn", "property"],
46+
"guard-for-in": ["error"],
47+
"no-useless-call": ["warn"],
48+
"no-useless-escape": ["warn"],
49+
"no-useless-concat": ["warn"],
50+
"brace-style": ["warn", "1tbs"],
51+
"comma-style": ["warn", "last"],
52+
"space-before-function-paren": ["warn", "never"],
53+
"space-before-blocks": ["warn", "always"],
54+
"keyword-spacing": ["warn", {
55+
"before": true,
56+
"after": true
57+
}],
58+
59+
// dangling commas required, but only for multiline objects/arrays
60+
"comma-dangle": ["warn", "always-multiline"],
61+
// always === instead of ==, unless dealing with null/undefined
62+
"eqeqeq": ["error", "smart"],
63+
// always use curly braces, even with single statements
64+
"curly": ["error", "all"],
65+
// phasing out var in favour of let/const is a good idea
66+
"no-var": ["warn"],
67+
// always require semicolons
68+
"semi": ["error", "always"],
69+
// prefer rest and spread over the Old Ways
70+
"prefer-spread": ["warn"],
71+
"prefer-rest-params": ["warn"],
72+
73+
/** react **/
74+
75+
// bind or arrow function in props causes performance issues
76+
"react/jsx-no-bind": ["error"],
77+
"react/jsx-key": ["error"],
78+
"react/prefer-stateless-function": ["warn"],
79+
"react/sort-comp": ["warn"],
80+
81+
/** flowtype **/
82+
"flowtype/require-parameter-type": 1,
83+
"flowtype/require-return-type": [
84+
1,
85+
"always",
86+
{
87+
"annotateUndefined": "never"
88+
}
89+
],
90+
"flowtype/space-after-type-colon": [
91+
1,
92+
"always"
93+
],
94+
"flowtype/space-before-type-colon": [
95+
1,
96+
"never"
97+
]
98+
},
99+
"settings": {
100+
"flowtype": {
101+
"onlyFilesWithFlowAnnotation": true
102+
}
103+
}
104+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
npm-debug.log
2+
13
/node_modules
24
/lib
35

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"reskindex": "reskindex -h header",
1717
"build": "babel src -d lib --source-maps",
1818
"start": "babel src -w -d lib --source-maps",
19+
"lint": "eslint",
20+
"lintall": "eslint src/ test/",
1921
"clean": "rimraf lib",
2022
"prepublish": "npm run build && git rev-parse HEAD > git-revision.txt",
2123
"test": "karma start $KARMAFLAGS --browsers PhantomJS",
@@ -51,8 +53,12 @@
5153
"devDependencies": {
5254
"babel": "^5.8.23",
5355
"babel-core": "^5.8.38",
56+
"babel-eslint": "^6.1.0",
5457
"babel-loader": "^5.4.0",
5558
"babel-polyfill": "^6.5.0",
59+
"eslint": "^2.13.1",
60+
"eslint-plugin-flowtype": "^2.3.0",
61+
"eslint-plugin-react": "^5.2.2",
5662
"expect": "^1.16.0",
5763
"json-loader": "^0.5.3",
5864
"karma": "^0.13.22",

0 commit comments

Comments
 (0)