-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy patheslint.config.js
More file actions
160 lines (150 loc) · 3.86 KB
/
eslint.config.js
File metadata and controls
160 lines (150 loc) · 3.86 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import globals from 'globals';
import tseslint from 'typescript-eslint';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import importPlugin from 'eslint-plugin-import';
import prettierConfig from 'eslint-config-prettier';
import jestPlugin from 'eslint-plugin-jest';
import unusedImportsPlugin from 'eslint-plugin-unused-imports';
export default [
// Global ignores (replaces ignorePatterns)
{
ignores: ['temp.js', 'node_modules/', '**/*.scss.d.ts', '**/*.scss', '.cache/', 'public/'],
},
// Base config for all JS/TS files
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.browser,
...globals.es2021,
...globals.node,
...globals.jest,
__PATH_PREFIX__: 'readonly',
graphql: 'readonly',
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
'jsx-a11y': jsxA11yPlugin,
import: importPlugin,
'unused-imports': unusedImportsPlugin,
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
'import/core-modules': ['gatsby'],
react: {
version: 'detect',
},
},
rules: {
// Import rules
'import/extensions': [
0,
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'import/no-anonymous-default-export': [1],
// Accessibility
'jsx-a11y/anchor-is-valid': [
2,
{
components: ['Link'],
specialLink: ['to'],
aspects: ['noHref', 'invalidHref', 'preferButton'],
},
],
// Code style
'linebreak-style': [1, 'unix'],
'prefer-template': [0],
'comma-dangle': [0],
'semi-style': [2, 'last'],
'func-style': [1, 'expression'],
'prefer-const': [1],
// React
'react/destructuring-assignment': [1, 'always'],
'react/jsx-pascal-case': [1],
'react/jsx-closing-bracket-location': [1],
'react/jsx-closing-tag-location': [1],
'react/jsx-tag-spacing': [1],
'react/jsx-uses-react': [1],
'react/jsx-uses-vars': [1],
// React Hooks
'react-hooks/rules-of-hooks': [2],
'react-hooks/exhaustive-deps': [0],
// Unused imports/vars
'no-unused-vars': [0],
'unused-imports/no-unused-imports': [1],
'unused-imports/no-unused-vars': [
1,
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
},
},
// TypeScript-specific config (replaces overrides block)
...tseslint.configs.recommended.map(config => ({
...config,
files: ['**/*.{ts,tsx}'],
})),
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tseslint.parser,
},
rules: {
'@typescript-eslint/no-inferrable-types': [0],
'@typescript-eslint/no-unused-vars': [0],
'@typescript-eslint/no-explicit-any': [1],
'@typescript-eslint/no-empty-object-type': [1],
},
},
// Jest test files
{
files: ['**/*.test.{js,jsx,ts,tsx}', '**/*.spec.{js,jsx,ts,tsx}'],
plugins: {
jest: jestPlugin,
},
languageOptions: {
globals: {
...globals.jest,
},
},
},
{
files: ['**/__tests__/**', '**/*spec.*', '**/*test.*', '**/*.bypass.*'],
rules: {
'import/extensions': [0],
},
},
// Prettier must be last - disables conflicting rules
prettierConfig,
{
files: ['**/*.{js,jsx,ts,tsx}'],
rules: {
'max-len': [1, 150],
},
},
];