-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
138 lines (129 loc) · 3.81 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import {
baseConfig,
configFilesConfig,
tsoaConfig,
typescriptConfig,
typescriptDefinitionsConfig,
} from '@arabasta/eslint-config';
import globals from 'globals';
// import/no-unresolved doesn't support node "exports" field. https://github.com/import-js/eslint-plugin-import/issues/1810
// eslint-disable-next-line import/no-unresolved
import tseslint from 'typescript-eslint';
const typeScriptExtensions = ['ts', 'cts', 'mts', 'tsx'];
const typeScriptDefinitionExtensions = typeScriptExtensions
.filter((x) => x !== 'tsx')
.map((x) => `d.${x}`);
const allExtensions = [
'js',
'cjs',
'mjs',
'jsx',
'json',
...typeScriptExtensions,
];
export default tseslint.config(
// We use a tseslint helper function here so that we get easy "extends"
// functionality that eslint flat config makes hard to achieve.
// You can use this for the convenience, without using TypeScript.
// Ideally this helper function should be provided by eslint.
// For more information: https://typescript-eslint.io/packages/typescript-eslint/#flat-config-extends
...tseslint.config({
name: 'All files',
files: [`**/*.+(${allExtensions.join('|')})`],
extends: [...baseConfig],
settings: {
'import/extensions': allExtensions.map((ext) => `.${ext}`),
'import/resolver': {
node: {
extensions: allExtensions.map((ext) => `.${ext}`),
},
},
},
languageOptions: {
globals: {
...globals.node,
},
ecmaVersion: 'latest',
sourceType: 'module',
parser: tseslint.parser,
},
rules: {
'prefer-destructuring': 'off',
'import/no-restricted-paths': [
'error',
{
zones: [
{
target: './',
from: `./src/**/*.+(spec|test).+(${allExtensions.join('|')})`,
message: 'Importing test files in non-test files is not allowed.',
},
{
target: './',
from: `./__mocks__`,
message:
'Importing mock modules in non-test files is not allowed.',
},
{
target: './',
from: './src/testing',
message:
'Importing testing utilities in non-test files is not allowed.',
},
],
},
],
'import/extensions': [
'error',
allExtensions.reduce((acc, val) => {
acc[val] = 'ignorePackages';
return acc;
}, {}),
],
},
}),
...tseslint.config({
name: 'TypeScript files',
files: [`**/*.+(${typeScriptExtensions.join('|')})`],
extends: [...typescriptConfig],
rules: {
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
},
}),
...tseslint.config({
name: 'TypeScript definition files',
files: [`**/*.+(${typeScriptDefinitionExtensions.join('|')})`],
extends: [...typescriptDefinitionsConfig],
rules: {
// Put your rules here.
},
}),
...tseslint.config({
name: 'TSOA files',
files: ['src/routes/**'],
extends: [...tsoaConfig],
rules: {
// Put your rules here.
'@arabasta/tsoa/valid-response-decorator-type': [
'error',
{ allowedTypes: ['ProblemDetails'] },
],
'@typescript-eslint/no-empty-object-type': 'off',
},
}),
...tseslint.config({
name: 'Root level configuration files',
files: [
`*.+(${allExtensions.join('|')})`,
`__mocks__/**/*.+(${allExtensions.join('|')})`,
],
extends: [...configFilesConfig],
rules: {
// Put your rules here.
},
}),
{ ignores: ['dist', 'src/generated/', 'scripts', '**/*.json'] }
);