-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
106 lines (100 loc) · 2.76 KB
/
eslint.config.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
import js from '@eslint/js'
import reactPlugin from 'eslint-plugin-react'
import reactHooksPlugin from 'eslint-plugin-react-hooks'
import importSortPlugin from 'eslint-plugin-simple-import-sort'
import globals from 'globals'
import wordpressPlugin from '@wordpress/eslint-plugin'
export default [
js.configs.recommended,
{
files: ['src/scripts/**/*.{js,jsx,ts,tsx}', '*.mjs', '*.cjs'],
},
{
...reactPlugin.configs.flat.recommended,
settings: { react: { version: 'detect' } },
languageOptions: {
globals: {
...globals.browser,
...globals.es2021,
process: true,
wp: true,
jQuery: true,
Zubug: true,
},
ecmaVersion: 2021,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
react: reactPlugin,
'simple-import-sort': importSortPlugin,
'react-hooks': reactHooksPlugin,
'@wordpress': wordpressPlugin,
},
rules: {
...reactPlugin.configs.recommended.rules,
...wordpressPlugin.configs.rules,
...reactHooksPlugin.configs.recommended.rules,
// general
semi: ['warn', 'never'],
'no-console': 'warn',
'object-shorthand': 'warn',
'no-useless-catch': 'warn',
'no-empty-pattern': 'warn',
'no-unneeded-ternary': 'warn',
'no-nested-ternary': 'off',
'object-curly-spacing': ['warn', 'always'],
indent: 'off',
'no-multi-spaces': 'warn',
'eol-last': ['warn', 'always'],
'no-multiple-empty-lines': ['warn', { max: 2, maxEOF: 0, maxBOF: 0 }],
'comma-spacing': 'warn',
'spaced-comment': ['warn', 'always', { markers: ['/'] }],
'no-duplicate-imports': 'warn',
'no-trailing-spaces': 'warn',
'no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'no-use-before-define': 'error',
// react
...reactPlugin.configs['jsx-runtime'].rules,
'jsx-quotes': ['warn', 'prefer-double'],
'react/jsx-equals-spacing': ['warn', 'never'],
'react/jsx-no-literals': 'off',
'react/jsx-fragments': ['warn'],
'react/jsx-no-target-blank': 'warn',
'react/jsx-first-prop-new-line': ['warn', 'multiline'],
'react/jsx-closing-bracket-location': ['warn', 'tag-aligned'],
'react/no-unused-prop-types': 'warn',
'react/self-closing-comp': 'warn',
'react/prop-types': 'off',
// wordpress
'@wordpress/no-unused-vars-before-return': 'off',
// imports
'simple-import-sort/imports': [
'warn',
{
groups: [
['^\\u0000'],
['^lodash-es', '^react', '^@?\\w'],
['^@wordpress/'],
['^components', '^data', '^hooks', '^plugins'],
['^\\.'],
],
},
],
},
},
// `ignores` should be the last item in config
// https://github.com/eslint/eslint/issues/17400#issuecomment-1647463901
{ ignores: ['dist/**'] },
]