@fenge/eslint-config 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/javascript.d.ts.map +1 -1
- package/dist/config/js/base.d.ts.map +1 -1
- package/dist/config/ts/base.d.ts.map +1 -1
- package/dist/config/typescript.d.ts.map +1 -1
- package/dist/eslint.config.d.ts +1 -1
- package/dist/eslint.config.d.ts.map +1 -1
- package/dist/eslint.config.js +1 -1
- package/package.json +7 -4
- package/CHANGELOG.md +0 -301
- package/src/config/base.ts +0 -56
- package/src/config/javascript.test.ts +0 -63
- package/src/config/javascript.ts +0 -8
- package/src/config/js/base.ts +0 -554
- package/src/config/js/cli.ts +0 -14
- package/src/config/js/config.ts +0 -11
- package/src/config/js/test.ts +0 -15
- package/src/config/packagejson.ts +0 -35
- package/src/config/ts/base.ts +0 -238
- package/src/config/ts/cli.ts +0 -13
- package/src/config/ts/config.ts +0 -13
- package/src/config/ts/declaration.ts +0 -13
- package/src/config/ts/test.ts +0 -18
- package/src/config/typescript.test.ts +0 -98
- package/src/config/typescript.ts +0 -15
- package/src/eslint.config.test.ts +0 -108
- package/src/eslint.config.ts +0 -99
- package/src/typing.d.ts +0 -8
- package/test/fixtures.test.ts +0 -101
- package/test/prettier.test.ts +0 -42
- package/tsconfig.json +0 -5
package/src/config/js/base.ts
DELETED
|
@@ -1,554 +0,0 @@
|
|
|
1
|
-
import * as fengePlugin from "@fenge/eslint-plugin";
|
|
2
|
-
import tsPlugin from "@typescript-eslint/eslint-plugin";
|
|
3
|
-
import confusingKeys from "confusing-browser-globals";
|
|
4
|
-
import checkFilePlugin from "eslint-plugin-check-file";
|
|
5
|
-
import esxPlugin from "eslint-plugin-es-x";
|
|
6
|
-
import * as esmPlugin from "eslint-plugin-esm";
|
|
7
|
-
import fpPlugin from "eslint-plugin-fp";
|
|
8
|
-
import importPlugin from "eslint-plugin-import";
|
|
9
|
-
import nPlugin from "eslint-plugin-n";
|
|
10
|
-
import promisePlugin from "eslint-plugin-promise";
|
|
11
|
-
import reactPlugin from "eslint-plugin-react";
|
|
12
|
-
import reactHooksPlugin from "eslint-plugin-react-hooks";
|
|
13
|
-
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
14
|
-
import sonarjsPlugin from "eslint-plugin-sonarjs";
|
|
15
|
-
import unicornPlugin from "eslint-plugin-unicorn";
|
|
16
|
-
import globals from "globals";
|
|
17
|
-
|
|
18
|
-
export function getJsBase() {
|
|
19
|
-
// copied from https://github.com/standard/eslint-config-standard/blob/master/src/index.ts
|
|
20
|
-
// prettier-ignore
|
|
21
|
-
const standardConfigRules = {
|
|
22
|
-
'no-var': 'error',
|
|
23
|
-
'object-shorthand': ['error', 'properties'],
|
|
24
|
-
|
|
25
|
-
'accessor-pairs': ['error', { setWithoutGet: true, enforceForClassMembers: true }],
|
|
26
|
-
// 'array-bracket-spacing': ['error', 'never'],
|
|
27
|
-
'array-callback-return': ['error', {
|
|
28
|
-
allowImplicit: false,
|
|
29
|
-
checkForEach: false
|
|
30
|
-
}],
|
|
31
|
-
// 'arrow-spacing': ['error', { before: true, after: true }],
|
|
32
|
-
// 'block-spacing': ['error', 'always'],
|
|
33
|
-
// 'brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
|
34
|
-
camelcase: ['error', {
|
|
35
|
-
allow: ['^UNSAFE_'],
|
|
36
|
-
properties: 'never',
|
|
37
|
-
ignoreGlobals: true
|
|
38
|
-
}],
|
|
39
|
-
// 'comma-dangle': ['error', {
|
|
40
|
-
// arrays: 'never',
|
|
41
|
-
// objects: 'never',
|
|
42
|
-
// imports: 'never',
|
|
43
|
-
// exports: 'never',
|
|
44
|
-
// functions: 'never'
|
|
45
|
-
// }],
|
|
46
|
-
// 'comma-spacing': ['error', { before: false, after: true }],
|
|
47
|
-
// 'comma-style': ['error', 'last'],
|
|
48
|
-
// 'computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
|
|
49
|
-
'constructor-super': 'error',
|
|
50
|
-
// curly: ['error', 'multi-line'],
|
|
51
|
-
'default-case-last': 'error',
|
|
52
|
-
// 'dot-location': ['error', 'property'],
|
|
53
|
-
// 'dot-notation': ['error', { allowKeywords: true }], // TODO: This should be enabled. Disable it as it conflicts with ts when enabling ts-check
|
|
54
|
-
// 'eol-last': 'error',
|
|
55
|
-
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
|
56
|
-
// 'func-call-spacing': ['error', 'never'],
|
|
57
|
-
// 'generator-star-spacing': ['error', { before: true, after: true }],
|
|
58
|
-
// indent: ['error', 2, {
|
|
59
|
-
// SwitchCase: 1,
|
|
60
|
-
// VariableDeclarator: 1,
|
|
61
|
-
// outerIIFEBody: 1,
|
|
62
|
-
// MemberExpression: 1,
|
|
63
|
-
// FunctionDeclaration: { parameters: 1, body: 1 },
|
|
64
|
-
// FunctionExpression: { parameters: 1, body: 1 },
|
|
65
|
-
// CallExpression: { arguments: 1 },
|
|
66
|
-
// ArrayExpression: 1,
|
|
67
|
-
// ObjectExpression: 1,
|
|
68
|
-
// ImportDeclaration: 1,
|
|
69
|
-
// flatTernaryExpressions: false,
|
|
70
|
-
// ignoreComments: false,
|
|
71
|
-
// ignoredNodes: [
|
|
72
|
-
// 'TemplateLiteral *',
|
|
73
|
-
// 'JSXElement',
|
|
74
|
-
// 'JSXElement > *',
|
|
75
|
-
// 'JSXAttribute',
|
|
76
|
-
// 'JSXIdentifier',
|
|
77
|
-
// 'JSXNamespacedName',
|
|
78
|
-
// 'JSXMemberExpression',
|
|
79
|
-
// 'JSXSpreadAttribute',
|
|
80
|
-
// 'JSXExpressionContainer',
|
|
81
|
-
// 'JSXOpeningElement',
|
|
82
|
-
// 'JSXClosingElement',
|
|
83
|
-
// 'JSXFragment',
|
|
84
|
-
// 'JSXOpeningFragment',
|
|
85
|
-
// 'JSXClosingFragment',
|
|
86
|
-
// 'JSXText',
|
|
87
|
-
// 'JSXEmptyExpression',
|
|
88
|
-
// 'JSXSpreadChild'
|
|
89
|
-
// ],
|
|
90
|
-
// offsetTernaryExpressions: true
|
|
91
|
-
// }],
|
|
92
|
-
// 'key-spacing': ['error', { beforeColon: false, afterColon: true }],
|
|
93
|
-
// 'keyword-spacing': ['error', { before: true, after: true }],
|
|
94
|
-
// 'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
|
|
95
|
-
// 'multiline-ternary': ['error', 'always-multiline'],
|
|
96
|
-
'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
|
|
97
|
-
// 'new-parens': 'error',
|
|
98
|
-
'no-array-constructor': 'error',
|
|
99
|
-
'no-async-promise-executor': 'error',
|
|
100
|
-
'no-caller': 'error',
|
|
101
|
-
'no-case-declarations': 'error',
|
|
102
|
-
'no-class-assign': 'error',
|
|
103
|
-
'no-compare-neg-zero': 'error',
|
|
104
|
-
'no-cond-assign': 'error',
|
|
105
|
-
'no-const-assign': 'error',
|
|
106
|
-
'no-constant-condition': ['error', { checkLoops: false }],
|
|
107
|
-
'no-control-regex': 'error',
|
|
108
|
-
'no-debugger': 'error',
|
|
109
|
-
'no-delete-var': 'error',
|
|
110
|
-
'no-dupe-args': 'error',
|
|
111
|
-
'no-dupe-class-members': 'error',
|
|
112
|
-
'no-dupe-keys': 'error',
|
|
113
|
-
'no-duplicate-case': 'error',
|
|
114
|
-
'no-useless-backreference': 'error',
|
|
115
|
-
'no-empty': ['error', { allowEmptyCatch: true }],
|
|
116
|
-
'no-empty-character-class': 'error',
|
|
117
|
-
'no-empty-pattern': 'error',
|
|
118
|
-
'no-eval': 'error',
|
|
119
|
-
'no-ex-assign': 'error',
|
|
120
|
-
'no-extend-native': 'error',
|
|
121
|
-
'no-extra-bind': 'error',
|
|
122
|
-
'no-extra-boolean-cast': 'error',
|
|
123
|
-
// 'no-extra-parens': ['error', 'functions'],
|
|
124
|
-
'no-fallthrough': 'error',
|
|
125
|
-
// 'no-floating-decimal': 'error',
|
|
126
|
-
'no-func-assign': 'error',
|
|
127
|
-
'no-global-assign': 'error',
|
|
128
|
-
'no-implied-eval': 'error',
|
|
129
|
-
'no-import-assign': 'error',
|
|
130
|
-
'no-invalid-regexp': 'error',
|
|
131
|
-
'no-irregular-whitespace': 'error',
|
|
132
|
-
'no-iterator': 'error',
|
|
133
|
-
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
|
|
134
|
-
'no-lone-blocks': 'error',
|
|
135
|
-
'no-loss-of-precision': 'error',
|
|
136
|
-
'no-misleading-character-class': 'error',
|
|
137
|
-
'no-prototype-builtins': 'error',
|
|
138
|
-
'no-useless-catch': 'error',
|
|
139
|
-
// 'no-mixed-operators': ['error', {
|
|
140
|
-
// groups: [
|
|
141
|
-
// ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
|
|
142
|
-
// ['&&', '||'],
|
|
143
|
-
// ['in', 'instanceof']
|
|
144
|
-
// ],
|
|
145
|
-
// allowSamePrecedence: true
|
|
146
|
-
// }],
|
|
147
|
-
// 'no-mixed-spaces-and-tabs': 'error',
|
|
148
|
-
// 'no-multi-spaces': 'error',
|
|
149
|
-
'no-multi-str': 'error',
|
|
150
|
-
// 'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
|
|
151
|
-
'no-new': 'error',
|
|
152
|
-
'no-new-func': 'error',
|
|
153
|
-
// 'no-new-object': 'error',
|
|
154
|
-
// 'no-new-symbol': 'error',
|
|
155
|
-
'no-new-wrappers': 'error',
|
|
156
|
-
'no-obj-calls': 'error',
|
|
157
|
-
'no-octal': 'error',
|
|
158
|
-
'no-octal-escape': 'error',
|
|
159
|
-
'no-proto': 'error',
|
|
160
|
-
'no-redeclare': ['error', { builtinGlobals: false }],
|
|
161
|
-
'no-regex-spaces': 'error',
|
|
162
|
-
'no-return-assign': ['error', 'except-parens'],
|
|
163
|
-
'no-self-assign': ['error', { props: true }],
|
|
164
|
-
'no-self-compare': 'error',
|
|
165
|
-
'no-sequences': 'error',
|
|
166
|
-
'no-shadow-restricted-names': 'error',
|
|
167
|
-
'no-sparse-arrays': 'error',
|
|
168
|
-
// 'no-tabs': 'error',
|
|
169
|
-
// 'no-template-curly-in-string': 'error', // VSCode an WebStorm can detect it. Enabling this will decrease flexibility. For example, long content containing ${foo} is reasonable.
|
|
170
|
-
'no-this-before-super': 'error',
|
|
171
|
-
'no-throw-literal': 'error',
|
|
172
|
-
// 'no-trailing-spaces': 'error',
|
|
173
|
-
'no-undef': 'error',
|
|
174
|
-
// 'no-undef-init': 'error', // It conflict with `init-declarations`
|
|
175
|
-
// 'no-unexpected-multiline': 'error',
|
|
176
|
-
'no-unmodified-loop-condition': 'error',
|
|
177
|
-
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
|
|
178
|
-
'no-unreachable': 'error',
|
|
179
|
-
'no-unreachable-loop': 'error',
|
|
180
|
-
'no-unsafe-finally': 'error',
|
|
181
|
-
'no-unsafe-negation': 'error',
|
|
182
|
-
'no-unused-expressions': ['error', {
|
|
183
|
-
enforceForJSX: true,
|
|
184
|
-
allowShortCircuit: true,
|
|
185
|
-
allowTernary: true,
|
|
186
|
-
allowTaggedTemplates: true
|
|
187
|
-
}],
|
|
188
|
-
'no-unused-vars': ['error', {
|
|
189
|
-
args: 'none',
|
|
190
|
-
caughtErrors: 'none',
|
|
191
|
-
ignoreRestSiblings: true,
|
|
192
|
-
vars: 'all'
|
|
193
|
-
}],
|
|
194
|
-
'no-use-before-define': ['error', { functions: false, classes: false, variables: false }],
|
|
195
|
-
'no-useless-call': 'error',
|
|
196
|
-
'no-useless-computed-key': 'error',
|
|
197
|
-
'no-useless-constructor': 'error',
|
|
198
|
-
'no-useless-escape': 'error',
|
|
199
|
-
'no-useless-rename': 'error',
|
|
200
|
-
'no-useless-return': 'error',
|
|
201
|
-
'no-void': 'error',
|
|
202
|
-
// 'no-whitespace-before-property': 'error',
|
|
203
|
-
'no-with': 'error',
|
|
204
|
-
// 'object-curly-newline': ['error', { multiline: true, consistent: true }],
|
|
205
|
-
// 'object-curly-spacing': ['error', 'always'],
|
|
206
|
-
// 'object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
|
|
207
|
-
'one-var': ['error', { initialized: 'never' }],
|
|
208
|
-
// 'operator-linebreak': ['error', 'after', { overrides: { '?': 'before', ':': 'before', '|>': 'before' } }],
|
|
209
|
-
// 'padded-blocks': ['error', { blocks: 'never', switches: 'never', classes: 'never' }],
|
|
210
|
-
'prefer-const': ['error', { destructuring: 'all' }],
|
|
211
|
-
'prefer-promise-reject-errors': 'error',
|
|
212
|
-
'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
|
|
213
|
-
// 'quote-props': ['error', 'as-needed'],
|
|
214
|
-
// quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
|
|
215
|
-
// 'rest-spread-spacing': ['error', 'never'],
|
|
216
|
-
// semi: ['error', 'never'],
|
|
217
|
-
// 'semi-spacing': ['error', { before: false, after: true }],
|
|
218
|
-
// 'space-before-blocks': ['error', 'always'],
|
|
219
|
-
// 'space-before-function-paren': ['error', 'always'],
|
|
220
|
-
// 'space-in-parens': ['error', 'never'],
|
|
221
|
-
// 'space-infix-ops': 'error',
|
|
222
|
-
// 'space-unary-ops': ['error', { words: true, nonwords: false }],
|
|
223
|
-
// 'spaced-comment': ['error', 'always', {
|
|
224
|
-
// line: { markers: ['*package', '!', '/', ',', '='] },
|
|
225
|
-
// block: { balanced: true, markers: ['*package', '!', ',', ':', '::', 'flow-include'], exceptions: ['*'] }
|
|
226
|
-
// }],
|
|
227
|
-
'symbol-description': 'error',
|
|
228
|
-
// 'template-curly-spacing': ['error', 'never'],
|
|
229
|
-
// 'template-tag-spacing': ['error', 'never'],
|
|
230
|
-
'unicode-bom': ['error', 'never'],
|
|
231
|
-
'use-isnan': ['error', {
|
|
232
|
-
enforceForSwitchCase: true,
|
|
233
|
-
enforceForIndexOf: true
|
|
234
|
-
}],
|
|
235
|
-
'valid-typeof': ['error', { requireStringLiterals: true }],
|
|
236
|
-
// 'wrap-iife': ['error', 'any', { functionPrototypeMethods: true }],
|
|
237
|
-
// 'yield-star-spacing': ['error', 'both'],
|
|
238
|
-
yoda: ['error', 'never'],
|
|
239
|
-
} as const;
|
|
240
|
-
|
|
241
|
-
return {
|
|
242
|
-
name: "fenge/javascript",
|
|
243
|
-
files: ["**/*.{js,cjs,mjs,jsx}"],
|
|
244
|
-
// https://eslint.org/docs/latest/use/configure/language-options
|
|
245
|
-
languageOptions: {
|
|
246
|
-
ecmaVersion: "latest",
|
|
247
|
-
sourceType: "module",
|
|
248
|
-
parserOptions: {
|
|
249
|
-
// TODO `ecmaVersion` and `sourceType` are no standard here. import/no-default-export required this
|
|
250
|
-
ecmaVersion: "latest",
|
|
251
|
-
sourceType: "module",
|
|
252
|
-
ecmaFeatures: {
|
|
253
|
-
jsx: true,
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
globals: {
|
|
257
|
-
...Object.fromEntries(
|
|
258
|
-
Object.entries(globals.browser)
|
|
259
|
-
.filter(([k]) => !confusingKeys.includes(k))
|
|
260
|
-
.filter(([k]) => !["self", "global"].includes(k)), // prefer `globalThis`
|
|
261
|
-
),
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
plugins: {
|
|
265
|
-
"check-file": checkFilePlugin,
|
|
266
|
-
fp: fpPlugin,
|
|
267
|
-
n: nPlugin,
|
|
268
|
-
import: importPlugin,
|
|
269
|
-
promise: promisePlugin,
|
|
270
|
-
react: reactPlugin,
|
|
271
|
-
"react-hooks": reactHooksPlugin,
|
|
272
|
-
sonarjs: sonarjsPlugin,
|
|
273
|
-
unicorn: unicornPlugin,
|
|
274
|
-
"es-x": esxPlugin,
|
|
275
|
-
esm: esmPlugin,
|
|
276
|
-
"simple-import-sort": simpleImportSortPlugin,
|
|
277
|
-
"@fenge": fengePlugin,
|
|
278
|
-
"@typescript-eslint": { rules: tsPlugin.rules }, // TODO: Ugly. Submit a pr to typescript-plugin to fix it.
|
|
279
|
-
},
|
|
280
|
-
rules: {
|
|
281
|
-
// 1. standard config rules
|
|
282
|
-
...standardConfigRules,
|
|
283
|
-
|
|
284
|
-
// 2. code style for a better readability
|
|
285
|
-
"arrow-body-style": ["error", "as-needed"],
|
|
286
|
-
// Sort imports by prettier. Turn in off.
|
|
287
|
-
// "simple-import-sort/imports": [
|
|
288
|
-
// "error",
|
|
289
|
-
// { groups: [["^\\u0000", "^node:", "^@?\\w", "^", "^\\."]] },
|
|
290
|
-
// ],
|
|
291
|
-
"simple-import-sort/exports": "error",
|
|
292
|
-
"unicorn/prefer-node-protocol": "error",
|
|
293
|
-
"unicorn/escape-case": "error", // '\ud834' -> '\uD834'
|
|
294
|
-
// "unicorn/number-literal-case": "error", // 0XFF -> 0xFF // conflict with prettier
|
|
295
|
-
|
|
296
|
-
// 3. ban some syntaxes to reduce mistakes
|
|
297
|
-
"default-param-last": "error",
|
|
298
|
-
"for-direction": "error",
|
|
299
|
-
"func-name-matching": "error",
|
|
300
|
-
"func-names": "error", // always require a name for function declaration
|
|
301
|
-
"func-style": ["error", "declaration", { allowArrowFunctions: true }],
|
|
302
|
-
"getter-return": "error",
|
|
303
|
-
"init-declarations": "error",
|
|
304
|
-
"logical-assignment-operators": [
|
|
305
|
-
"error",
|
|
306
|
-
"always",
|
|
307
|
-
{ enforceForIfStatements: true },
|
|
308
|
-
],
|
|
309
|
-
"max-depth": ["error", { max: 5 }],
|
|
310
|
-
"max-params": ["error", { max: 4 }],
|
|
311
|
-
"no-bitwise": "error",
|
|
312
|
-
"no-console": "error",
|
|
313
|
-
"no-constant-binary-expression": "error",
|
|
314
|
-
"no-dupe-else-if": "error",
|
|
315
|
-
"no-duplicate-imports": "error",
|
|
316
|
-
"no-empty-static-block": "error",
|
|
317
|
-
"no-empty-function": "error",
|
|
318
|
-
"no-implicit-coercion": [
|
|
319
|
-
"error",
|
|
320
|
-
{ disallowTemplateShorthand: true, allow: ["!!"] },
|
|
321
|
-
], // forbid code like `const num = +str`;
|
|
322
|
-
"no-inner-declarations": "error", // TODO: change the rule value to `["error","functions",{blockScopedFunctions:"disallow"}]` when eslint is v9
|
|
323
|
-
"no-invalid-this": "error",
|
|
324
|
-
"no-lonely-if": "error",
|
|
325
|
-
"no-multi-assign": "error",
|
|
326
|
-
"no-new-native-nonconstructor": "error",
|
|
327
|
-
"no-nonoctal-decimal-escape": "error",
|
|
328
|
-
"no-object-constructor": "error",
|
|
329
|
-
"no-param-reassign": "error",
|
|
330
|
-
"no-plusplus": "error",
|
|
331
|
-
"no-setter-return": "error",
|
|
332
|
-
"no-shadow": ["error", { ignoreOnInitialization: true }],
|
|
333
|
-
"no-unsafe-optional-chaining": [
|
|
334
|
-
"error",
|
|
335
|
-
{ disallowArithmeticOperators: true },
|
|
336
|
-
],
|
|
337
|
-
"no-unused-labels": "error",
|
|
338
|
-
"no-unused-private-class-members": "error",
|
|
339
|
-
"require-await": "error",
|
|
340
|
-
"require-yield": "error",
|
|
341
|
-
"prefer-arrow-callback": "error",
|
|
342
|
-
"prefer-exponentiation-operator": "error",
|
|
343
|
-
"prefer-object-has-own": "error",
|
|
344
|
-
// "prefer-object-spread": "error",
|
|
345
|
-
"prefer-spread": "error",
|
|
346
|
-
"prefer-template": "error",
|
|
347
|
-
// check-file
|
|
348
|
-
"check-file/filename-blocklist": [
|
|
349
|
-
"error",
|
|
350
|
-
{
|
|
351
|
-
"**/*.mjs": "*.js",
|
|
352
|
-
"**/*.cjs": "*.js",
|
|
353
|
-
"**/*.mts": "*.ts",
|
|
354
|
-
"**/*.cts": "*.ts",
|
|
355
|
-
|
|
356
|
-
"**/*.spec.*": "*.test.*", // Node.js built-in support *.test.js. See https://nodejs.org/api/test.html#running-tests-from-the-command-line.
|
|
357
|
-
},
|
|
358
|
-
],
|
|
359
|
-
// es
|
|
360
|
-
"es-x/no-accessor-properties": "error",
|
|
361
|
-
"es-x/no-async-iteration": "error",
|
|
362
|
-
"es-x/no-generators": "error",
|
|
363
|
-
"es-x/no-hashbang": "error",
|
|
364
|
-
"es-x/no-legacy-object-prototype-accessor-methods": "error",
|
|
365
|
-
"es-x/no-top-level-await": "error",
|
|
366
|
-
// esm
|
|
367
|
-
"esm/existing-file-imports": "error",
|
|
368
|
-
"esm/no-declaration-file-imports": "error",
|
|
369
|
-
"esm/no-directory-imports": "error",
|
|
370
|
-
"esm/no-dynamic-imports": "error",
|
|
371
|
-
"esm/no-empty-exports": "error",
|
|
372
|
-
"esm/no-git-ignored-imports": "error",
|
|
373
|
-
"esm/no-phantom-dep-imports": "error",
|
|
374
|
-
"esm/no-relative-parent-imports": "error",
|
|
375
|
-
"esm/no-rename-exports": "error",
|
|
376
|
-
"esm/no-rename-imports": "error",
|
|
377
|
-
"esm/no-side-effect-imports": "error",
|
|
378
|
-
"esm/no-useless-path-segments": "error",
|
|
379
|
-
"esm/required-exports": "error",
|
|
380
|
-
"esm/top-side-effect-imports": "error",
|
|
381
|
-
// fp
|
|
382
|
-
"fp/no-arguments": "error",
|
|
383
|
-
"fp/no-delete": "error",
|
|
384
|
-
// import
|
|
385
|
-
"import/export": "error",
|
|
386
|
-
"import/first": "error",
|
|
387
|
-
// "import/newline-after-import": "error", // already handled by prettier's plugin `@ianvs/prettier-plugin-sort-imports`
|
|
388
|
-
"import/no-absolute-path": "error",
|
|
389
|
-
"import/no-commonjs": [
|
|
390
|
-
"error",
|
|
391
|
-
{
|
|
392
|
-
allowRequire: false,
|
|
393
|
-
allowConditionalRequire: false,
|
|
394
|
-
allowPrimitiveModules: false,
|
|
395
|
-
},
|
|
396
|
-
],
|
|
397
|
-
/**
|
|
398
|
-
* 1. The ESM specification didn’t say anything about interoperability with CommonJS. See: https://blog.andrewbran.ch/default-exports-in-commonjs-libraries/
|
|
399
|
-
* 2. Reexporting like `export * from 'foo'` will be difficult.
|
|
400
|
-
*/
|
|
401
|
-
"import/no-default-export": "error",
|
|
402
|
-
"import/no-duplicates": "error",
|
|
403
|
-
"import/no-dynamic-require": "error",
|
|
404
|
-
"import/no-empty-named-blocks": "error", // The feature of this rule is already handled by Prettier. But we still put it here.
|
|
405
|
-
"import/no-mutable-exports": "error", // forbid code like `export let count = 3`
|
|
406
|
-
"import/no-named-default": "error",
|
|
407
|
-
"import/no-relative-packages": "error", // forbid to import module from other monorepo packages by relative paths
|
|
408
|
-
"import/no-self-import": "error",
|
|
409
|
-
"import/no-webpack-loader-syntax": "error",
|
|
410
|
-
// n
|
|
411
|
-
"n/handle-callback-err": ["error", "^(err|error)$"],
|
|
412
|
-
"n/no-callback-literal": "error",
|
|
413
|
-
"n/no-deprecated-api": "error",
|
|
414
|
-
"n/no-exports-assign": "error",
|
|
415
|
-
"n/no-new-require": "error",
|
|
416
|
-
"n/no-path-concat": "error",
|
|
417
|
-
"n/no-process-exit": "error",
|
|
418
|
-
"n/no-unpublished-bin": "error",
|
|
419
|
-
"n/prefer-global/buffer": ["error", "never"],
|
|
420
|
-
"n/prefer-global/console": "error",
|
|
421
|
-
"n/prefer-global/process": ["error", "never"],
|
|
422
|
-
"n/prefer-global/text-decoder": "error",
|
|
423
|
-
"n/prefer-global/text-encoder": "error",
|
|
424
|
-
"n/prefer-global/url": "error",
|
|
425
|
-
"n/prefer-global/url-search-params": "error",
|
|
426
|
-
"n/process-exit-as-throw": "error",
|
|
427
|
-
// promise
|
|
428
|
-
"promise/no-return-wrap": "error",
|
|
429
|
-
"promise/param-names": "error",
|
|
430
|
-
"promise/prefer-catch": "error",
|
|
431
|
-
// react
|
|
432
|
-
// "react/hook-use-state": "error", // This rule will cause some warnings because we don't specify the version of react.
|
|
433
|
-
"react/jsx-filename-extension": [
|
|
434
|
-
"error",
|
|
435
|
-
{ allow: "as-needed", extensions: [".jsx", ".tsx"] },
|
|
436
|
-
],
|
|
437
|
-
"react/jsx-key": "error",
|
|
438
|
-
"react/jsx-no-duplicate-props": "error",
|
|
439
|
-
"react/jsx-no-undef": "error",
|
|
440
|
-
"react/jsx-no-useless-fragment": "error",
|
|
441
|
-
"react/jsx-props-no-spread-multi": "error",
|
|
442
|
-
"react/jsx-uses-vars": "error",
|
|
443
|
-
// react-hooks
|
|
444
|
-
"react-hooks/exhaustive-deps": "error",
|
|
445
|
-
"react-hooks/rules-of-hooks": "error",
|
|
446
|
-
// sonarjs
|
|
447
|
-
"sonarjs/no-collapsible-if": "error",
|
|
448
|
-
"sonarjs/no-all-duplicated-branches": "error",
|
|
449
|
-
"sonarjs/no-identical-conditions": "error",
|
|
450
|
-
"sonarjs/no-identical-expressions": "error",
|
|
451
|
-
"sonarjs/no-ignored-return": "error",
|
|
452
|
-
"sonarjs/no-inverted-boolean-check": "error",
|
|
453
|
-
"sonarjs/no-nested-switch": "error",
|
|
454
|
-
"sonarjs/no-useless-catch": "error",
|
|
455
|
-
"sonarjs/prefer-immediate-return": "error",
|
|
456
|
-
// unicorn
|
|
457
|
-
// 'unicorn/no-null': 'error', // null can be useful when interact with json.
|
|
458
|
-
"unicorn/consistent-assert": "error",
|
|
459
|
-
"unicorn/consistent-date-clone": "error",
|
|
460
|
-
"unicorn/consistent-destructuring": "error",
|
|
461
|
-
"unicorn/consistent-empty-array-spread": "error",
|
|
462
|
-
"unicorn/error-message": "error",
|
|
463
|
-
"unicorn/explicit-length-check": "error",
|
|
464
|
-
"unicorn/filename-case": [
|
|
465
|
-
"error",
|
|
466
|
-
{ cases: { kebabCase: true, pascalCase: true } },
|
|
467
|
-
],
|
|
468
|
-
"unicorn/import-style": [
|
|
469
|
-
"error",
|
|
470
|
-
{
|
|
471
|
-
styles: {
|
|
472
|
-
react: { named: true },
|
|
473
|
-
|
|
474
|
-
child_process: { default: true },
|
|
475
|
-
fs: { default: true },
|
|
476
|
-
"fs/promises": { default: true },
|
|
477
|
-
process: { default: true },
|
|
478
|
-
"util/types": { named: true },
|
|
479
|
-
"node:child_process": { default: true },
|
|
480
|
-
"node:fs": { default: true },
|
|
481
|
-
"node:fs/promises": { default: true },
|
|
482
|
-
"node:process": { default: true },
|
|
483
|
-
"node:util/types": { named: true },
|
|
484
|
-
},
|
|
485
|
-
},
|
|
486
|
-
],
|
|
487
|
-
"unicorn/new-for-builtins": "error",
|
|
488
|
-
"unicorn/no-abusive-eslint-disable": "error",
|
|
489
|
-
"unicorn/no-accessor-recursion": "error",
|
|
490
|
-
"unicorn/no-array-callback-reference": "error",
|
|
491
|
-
"unicorn/no-array-method-this-argument": "error",
|
|
492
|
-
"unicorn/no-await-in-promise-methods": "error",
|
|
493
|
-
"unicorn/no-for-loop": "error",
|
|
494
|
-
"unicorn/no-instanceof-builtins": "error",
|
|
495
|
-
"unicorn/no-lonely-if": "error",
|
|
496
|
-
"unicorn/no-named-default": "error",
|
|
497
|
-
"unicorn/no-negation-in-equality-check": "error",
|
|
498
|
-
"unicorn/no-new-array": "error",
|
|
499
|
-
"unicorn/no-new-buffer": "error",
|
|
500
|
-
"unicorn/no-process-exit": "error", // Prefer `n/no-process-exit`, but at the same time using this rule seems have no problem
|
|
501
|
-
"unicorn/no-single-promise-in-promise-methods": "error",
|
|
502
|
-
"unicorn/no-static-only-class": "error",
|
|
503
|
-
"unicorn/no-thenable": "error",
|
|
504
|
-
"unicorn/no-this-assignment": "error",
|
|
505
|
-
"unicorn/no-typeof-undefined": "error",
|
|
506
|
-
"unicorn/no-unreadable-array-destructuring": "error",
|
|
507
|
-
"unicorn/no-unreadable-iife": "error",
|
|
508
|
-
"unicorn/no-useless-fallback-in-spread": "error",
|
|
509
|
-
"unicorn/no-useless-spread": "error",
|
|
510
|
-
"unicorn/no-useless-switch-case": "error",
|
|
511
|
-
"unicorn/no-zero-fractions": "error",
|
|
512
|
-
"unicorn/prefer-array-flat-map": "error",
|
|
513
|
-
"unicorn/prefer-date-now": "error",
|
|
514
|
-
"unicorn/prefer-export-from": "error",
|
|
515
|
-
"unicorn/prefer-global-this": "error",
|
|
516
|
-
"unicorn/prefer-includes": "error",
|
|
517
|
-
"unicorn/prefer-logical-operator-over-ternary": "error",
|
|
518
|
-
"unicorn/prefer-math-min-max": "error",
|
|
519
|
-
"unicorn/prefer-module": "error",
|
|
520
|
-
"unicorn/prefer-negative-index": "error",
|
|
521
|
-
"unicorn/prefer-number-properties": "error",
|
|
522
|
-
"unicorn/prefer-object-from-entries": "error",
|
|
523
|
-
"unicorn/prefer-optional-catch-binding": "error",
|
|
524
|
-
"unicorn/prefer-regexp-test": "error",
|
|
525
|
-
"unicorn/prefer-string-replace-all": "error",
|
|
526
|
-
"unicorn/prefer-string-slice": "error",
|
|
527
|
-
"unicorn/prefer-ternary": "error",
|
|
528
|
-
"unicorn/require-array-join-separator": "error",
|
|
529
|
-
"unicorn/require-number-to-fixed-digits-argument": "error",
|
|
530
|
-
"unicorn/text-encoding-identifier-case": "error",
|
|
531
|
-
"unicorn/throw-new-error": "error",
|
|
532
|
-
|
|
533
|
-
"@fenge/call-arguments-length": "error",
|
|
534
|
-
"@fenge/no-instanceof-builtin": "error",
|
|
535
|
-
"@fenge/no-nested-class": "error",
|
|
536
|
-
"@fenge/no-nested-function": "error",
|
|
537
|
-
"@fenge/no-restricted-loops": "error",
|
|
538
|
-
"@fenge/no-top-level-arrow-function": "error",
|
|
539
|
-
"@fenge/no-unnecessary-template-string": "error",
|
|
540
|
-
|
|
541
|
-
"@typescript-eslint/ban-ts-comment": [
|
|
542
|
-
"error",
|
|
543
|
-
{
|
|
544
|
-
"ts-expect-error": true,
|
|
545
|
-
"ts-ignore": true,
|
|
546
|
-
"ts-nocheck": true,
|
|
547
|
-
},
|
|
548
|
-
],
|
|
549
|
-
"@typescript-eslint/no-this-alias": "error",
|
|
550
|
-
"@typescript-eslint/no-useless-empty-export": "error",
|
|
551
|
-
"@typescript-eslint/prefer-for-of": "error",
|
|
552
|
-
},
|
|
553
|
-
} as const;
|
|
554
|
-
}
|
package/src/config/js/cli.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function getJsCli() {
|
|
2
|
-
return {
|
|
3
|
-
name: "fenge/javascript/cli",
|
|
4
|
-
files: ["**/*.cli.{js,cjs,mjs,jsx}"],
|
|
5
|
-
rules: {
|
|
6
|
-
"es-x/no-hashbang": "off",
|
|
7
|
-
"es-x/no-top-level-await": "off",
|
|
8
|
-
"esm/required-exports": "off",
|
|
9
|
-
"n/no-process-exit": "off",
|
|
10
|
-
// "unicorn/no-process-exit": "off", // This rule can detect a file if is a cli file, so there is no need to disable it here.
|
|
11
|
-
"no-console": "off",
|
|
12
|
-
},
|
|
13
|
-
} as const;
|
|
14
|
-
}
|
package/src/config/js/config.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function getJsConfig() {
|
|
2
|
-
return {
|
|
3
|
-
name: "fenge/javascript/config",
|
|
4
|
-
files: ["**/*.config.{js,cjs,mjs,jsx}"],
|
|
5
|
-
rules: {
|
|
6
|
-
"es-x/no-top-level-await": "off",
|
|
7
|
-
"esm/no-phantom-dep-imports": ["error", { allowDevDependencies: true }],
|
|
8
|
-
"import/no-default-export": "off",
|
|
9
|
-
},
|
|
10
|
-
} as const;
|
|
11
|
-
}
|
package/src/config/js/test.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function getJsTest() {
|
|
2
|
-
return {
|
|
3
|
-
// https://github.com/motemen/minimatch-cheat-sheet
|
|
4
|
-
name: "fenge/javascript/test",
|
|
5
|
-
files: [
|
|
6
|
-
"**/__tests__/**/*.{js,cjs,mjs,jsx}",
|
|
7
|
-
"**/*.{test,spec}.{js,cjs,mjs,jsx}",
|
|
8
|
-
],
|
|
9
|
-
rules: {
|
|
10
|
-
"es-x/no-top-level-await": "off",
|
|
11
|
-
"esm/no-phantom-dep-imports": ["error", { allowDevDependencies: true }],
|
|
12
|
-
"esm/required-exports": "off",
|
|
13
|
-
},
|
|
14
|
-
} as const;
|
|
15
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as pkg from "eslint-plugin-pkg-json";
|
|
2
|
-
import * as publint from "eslint-plugin-publint";
|
|
3
|
-
|
|
4
|
-
export function packagejson() {
|
|
5
|
-
return [
|
|
6
|
-
{
|
|
7
|
-
name: "fenge/packagejson",
|
|
8
|
-
files: ["**/package.json"],
|
|
9
|
-
processor: "pkg-json/processor",
|
|
10
|
-
plugins: {
|
|
11
|
-
"pkg-json": pkg,
|
|
12
|
-
publint,
|
|
13
|
-
},
|
|
14
|
-
rules: {
|
|
15
|
-
"pkg-json/bottom-default": "error",
|
|
16
|
-
"pkg-json/exact-dependency-version": "error",
|
|
17
|
-
"pkg-json/no-conflict-types": "error",
|
|
18
|
-
"pkg-json/no-dependencies-in-workspace-root": "error",
|
|
19
|
-
"pkg-json/no-lifecycle-script": "error",
|
|
20
|
-
"pkg-json/no-nonstandard-property": "error",
|
|
21
|
-
"pkg-json/no-types-dependency-in-workspace-root": "error",
|
|
22
|
-
"pkg-json/top-types": "error",
|
|
23
|
-
"pkg-json/private-workspace-root": "error",
|
|
24
|
-
"pkg-json/required-dev-engines": "error",
|
|
25
|
-
"pkg-json/required-engines": "error",
|
|
26
|
-
"pkg-json/required-hashbang": "error",
|
|
27
|
-
"pkg-json/required-repository": "error",
|
|
28
|
-
"pkg-json/type-module": "error",
|
|
29
|
-
// "publint/suggestion": "error",
|
|
30
|
-
"publint/warning": "error",
|
|
31
|
-
"publint/error": "error",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
] as const;
|
|
35
|
-
}
|