-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheslint.config.js
More file actions
122 lines (120 loc) · 3.06 KB
/
eslint.config.js
File metadata and controls
122 lines (120 loc) · 3.06 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
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
115
116
117
118
119
120
121
122
const react = require('eslint-plugin-react')
const jsxA11Y = require('eslint-plugin-jsx-a11y')
const prettier = require('eslint-plugin-prettier')
const js = require('@eslint/js')
const globals = require('globals')
const browserGlobals = Object.fromEntries(Object.entries(globals.browser).filter(([key]) => key.trim() === key))
module.exports = [
{
ignores: [
'**/*.json',
'**/node_modules/**',
'**/theme/public/**',
'**/www.chrisvogt.me/public/**',
'**/www.chronogrove.com/public/**',
'**/.cache/**'
]
},
{
files: ['theme/**/*.js', 'www.chrisvogt.me/**/*.js']
},
{
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
// Explicitly define browser globals we want to use
window: 'readonly',
document: 'readonly',
navigator: 'readonly',
location: 'readonly',
history: 'readonly',
localStorage: 'readonly',
sessionStorage: 'readonly',
fetch: 'readonly',
requestAnimationFrame: 'readonly',
cancelAnimationFrame: 'readonly',
ResizeObserver: 'readonly',
// Node.js globals
...globals.node
}
}
},
js.configs.recommended,
{
plugins: {
react,
'jsx-a11y': jsxA11Y,
prettier
},
rules: {
'prettier/prettier': [
'error',
{
singleQuote: true,
semi: false,
trailingComma: 'none',
bracketSpacing: true,
arrowParens: 'avoid',
jsxSingleQuote: true
}
],
quotes: ['error', 'single', { avoidEscape: true }],
semi: ['error', 'never'],
'comma-dangle': ['error', 'never'],
'jsx-a11y/no-noninteractive-element-interactions': 'warn',
'react/prop-types': 'off',
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'no-unused-vars': ['error', { varsIgnorePattern: '^React$' }]
},
settings: {
react: {
version: 'detect'
}
},
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true
}
}
}
},
{
plugins: {
json: require('eslint-plugin-json')
},
files: ['**/*.json'],
rules: {
'json/*': 'error'
}
},
{
files: ['**/*.spec.js', 'theme/jest-shim.js'], // Target Jest spec files
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.jest, // Include Jest globals for describe, it, etc.
...browserGlobals, // Filtered browser globals
getComputedStyle: 'readonly',
Event: 'readonly',
HTMLCanvasElement: 'readonly',
requestAnimationFrame: 'readonly'
}
},
plugins: {
jest: require('eslint-plugin-jest') // Add Jest plugin
},
rules: {
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error'
}
}
]