-
Notifications
You must be signed in to change notification settings - Fork 6
/
eslint.config.mjs
168 lines (155 loc) · 4.68 KB
/
eslint.config.mjs
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
161
162
163
164
165
166
167
168
// @ts-check
import url from 'node:url';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import reactPlugin from 'eslint-plugin-react';
import storybookPlugin from 'eslint-plugin-storybook';
import { FlatCompat } from '@eslint/eslintrc';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const compat = new FlatCompat({ baseDirectory: __dirname });
export default tseslint.config(
{
plugins: {
'@typescript-eslint': tseslint.plugin,
'react': reactPlugin,
},
},
// ignore in all configs
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/build/**',
'**/fixtures/**',
'**/__snapshots__/**',
'**/coverage/**',
'**/_data/**',
'**/generated/**',
'**/storybook-static/**',
'**/.next/**',
'**/migrations/**',
'**/*.d.ts',
'**/jest.config.js',
'**/mocharc.js',
'**/.storybook/**',
'**/.docusaurus/**',
'**/reports/**'
],
},
// extends
eslint.configs.recommended,
...tseslint.configs.recommended,
//
// base config
//
{
languageOptions: {
parserOptions: {
allowAutommaticSingleRunInference: true,
cacheLiftetime: {
// We never create/change tsconfig structure - so no need to ever evict the cache
// In the rare case that we do - just manually restart IDE
glob: 'infinity',
},
project: ['tsconfig.json', 'tsconfig.esm.json', 'tsconfig.react.json', 'packages/*/tsconfig.json'],
tsconfigRootDir: __dirname,
warnOnUnsupportedTypeScriptVersion: true,
},
},
rules: {
'no-console': 'off',
quotes: ['error', 'single'],
semi: ['error', 'always'],
'logical-assignment-operators': 'error',
'no-else-return': 'off',
'no-process-exit': 'off',
'no-fallthrough': ['error', { commentPattern: '.*intentional fallthrough.*' }],
'no-implicit-coercion': ['error', { boolean: false }],
'no-lonely-if': 'error',
'no-unreachable-loop': 'error',
'no-useless-call': 'error',
'no-useless-computed-key': 'off',
'no-useless-escape': 'off',
'no-useless-concat': 'error',
'no-var': 'error',
'no-void': ['error', { allowAsStatement: true }],
'one-var': ['error', 'never'],
'operator-assignment': 'error',
'prefer-const': 'error',
'prefer-object-spread': 'error',
'prefer-rest-params': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
caughtErrors: 'all',
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-empty-function': [
'error',
{
allow: ['arrowFunctions'],
},
],
},
},
{
files: ['**/*.js'],
extends: [tseslint.configs.disableTypeChecked],
rules: {
// turn off other type-aware rules
'deprecation/deprecation': 'off',
'no-undef': 'off',
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
// config for storybook
{
files: ['**/*.stories.tsx'],
extends: [
...compat.config(storybookPlugin.configs.recommended)
],
},
// config for tests
{
files: ['**/*.test.{ts,tsx,js,jsx}'],
rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
}
},
// config for react packages
{
files: ['packages/lib-components/**/*.{ts,tsx,mts,cts,js,jsx}', 'packages/web-main/**/*.{ts,tsx,mts,cts,js,jsx}'],
extends: [
...compat.config(reactPlugin.configs.recommended),
],
rules: {
'import/no-default-export': 'off',
'react/react-in-jsx-scope': 'off',
'react/no-unescaped-entities': 'off',
'react/prop-types': 'off',
'react/exhaustive-deps': 'off',
},
settings: {
react: {
version: 'detect',
},
},
},
);