-
Notifications
You must be signed in to change notification settings - Fork 19
/
.eslintrc.js
executable file
·114 lines (105 loc) · 3.75 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const path = require('path');
// ESLint configuration
// http://eslint.org/docs/user-guide/configuring
module.exports = {
env: { browser: true, es6: true, node: true },
extends: ['react-app', 'prettier', 'prettier/react'],
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['prettier', 'react-hooks'],
rules: {
// Forbid the use of extraneous packages
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
'import/no-extraneous-dependencies': ['off'],
// Recommend not to leave any console.log in your code
// Use console.error, console.warn and console.info instead
// https://eslint.org/docs/rules/no-console
'no-console': [
'error',
{
allow: ['warn', 'error', 'info', 'log'],
},
],
// Prefer destructuring from arrays and objects
// http://eslint.org/docs/rules/prefer-destructuring
'prefer-destructuring': [
'error',
{
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: false,
object: false,
},
},
{
enforceForRenamedProperties: false,
},
],
// Allow .js files to use JSX syntax
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx'] }],
// Functional and class components are equivalent from React’s point of view
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
'react/prefer-stateless-function': 'off',
// ESLint plugin for prettier formatting
// https://github.com/prettier/eslint-plugin-prettier
'prettier/prettier': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
settings: {
// Allow absolute paths in imports, e.g. import Button from 'components/Button'
// https://github.com/benmosher/eslint-plugin-import/tree/master/resolvers
'import/resolver': {
webpack: {
config: path.resolve(__dirname, 'config/webpack.config.js'),
},
},
},
overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
env: { browser: true, es6: true, node: true },
extends: [
// 'eslint:recommended',
// 'plugin:react/recommended',
// 'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: 2018,
sourceType: 'module',
project: './tsconfig.json',
},
plugins: ['react', '@typescript-eslint'],
rules: {
// indent: ['error', 2, { SwitchCase: 1 }],
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
// 'comma-dangle': ['error', 'always-multiline'],
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/camelcase': 0,
// '@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-var-requires': 0,
'no-case-declarations': 0,
'react/display-name': 0,
'react/prop-types': 0,
},
settings: { react: { version: 'detect' } },
},
],
};