forked from eclipse-oct/open-collaboration-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
183 lines (175 loc) · 7.13 KB
/
eslint.config.mjs
File metadata and controls
183 lines (175 loc) · 7.13 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
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import js from '@eslint/js';
import globals from 'globals';
import { FlatCompat } from '@eslint/eslintrc';
import tsParser from '@typescript-eslint/parser';
import pluginTypescriptEslint from '@typescript-eslint/eslint-plugin';
import pluginImport from 'eslint-plugin-import';
import pluginUnusedImports from 'eslint-plugin-unused-imports';
import pluginHeader from 'eslint-plugin-header';
import pluginStylistic from '@stylistic/eslint-plugin';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
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
});
// Workaround, see https://github.com/Stuk/eslint-plugin-header/issues/57#issuecomment-2378485611
pluginHeader.rules.header.meta.schema = false;
export default [{
ignores: [
'**/node_modules/**/*',
'**/bin/**/*',
'**/bundle/**/*',
'**/dist/**/*',
'**/lib/**/*',
'**/out/**/*',
'**/resources/**/*',
'**/production/**/*',
'**/scripts/**/*',
'**/*env.d.ts'
],
}, ...compat.extends('eslint:recommended', 'plugin:@typescript-eslint/recommended'), {
files: [
'**/src/**/*.ts',
'**/src/**/*.tsx',
'**/test/**/*.ts',
'**/test/**/*.tsx'
],
plugins: {
'@typescript-eslint': pluginTypescriptEslint,
import: pluginImport,
'unused-imports': pluginUnusedImports,
pluginHeader,
'@stylistic': pluginStylistic
},
languageOptions: {
globals: {
...globals.node,
...globals.browser
},
parser: tsParser,
ecmaVersion: 2022,
sourceType: 'module',
parserOptions: {
project: ['./tsconfig.json']
}
},
// List of [ESLint rules](https://eslint.org/docs/rules/)
rules: {
// do not force arrow function parentheses
'arrow-parens': ['off', 'as-needed'],
// checks the correct use of super() in sub-classes
'constructor-super': 'error',
// obj.a instead of obj['a'] when possible
'dot-notation': 'error',
// ban '==', don't use 'smart' option!
eqeqeq: 'error',
// needs obj.hasOwnProperty(key) checks
'guard-for-in': 'error',
// new Error() instead of new Error
'new-parens': 'error',
// bitwise operators &, | can be confused with &&, ||
'no-bitwise': 'error',
// ECMAScript deprecated arguments.caller and arguments.callee
'no-caller': 'error',
// assignments if (a = '1') are error-prone
'no-cond-assign': 'error',
// disallow debugger; statements
'no-debugger': 'error',
// eval is considered unsafe
'no-eval': 'error',
// we need to have 'namespace' functions when using TS 'export ='
'no-inner-declarations': 'off',
// GOTO is only used in BASIC ;)
'no-labels': 'error',
// two or more empty lines need to be fused to one
'no-multiple-empty-lines': ['error', {
max: 1
}],
// there is no reason to wrap primitve values
'no-new-wrappers': 'error',
// only throw Error but no objects {}
'no-throw-literal': 'error',
// trim end of lines
'no-trailing-spaces': 'error',
// safe try/catch/finally behavior
'no-unsafe-finally': 'error',
// use const and let instead of var
'no-var': 'error',
// space in function decl: f() vs async () => {}
'space-before-function-paren': ['error', {
anonymous: 'never',
asyncArrow: 'always',
named: 'never'
}],
// Always use semicolons at end of statement
semi: [2, 'always'],
// Prefer single quotes
quotes: [2, 'single', {
avoidEscape: true
}],
// isNaN(i) Number.isNaN(i) instead of i === NaN
'use-isnan': 'error',
// Use MIT file header
'pluginHeader/header': [2, 'line', [
{ 'pattern': '\\*+' },
{ 'pattern': 'Copyright' },
{ 'pattern': '' },
{ 'pattern': 'MIT License' },
{ 'pattern': '\\*+' }
]],
// use @typescript-eslint/no-unused-vars instead
'no-unused-vars': 'off',
// List of [@typescript-eslint rules](https://typescript-eslint.io/rules/)
// Require that function overload signatures be consecutive
'@typescript-eslint/adjacent-overload-signatures': 'error',
// Require consistently using either T[] or Array<T> for arrays
'@typescript-eslint/array-type': ['error', {
default: 'array-simple'
}],
// Disallow accidentally using the "empty object" type
'@typescript-eslint/no-empty-object-type': 'error',
// Disallow explicit type declarations for variables or parameters initialized to a number, string, or boolean
'@typescript-eslint/no-inferrable-types': 'off',
// Disallow using the unsafe built-in Function type
'@typescript-eslint/no-unsafe-function-type': 'error',
// Disallow using confusing built-in primitive class wrappers
'@typescript-eslint/no-wrapper-object-types': 'error',
// Disallow the `any` type
'@typescript-eslint/no-explicit-any': 'off',
// Enforce valid definition of `new` and `constructor`
'@typescript-eslint/no-misused-new': 'error',
// Disallow TypeScript namespaces
'@typescript-eslint/no-namespace': 'off',
// Disallow non-null assertions using the ! postfix operator
'@typescript-eslint/no-non-null-assertion': 'off',
// Require or disallow parameter properties in class constructors
'@typescript-eslint/parameter-properties': 'off',
// Disallow unused variables
'@typescript-eslint/no-unused-vars': ['error', {
caughtErrorsIgnorePattern: '^_',
argsIgnorePattern: '^_',
varsIgnorePattern: '^_'
}],
// isallow require statements except in import statements
'@typescript-eslint/no-var-requires': 'error',
// Enforce the use of `for-of` loop over the standard `for` loop where possible
'@typescript-eslint/prefer-for-of': 'error',
// Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules
'@typescript-eslint/prefer-namespace-keyword': 'error',
// Disallow certain triple slash directives in favor of ES6-style import declarations
'@typescript-eslint/triple-slash-reference': 'error',
// Disallow conditionals where the type is always truthy or always falsy
'@typescript-eslint/no-unnecessary-condition': 'off',
// Disallow unused expressions
'@typescript-eslint/no-unused-expressions': 'off',
// List of [@stylistic rules](https://eslint.style/rules)
// Enforce consistent indentation
'@stylistic/indent': 'error',
// Require consistent spacing around type annotations
'@stylistic/type-annotation-spacing': 'error'
}
}];