-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
174 lines (174 loc) · 6.75 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
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
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable @cspell/spellchecker, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
import eslintCspell from '@cspell/eslint-plugin/recommended';
import eslint from '@eslint/js';
import eslintPluginEslintComments from '@eslint-community/eslint-plugin-eslint-comments/configs';
import eslintConfigLove from 'eslint-config-love';
import eslintPluginJsdoc from 'eslint-plugin-jsdoc';
import eslintPluginNoSecrets from 'eslint-plugin-no-secrets';
import eslintPluginNoUnsanitized from 'eslint-plugin-no-unsanitized';
import * as eslintPluginRegexp from 'eslint-plugin-regexp';
import eslintPluginSecurity from 'eslint-plugin-security';
import eslintPluginSonarJs from 'eslint-plugin-sonarjs';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
// import * as eslintPluginWoke from 'eslint-plugin-woke'
import * as eslintPluginWriteGoodComments from 'eslint-plugin-write-good-comments';
import tseslint from 'typescript-eslint';
import cspellFlagWords from './wordLists/cspell.flagWords.js';
import cspellWords from './wordLists/cspell.words.js';
import writeGoodCommentsWhitelist from './wordLists/writeGoodComments.whitelist.js';
export const config = tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommendedTypeChecked, ...tseslint.configs.stylisticTypeChecked, eslintCspell, eslintPluginEslintComments.recommended, eslintPluginJsdoc.configs['flat/recommended-typescript'], eslintPluginRegexp.configs['flat/recommended'], eslintPluginSecurity.configs.recommended, eslintPluginSonarJs.configs.recommended, eslintPluginUnicorn.configs['flat/recommended'], eslintConfigLove, {
files: ['**/*.ts'],
ignores: ['**/*.d.ts'],
languageOptions: {
parserOptions: {
ecmaFeatures: { modules: true },
ecmaVersion: 2022,
project: ['./tsconfig.json'],
sourceType: 'module'
}
},
plugins: {
'no-secrets': eslintPluginNoSecrets,
// woke: eslintPluginWoke,
'write-good-comments': eslintPluginWriteGoodComments
},
rules: {
'@cspell/spellchecker': [
'warn',
{
cspell: {
language: 'en-CA,en-US,en-GB',
flagWords: cspellFlagWords,
words: cspellWords
}
}
],
'@typescript-eslint/init-declarations': 'warn',
'@typescript-eslint/no-extra-semi': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-magic-numbers': [
'warn',
{
ignore: [-1, 0, 1]
}
],
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/prefer-destructuring': 'off',
'@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/strict-boolean-expressions': 'warn',
'eslint-comments/require-description': 'off',
'import/order': [
'error',
{
'newlines-between': 'always',
alphabetize: {
order: 'asc',
orderImportKind: 'asc'
}
}
],
'jsdoc/require-jsdoc': ['warn', { publicOnly: true }],
'n/no-missing-import': 'off',
'no-extra-semi': 'off',
'no-secrets/no-secrets': 'error',
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
'sonarjs/cognitive-complexity': ['warn', 20],
'sonarjs/no-duplicate-string': 'warn',
// checked by "@typescript-eslint/no-redundant-type-constituents"
'sonarjs/no-redundant-type-constituents': 'off',
// checked by "no-useless-escape"
'regexp/no-useless-escape': 'off',
'sonarjs/unnecessary-character-escapes': 'off',
// checked by "regexp/no-dupe-characters-character-class"
'sonarjs/duplicates-in-character-class': 'off',
// checked by "@typescript-eslint/no-misused-promises"
'sonarjs/no-misused-promises': 'off',
'sort-imports': [
'error',
{
ignoreDeclarationSort: true
}
],
'unicorn/consistent-function-scoping': 'warn',
'unicorn/empty-brace-spaces': 'off',
'unicorn/filename-case': [
'error',
{
case: 'camelCase',
ignore: ['DB', 'URL']
}
],
'unicorn/prevent-abbreviations': [
'error',
{
replacements: {
def: {
definition: true
},
ele: {
element: true
},
eles: {
elements: true
},
fns: {
functions: true
},
res: {
result: false
},
temp: {
temporary: false
}
}
}
],
// 'woke/all': 'error',
'write-good-comments/write-good-comments': [
'warn',
{
passive: false,
whitelist: writeGoodCommentsWhitelist
}
]
}
});
export const configWebApp = tseslint.config(...config, {
files: ['**/*.ts'],
ignores: ['**/*.d.ts'],
plugins: {
'no-unsanitized': eslintPluginNoUnsanitized
},
rules: {
'jsdoc/require-jsdoc': 'off',
'no-unsanitized/method': [
'error',
{
escape: {
methods: ['cityssm.escapeHTML']
}
}
],
'no-unsanitized/property': [
'error',
{
escape: {
methods: ['cityssm.escapeHTML']
}
}
]
}
});
export { default as tseslint } from 'typescript-eslint';
export { default as cspellFlagWords } from './wordLists/cspell.flagWords.js';
export { default as cspellWords } from './wordLists/cspell.words.js';
export { default as writeGoodCommentsWhitelist } from './wordLists/writeGoodComments.whitelist.js';
export default config;