-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy patheslint.config.js
More file actions
127 lines (121 loc) · 3.41 KB
/
eslint.config.js
File metadata and controls
127 lines (121 loc) · 3.41 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
import { join } from 'node:path';
import { includeIgnoreFile } from '@eslint/compat';
import eslint from '@eslint/js';
import { defineConfig, globalIgnores } from 'eslint/config';
import configPrettier from 'eslint-config-prettier/flat';
import pluginImport from 'eslint-plugin-import';
import pluginJsxA11y from 'eslint-plugin-jsx-a11y';
import pluginReact from 'eslint-plugin-react';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';
import pluginTypeScript from 'typescript-eslint';
const rootPath = import.meta.dirname;
const gitignorePath = join(rootPath, '.gitignore');
export default defineConfig([
{
files: ['**/*.{js,mjs,ts,tsx}'],
extends: [
eslint.configs.recommended,
pluginImport.flatConfigs.recommended,
pluginImport.flatConfigs.typescript,
pluginTypeScript.configs.recommended,
configPrettier,
],
languageOptions: {
parser: pluginTypeScript.parser,
parserOptions: {
ecmaVersion: 'latest',
projectService: true,
tsconfigRootDir: rootPath,
},
},
rules: {
// Turn off rules that are handled by TypeScript
// https://typescript-eslint.io/troubleshooting/typed-linting/performance/#eslint-plugin-import
'import/default': 'off',
'import/named': 'off',
'import/namespace': 'off',
'import/no-cycle': 'off',
'import/no-deprecated': 'off',
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'import/no-unresolved': 'off',
'import/no-unused-modules': 'off',
// Always import Node.js packages from `node:*`
'import/enforce-node-protocol-usage': ['error', 'always'],
// Check import or require statements are A-Z ordered
'import/order': [
'error',
{
'alphabetize': { order: 'asc' },
'newlines-between': 'always',
},
],
// Prefer rules that are type aware
'no-redeclare': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
settings: {
'import/resolver': {
node: true,
typescript: true,
},
},
},
{
files: ['**/*.{ts,tsx}'],
extends: [
pluginJsxA11y.flatConfigs.recommended,
pluginReact.configs.flat.recommended,
pluginReact.configs.flat['jsx-runtime'],
pluginReactHooks.configs.flat.recommended,
],
languageOptions: {
globals: globals.browser,
parserOptions: {
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
settings: {
react: {
version: 'detect',
},
},
},
{
files: ['**/*.{cjs,js,mjs}'],
languageOptions: {
globals: globals.node,
},
},
{
files: ['**/*.cjs'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['**/*.test.{ts,tsx}'],
languageOptions: {
globals: globals.jest,
},
},
{
files: ['**/*.stories.tsx'],
rules: { '@typescript-eslint/no-unused-vars': 'off' },
},
globalIgnores(['**/coverage/', '**/dist/']),
includeIgnoreFile(gitignorePath, 'Imported .gitignore patterns'),
]);