-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
84 lines (81 loc) · 2.95 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
// rules
const lintTS = {
plugins: ['@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:cypress/recommended',
],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
warnOnUnsupportedTypeScriptVersion: false, // suppress the typescript version difference
},
rules: {
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/no-var-requires': 'off', // turning off because we do not care if we import using es6 or common js... stupid lint
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-use-before-define': ['error', {variables: true}],
// '@typescript-eslint/naming-convention': [
// 'error',
// {
// selector: ['interface'],
// format: ['PascalCase'],
// prefix: ['I'],
// },
// ],
},
}
const lintReact = {
plugins: ['react'],
extends: ['plugin:react/recommended'],
// React Rules: https://www.npmjs.com/package/eslint-plugin-react
rules: {
'react/react-in-jsx-scope': 'off', // from react: Prevent missing React when using JSX -- turned off for next.js
'react/jsx-filename-extension': ['warn', {extensions: ['.tsx']}], // from react: Restrict file extensions that may contain JSX
'react/prop-types': 'off', // from react: Prevent missing props validation in a React component definition
'react/jsx-props-no-spreading': ['error', {custom: 'ignore'}], // from react: Prevent JSX prop spreading
'react/no-unescaped-entities': 'warn', // Turning on to catch possible mistakes
},
settings: {
pragma: 'React',
version: 'detect',
},
}
module.exports = {
root: true,
env: {
browser: true,
node: true,
es2020: true,
},
parserOptions: lintTS.parserOptions,
parser: '@typescript-eslint/parser',
plugins: [...lintTS.plugins, ...lintReact.plugins],
extends: ['eslint:recommended', ...lintTS.extends, ...lintReact.extends],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
// eslint rules: https://eslint.org/docs/rules/
'prefer-const': 'warn', // from eslint: require `const` declarations for variables that are never reassigned after declared
// needed because of https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md#how-to-use & https://stackoverflow.com/questions/63818415/react-was-used-before-it-was-defined
'no-use-before-define': 'off', // from eslint: disallow the use of variables before they are defined
...lintTS.rules,
...lintReact.rules,
},
settings: {
react: lintReact.settings,
'import/resolver': {
'babel-module': {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
paths: ['src'],
},
},
},
}