-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy patheslint.config.js
More file actions
96 lines (93 loc) · 2.47 KB
/
eslint.config.js
File metadata and controls
96 lines (93 loc) · 2.47 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
import { join } from 'node:path';
import { includeIgnoreFile } from '@eslint/compat';
import eslint from '@eslint/js';
import configPrettier from 'eslint-config-prettier/flat';
import pluginJsxA11y from 'eslint-plugin-jsx-a11y';
import pluginNodeImport from 'eslint-plugin-node-import';
import pluginReact from 'eslint-plugin-react';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import { defineConfig, globalIgnores } from 'eslint/config';
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,
pluginTypeScript.configs.recommended,
pluginNodeImport.configs['flat/recommended'],
configPrettier,
],
languageOptions: {
parser: pluginTypeScript.parser,
parserOptions: {
ecmaVersion: 'latest',
projectService: true,
tsconfigRootDir: rootPath,
},
},
rules: {
// 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,
},
],
},
},
{
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'),
]);