Skip to content

Commit 565f1cd

Browse files
authored
Merge pull request #563 from john-s-morgan/master
Setup ESLint for react project
2 parents 7dded8d + d3c1d0b commit 565f1cd

File tree

3 files changed

+65
-10
lines changed

3 files changed

+65
-10
lines changed

reactjs/.eslintrc.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
extends: [
4+
'airbnb-typescript',
5+
'plugin:react/recommended',
6+
'plugin:react-hooks/recommended',
7+
'plugin:@typescript-eslint/recommended',
8+
'plugin:jsx-a11y/recommended',
9+
'plugin:jest/recommended',
10+
'prettier/@typescript-eslint',
11+
'prettier',
12+
],
13+
plugins: ['react-hooks'],
14+
parserOptions: {
15+
ecmaFeatures: {
16+
jsx: true,
17+
},
18+
ecmaVersion: 2020,
19+
sourceType: 'module',
20+
project: './tsconfig.json',
21+
},
22+
rules: {
23+
'react-hooks/rules-of-hooks': 'error',
24+
'react-hooks/exhaustive-deps': 'warn',
25+
'react/prop-types': 'off',
26+
'@typescript-eslint/explicit-function-return-type': 'off',
27+
curly: 'error',
28+
'@typescript-eslint/no-unused-vars': 'warn', // Imports of interfaces throw this.
29+
'react/jsx-one-expression-per-line': 0,
30+
},
31+
settings: {
32+
react: {
33+
version: 'detect',
34+
},
35+
},
36+
ignorePatterns: ['node_modules/', 'src/registerServiceWorker.ts'],
37+
};

reactjs/.prettierrc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
2-
"singleQuote": true,
3-
"trailingComma": "es5",
4-
"printWidth": 150,
5-
"overrides": [{
6-
"files": ".prettierrc",
7-
"options": {
8-
"parser": "json"
9-
}
10-
}]
11-
}
2+
"singleQuote": true,
3+
"trailingComma": "es5",
4+
"printWidth": 100,
5+
"overrides": [
6+
{
7+
"files": ".prettierrc",
8+
"options": {
9+
"parser": "json"
10+
}
11+
}
12+
]
13+
}

reactjs/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@
2525
"react-scripts": "^3.2.0",
2626
"recharts": "^1.8.5"
2727
},
28+
"eslintConfig": {
29+
"extends": "react-app"
30+
},
2831
"scripts": {
2932
"start": "craco start",
3033
"build": "craco build",
34+
"lint": "eslint . --ext .ts,.tsx",
3135
"test": "craco test",
3236
"eject": "react-scripts eject"
3337
},
@@ -43,7 +47,19 @@
4347
"@types/react-loadable": "^5.5.2",
4448
"@types/react-router-dom": "^5.1.3",
4549
"@types/recharts": "^1.8.3",
50+
"@typescript-eslint/eslint-plugin": "^4.0.1",
51+
"@typescript-eslint/parser": "^4.0.1",
4652
"copy-webpack-plugin": "^5.0.5",
53+
"eslint": "^6.8.0",
54+
"eslint-config-airbnb-typescript": "^9.0.0",
55+
"eslint-config-prettier": "^6.11.0",
56+
"eslint-plugin-import": "^2.22.0",
57+
"eslint-plugin-jest": "^23.17.1",
58+
"eslint-plugin-jsx-a11y": "^6.3.1",
59+
"eslint-plugin-prettier": "^3.1.4",
60+
"eslint-plugin-react": "^7.20.6",
61+
"eslint-plugin-react-hooks": "^4.1.0",
62+
"prettier": "^2.0.5",
4763
"ts-import-plugin": "^1.6.1",
4864
"typescript": "^3.7.2"
4965
},

0 commit comments

Comments
 (0)