-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc.js
93 lines (91 loc) · 2.51 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
// eslint-disable-next-line
const fs = require('fs');
const foldersUnderSrc = fs
.readdirSync('src', { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name);
// eslint-disable-next-line
module.exports = {
env: {
browser: true,
node: true,
'jest/globals': true,
es6: true,
},
// all of these globals are from the _old_ wp code
globals: {
angular: true,
wp: true,
jQuery: true,
define: true,
},
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended',
'plugin:jest/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
plugins: ['react', 'react-hooks', 'prettier', 'babel', 'import', 'simple-import-sort'],
overrides: [
{
files: ['*.js', '*.jsx', '*.tsx', '*.ts'],
rules: {
'simple-import-sort/imports': [
'error',
{
groups: [
// Packages. `react` related packages come first.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
['^react', '^@?\\w'],
// Absolute imports and Relative imports.
[`^(${foldersUnderSrc.join('|')})(/.*|$)`, '^\\.'],
// for scss imports.
['^[^.]'],
],
},
],
},
},
],
rules: {
'no-console': 'warn',
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'prettier/prettier': 'warn',
'react-hooks/rules-of-hooks': 'warn',
'react-hooks/exhaustive-deps': 'warn',
'@typescript-eslint/no-var-requires': 'off',
semi: 'off',
'react/prop-types': 'off',
'simple-import-sort/imports': 'warn',
// remove these if deprecating old scripts
'@typescript-eslint/no-this-alias': 'warn',
'no-empty': 'warn',
'no-prototype-builtins': 'warn',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
'babel-module': {},
},
},
};