-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.eslintrc.js
More file actions
76 lines (74 loc) · 2.31 KB
/
Copy path.eslintrc.js
File metadata and controls
76 lines (74 loc) · 2.31 KB
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
module.exports = {
extends: [ '@10up/eslint-config' ],
globals: {
wp: 'readonly',
},
settings: {
// Treat `@wordpress/*` packages as built-in modules — they are
// provided by WordPress at runtime (externalized by Webpack) and
// are not in node_modules, so import/no-unresolved would otherwise
// fail on every import.
'import/core-modules': [
'@wordpress/api-fetch',
'@wordpress/components',
'@wordpress/core-data',
'@wordpress/data',
'@wordpress/editor',
'@wordpress/element',
'@wordpress/i18n',
'@wordpress/plugins',
],
},
rules: {
// Match the codebase's WordPress-style paren spacing (`fn( arg )`).
// @10up/eslint-config sets `parenSpacing: false`; with the `prettier`
// package overridden to `wp-prettier` (see package.json overrides),
// re-specifying the option here flips it on. Other Prettier options
// mirror the @10up defaults.
'prettier/prettier': [
2,
{
useTabs: true,
tabWidth: 4,
printWidth: 100,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: true,
parenSpacing: true,
bracketSameLine: false,
semi: true,
arrowParens: 'always',
},
{
usePrettierrc: false,
},
],
// Removed in eslint-plugin-jsdoc v46 (we pin v46 via package.json
// `overrides` because v31 — bundled with @10up/scripts@1.3.4 — crashes
// on Node 20+). The @10up config still tries to enable this removed
// rule, so we silence it here.
'jsdoc/newline-after-description': 'off',
// Allow hoisted function references — codebase relies on hoisting for
// helper functions declared after their first call site.
'no-use-before-define': [ 'error', { functions: false, classes: true, variables: true } ],
},
overrides: [
{
// Editor file uses JSX (WordPress block editor) and React hooks.
files: [ 'assets/js/editor/**/*.js' ],
parserOptions: {
ecmaFeatures: { jsx: true },
},
plugins: [ 'react', 'react-hooks' ],
rules: {
// Mark variables referenced in JSX as used so no-unused-vars
// doesn't flag imported components like <Button>.
'react/jsx-uses-vars': 'error',
'react/jsx-uses-react': 'off',
// Real check on hook dependency arrays. Inline disable comments
// at specific call sites suppress intentional omissions.
'react-hooks/exhaustive-deps': 'warn',
},
},
],
};