Repository navigation
Expand file tree
/
Copy patheslint.config.mjs
More file actions
135 lines (119 loc) · 3.45 KB
/
Copy patheslint.config.mjs
File metadata and controls
135 lines (119 loc) · 3.45 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
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import eslint from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import noNull from 'eslint-plugin-no-null';
import globals from 'globals';
import header from 'eslint-plugin-header';
import tseslint from 'typescript-eslint';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
const getRules = configArray => {
let rules = {};
const addRulesFromObject = config => {
if (Object.hasOwn(config, 'rules')) {
rules = {
...rules,
...config.rules,
};
}
};
if (Array.isArray(configArray)) {
for (const config of configArray) {
addRulesFromObject(config);
}
} else {
addRulesFromObject(configArray);
}
return rules;
};
const rules = {
...getRules(eslint.configs.recommended),
...getRules(tseslint.configs.recommended),
...{
'no-irregular-whitespace': 0,
semi: [2, 'always'],
'react/display-name': 0,
'react/react-in-jsx-scope': 0,
'no-prototype-builtins': 0,
'@typescript-eslint/no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/ban-ts-comment': 0,
"@typescript-eslint/no-empty-interface": 0,
},
};
const reactCompat = compat.extends('plugin:react/recommended');
const reactPlugin = reactCompat[0].plugins.react;
const defaultConfig = [
{
ignores: [
'**/*.d.ts',
'**/*.scss.d.ts',
'**/tsconfig.*',
'**/wallaby.js',
'**/*.js',
'**/dist/**',
'**/node_modules/**',
'**/wwwroot/**',
'**/templates/**',
'**/Api/**',
'**/rollup.config.mjs'
],
},
{
files: ['**/*.ts', '**/*.tsx'],
plugins: {
'@typescript-eslint': typescriptEslint,
react: reactPlugin,
header,
'no-null': noNull
},
rules: rules,
languageOptions: {
globals: {
...globals.browser,
},
parser: tsParser,
sourceType: 'module',
},
settings: {
react: {
version: 'detect',
},
},
},
{
files: ['Library/**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
{
files: ['**/for_*/**/*.ts'],
rules: {
'@typescript-eslint/naming-convention': 0,
'@typescript-eslint/no-unused-expressions': 0,
"@typescript-eslint/no-empty-function": "off",
'no-restricted-globals': 0,
},
},
];
const config = tseslint.config(...defaultConfig);
export default config;