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

Commit a97ae9b

Browse files
committed
feat: add react hooks & adjust rules
BREAKING CHANGE: eslint-plugin-react-hooks is required
1 parent 9751148 commit a97ae9b

File tree

7 files changed

+1173
-762
lines changed

7 files changed

+1173
-762
lines changed

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CHANGELOG.md
2+
node_modules/

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"semi": false
5+
}

dev.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
rules: {
3+
// https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
34
'import/no-extraneous-dependencies': 'off',
45
},
56
}

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ module.exports = {
1010
sourceType: 'module',
1111
},
1212
rules: {
13+
// https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
1314
'import/prefer-default-export': 'off',
15+
'import/first': 'error',
16+
'import/no-amd': 'error',
17+
'import/no-webpack-loader-syntax': 'error',
18+
'import/no-extraneous-dependencies': [
19+
'error',
20+
{ devDependencies: ['**/*.stories.js', '**/*.test.js'] },
21+
],
1422

1523
'no-param-reassign': 'off',
1624
'no-shadow': 'off',

package.json

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,31 @@
1010
"main": "index.js",
1111
"license": "MIT",
1212
"scripts": {
13+
"format": "prettier --write \"*.{js,md}\"",
1314
"release": "standard-version && conventional-github-releaser -p angular",
1415
"test": "eslint ."
1516
},
1617
"devDependencies": {
17-
"babel-eslint": "^8.2.2",
18-
"conventional-github-releaser": "^2.0.2",
19-
"eslint": "^4.19.1",
20-
"eslint-config-airbnb": "^16.1.0",
21-
"eslint-config-prettier": "^2.9.0",
22-
"eslint-plugin-import": "^2.10.0",
23-
"eslint-plugin-jsx-a11y": "^6.0.3",
24-
"eslint-plugin-react": "^7.7.0",
25-
"standard-version": "^4.3.0"
18+
"babel-eslint": "^10.0.1",
19+
"conventional-github-releaser": "^3.1.2",
20+
"eslint": "^5.15.0",
21+
"eslint-config-airbnb": "^17.1.0",
22+
"eslint-config-prettier": "^4.1.0",
23+
"eslint-plugin-import": "^2.16.0",
24+
"eslint-plugin-jsx-a11y": "^6.2.1",
25+
"eslint-plugin-react": "^7.12.4",
26+
"eslint-plugin-react-hooks": "^1.4.0",
27+
"prettier": "^1.16.4",
28+
"standard-version": "^5.0.1"
2629
},
2730
"peerDependencies": {
28-
"babel-eslint": ">=8.2.2",
29-
"eslint": ">=4.19.1",
30-
"eslint-config-airbnb": ">=16.1.0",
31-
"eslint-config-prettier": ">=2.9.0",
32-
"eslint-plugin-import": ">=2.10.0",
33-
"eslint-plugin-jsx-a11y": ">=6.0.3",
34-
"eslint-plugin-react": ">=7.7.0"
31+
"babel-eslint": "^10.0.0",
32+
"eslint": "^5.15.0",
33+
"eslint-config-airbnb": "^17.1.0",
34+
"eslint-config-prettier": "^4.1.0",
35+
"eslint-plugin-import": "^2.16.0",
36+
"eslint-plugin-jsx-a11y": "^6.2.0",
37+
"eslint-plugin-react": "^7.12.0",
38+
"eslint-plugin-react-hooks": "^1.4.0"
3539
}
3640
}

react.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,41 @@ const baseRules = require('./index').rules
22

33
module.exports = {
44
extends: ['airbnb', 'prettier', 'prettier/react'],
5+
plugins: ['react-hooks'],
56
rules: Object.assign(baseRules, {
7+
// https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
68
'react/jsx-filename-extension': ['error', { extensions: ['.js'] }],
79
'react/prop-types': 'off',
810
'react/sort-comp': 'off',
911
'react/no-did-mount-set-state': 'off',
1012
'react/require-default-props': 'off',
1113
'react/no-array-index-key': 'off',
12-
'react/no-typos': 'off',
14+
'react/destructuring-assignment': 'off',
15+
'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
16+
'react/jsx-no-comment-textnodes': 'warn',
17+
'react/jsx-no-duplicate-props': ['warn', { ignoreCase: true }],
18+
'react/jsx-no-target-blank': 'warn',
19+
'react/jsx-no-undef': 'error',
20+
'react/jsx-pascal-case': [
21+
'warn',
22+
{
23+
allowAllCaps: true,
24+
ignore: [],
25+
},
26+
],
27+
'react/jsx-uses-react': 'warn',
28+
'react/jsx-uses-vars': 'warn',
29+
'react/no-danger-with-children': 'warn',
30+
'react/no-deprecated': 'warn',
31+
'react/no-direct-mutation-state': 'warn',
32+
'react/no-is-mounted': 'warn',
33+
'react/no-typos': 'error',
34+
'react/react-in-jsx-scope': 'error',
35+
'react/require-render-return': 'error',
36+
'react/style-prop-object': 'warn',
37+
38+
'react-hooks/rules-of-hooks': 'error',
39+
'react-hooks/exhaustive-deps': 'warn',
1340

1441
'jsx-a11y/anchor-is-valid': 'off',
1542
'jsx-a11y/anchor-has-content': 'off',

0 commit comments

Comments
 (0)