-
Notifications
You must be signed in to change notification settings - Fork 11
/
eslint.config.js
118 lines (106 loc) · 2.88 KB
/
eslint.config.js
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
// @ts-check
import eslint from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
import jestPlugin from 'eslint-plugin-jest';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import reactPlugin from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
export default tseslint.config(
// config ignores files, equal `.eslintignore`
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/.cache/**',
'**/.history/**',
'**/.idea/**',
'./*.?*.ts',
'bindings/**',
// Files of the build
'dist/*',
],
},
// extends configs
eslint.configs.recommended,
// basic config
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.es2021,
...globals.browser,
},
},
rules: {
'no-unused-vars': 'warn',
'no-unsafe-optional-chaining': 'warn',
'no-constant-condition': 'off',
'no-prototype-builtins': 'off',
'no-case-declarations': 'off',
'no-useless-catch': 'off',
'prefer-rest-params': 'off',
},
},
// ts files linting
{
files: ['**/*.{ts,tsx}'],
extends: [...tseslint.configs.recommended],
languageOptions: {
parserOptions: {
project: './tsconfig.eslint.json',
tsconfigRootDir: __dirname,
},
},
rules: {
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
'@typescript-eslint/no-loss-of-precision': 0,
'@typescript-eslint/no-inferrable-types': 0,
'@typescript-eslint/ban-types': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-duplicate-enum-values': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/no-empty-object-type': 0,
'@typescript-eslint/no-unused-expressions': ['error', { allowShortCircuit: true }],
},
},
// react tsx files linting
{
files: ['**/*.{tsx}'],
...reactPlugin.configs.recommended,
...reactHooks.configs.recommended,
plugins: {
'jsx-a11y': jsxA11yPlugin,
},
rules: {},
},
//
// test jest file linting
//
{
files: ['test/**/*.spec.ts'],
...jestPlugin.configs['flat/recommended'],
rules: {},
},
//
// evaluations scripts file linting
//
{
languageOptions: {
globals: {
...globals.node,
},
},
},
// after all eslint plugins configs to override, see https://github.com/prettier/eslint-config-prettier
// @ts-ignore
prettierConfig,
);