Skip to content

Commit caad21a

Browse files
committed
style: improve lint config
1 parent eea08d7 commit caad21a

File tree

3 files changed

+60
-51
lines changed

3 files changed

+60
-51
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ build
33
.cache
44
dist
55
coverage
6+
!.eslintrc.js

.eslintrc.js

+51-45
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,71 @@
1+
const ignoreExports = [
2+
'.eslintrc.js',
3+
'app/script.js',
4+
'app/script.test.js',
5+
'commitlint.config.js',
6+
'test/About.test.js',
7+
'truffle-config.js',
8+
// TODO: Fix index exports
9+
'**/index.js',
10+
]
11+
112
module.exports = {
213
env: {
314
browser: true,
15+
commonjs: true,
416
es6: true,
517
node: true,
6-
commonjs: true,
718
},
819
extends: [
20+
'standard', 'standard-react',
921
'eslint:recommended',
1022
'plugin:import/errors',
11-
'plugin:react/recommended',
23+
'plugin:react/recommended', // will import plugin and enable jsx in parser options
1224
'plugin:jsx-a11y/recommended',
1325
],
1426
parser: 'babel-eslint',
1527
parserOptions: {
16-
ecmaFeatures: {
17-
jsx: true
18-
},
1928
ecmaVersion: 2018,
20-
sourceType: 'module'
2129
},
22-
plugins: ['react'],
30+
plugins: [ 'react-hooks', 'sort-keys-fix' ],
2331
rules: {
24-
'arrow-parens': ["error", "as-needed"],
25-
indent: ['error', 2],
26-
'linebreak-style': ['error', 'unix'],
27-
quotes: ['error', 'single'],
28-
'react/no-typos': 1,
29-
semi: ['error', 'never'],
30-
'array-bracket-spacing': [
31-
'error',
32-
'always',
33-
{
34-
objectsInArrays: false,
35-
arraysInArrays: false,
36-
singleValue: false
37-
}
38-
],
39-
'func-style': ["warn", "declaration", { "allowArrowFunctions": true }],
40-
'object-curly-spacing': ['error', 'always'],
41-
// "import/no-unused-modules": [
42-
// "warn",
43-
// {
44-
// unusedExports: true,
45-
// missingExports: true,
46-
// ignoreExports: [],
47-
// }
48-
// ],
49-
"no-undef": "error",
50-
"no-unused-vars": ["warn", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }],
51-
'no-console': ['warn', { allow: ['warn', 'error'] }],
52-
"react/jsx-uses-react": "warn",
53-
"react/jsx-uses-vars": "warn",
54-
"react/jsx-filename-extension": "off",
55-
"react/no-unused-prop-types": "warn",
56-
"react/self-closing-comp": ["error", {"component": true, "html": true}],
57-
"sort-imports": ["warn", { "ignoreDeclarationSort": true }]
32+
'array-bracket-spacing': [ 'error', 'always', { singleValue: false } ],
33+
'arrow-parens': [ 'error', 'as-needed' ],
34+
'comma-dangle': [ 'error', 'always-multiline' ],
35+
'comma-spacing': ['error'],
36+
'func-style': [ 'warn', 'declaration', { 'allowArrowFunctions': true } ],
37+
'import/no-unresolved': ['error'],
38+
'import/no-unused-modules': [ 'error', { ignoreExports, missingExports: true, unusedExports: true } ],
39+
'indent': [ 'error', 2 ],
40+
'linebreak-style': [ 'error', 'unix' ],
41+
'no-console': [ 'warn', { allow: [ 'warn', 'error' ] } ],
42+
'no-multi-spaces': 'error',
43+
'no-trailing-spaces': ['error'],
44+
'no-undef': 'error',
45+
'no-unused-vars': [ 'warn', { 'args': 'after-used', 'ignoreRestSiblings': false, 'vars': 'all' } ],
46+
'object-curly-spacing': [ 'error', 'always' ],
47+
'quotes': [ 'error', 'single' ],
48+
'react-hooks/exhaustive-deps': 'error',
49+
'react-hooks/rules-of-hooks': 'error',
50+
'react/default-props-match-prop-types': ['error'],
51+
'react/destructuring-assignment': [ 'error', 'always' ],
52+
'react/forbid-prop-types': ['warn'],
53+
'react/function-component-definition': [ 'error', { 'namedComponents': 'arrow-function', 'unnamedComponents': 'function-expression' } ],
54+
'react/no-array-index-key': 'warn',
55+
'react/no-danger': 'error',
56+
'react/no-typos': 'error',
57+
'react/no-unused-prop-types': 'warn',
58+
'react/require-default-props': ['error'],
59+
'react/self-closing-comp': [ 'error', { 'component': true, 'html': true } ],
60+
'react/sort-comp': ['error'],
61+
'react/sort-prop-types': [ 'error', { 'ignoreCase': true, 'sortShapeProp': 'true' } ],
62+
'react/void-dom-elements-no-children': 'error',
63+
'semi': [ 'error', 'never' ],
64+
'sort-imports': [ 'error', { 'ignoreDeclarationSort': true } ],
65+
'sort-keys-fix/sort-keys-fix': 'error',
5866
},
5967
settings: {
60-
react: {
61-
version: 'detect',
62-
}
63-
}
68+
react: { version: 'detect' },
69+
},
6470
}
6571

package.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@types/react": "^16.8.6",
4444
"acorn": "^6.1.1",
4545
"ava": "^1.4.1",
46-
"babel-eslint": "^10.0.1",
46+
"babel-eslint": "^10.0.3",
4747
"babel-plugin-styled-components": "^1.10.0",
4848
"copyfiles": "^2.1.1",
4949
"coveralls": "3.0.2",
@@ -52,12 +52,14 @@
5252
"eslint-config-prettier": "^6.0.0",
5353
"eslint-config-standard": "^12.0.0",
5454
"eslint-config-standard-react": "^7.0.2",
55-
"eslint-plugin-import": "^2.17.3",
55+
"eslint-plugin-import": "^2.20.0",
5656
"eslint-plugin-jsx-a11y": "^6.2.1",
57-
"eslint-plugin-node": "^9.1.0",
58-
"eslint-plugin-promise": "^4.1.1",
59-
"eslint-plugin-react": "^7.13.0",
60-
"eslint-plugin-standard": "^4.0.0",
57+
"eslint-plugin-node": "^9.2.0",
58+
"eslint-plugin-promise": "^4.2.1",
59+
"eslint-plugin-react": "^7.18.0",
60+
"eslint-plugin-react-hooks": "^2.3.0",
61+
"eslint-plugin-sort-keys-fix": "^1.1.0",
62+
"eslint-plugin-standard": "^4.0.1",
6163
"eth-gas-reporter": "0.1.12",
6264
"ethereumjs-abi": "0.6.5",
6365
"ganache-cli": "6.1.8",

0 commit comments

Comments
 (0)