@so1ve/eslint-config 3.23.0 → 3.25.0
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/index.d.mts +18 -5
- package/dist/index.mjs +705 -147
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -436,6 +436,16 @@ interface RuleOptions {
|
|
|
436
436
|
* @see https://eslint.org/docs/latest/rules/curly
|
|
437
437
|
*/
|
|
438
438
|
'curly'?: Linter.RuleEntry<Curly>;
|
|
439
|
+
/**
|
|
440
|
+
* Transforms the negation of a conjunction !(A && B) into the equivalent !A || !B according to De Morgan’s law
|
|
441
|
+
* @see https://github.com/azat-io/eslint-plugin-de-morgan/blob/main/docs/no-negated-conjunction.md
|
|
442
|
+
*/
|
|
443
|
+
'de-morgan/no-negated-conjunction'?: Linter.RuleEntry<[]>;
|
|
444
|
+
/**
|
|
445
|
+
* Transforms the negation of a disjunction !(A || B) into the equivalent !A && !B according to De Morgan’s law
|
|
446
|
+
* @see https://github.com/azat-io/eslint-plugin-de-morgan/blob/main/docs/no-negated-disjunction.md
|
|
447
|
+
*/
|
|
448
|
+
'de-morgan/no-negated-disjunction'?: Linter.RuleEntry<[]>;
|
|
439
449
|
/**
|
|
440
450
|
* Require `default` cases in `switch` statements
|
|
441
451
|
* @see https://eslint.org/docs/latest/rules/default-case
|
|
@@ -16293,7 +16303,7 @@ type Yoda = [] | [("always" | "never")] | [("always" | "never"), {
|
|
|
16293
16303
|
onlyEquality?: boolean;
|
|
16294
16304
|
}];
|
|
16295
16305
|
// Names of all the configs
|
|
16296
|
-
type ConfigNames = 'so1ve/ignores' | 'so1ve/javascript/setup' | 'so1ve/javascript/rules' | 'so1ve/javascript/regexp' | 'so1ve/javascript/cli' | 'so1ve/comments/setup' | 'so1ve/comments/rules' | 'so1ve/node/setup' | 'so1ve/node/rules' | 'so1ve/only-error' | 'so1ve/promise/setup' | 'so1ve/promise/rules' | 'so1ve/sort-imports/setup' | 'so1ve/sort-imports/rules' | 'so1ve/imports/setup' | 'so1ve/imports/rules' | 'so1ve/imports/rules/dts' | 'so1ve/unicorn/setup' | 'so1ve/unicorn/rules' | 'so1ve/command/
|
|
16306
|
+
type ConfigNames = 'so1ve/ignores' | 'so1ve/javascript/setup' | 'so1ve/javascript/rules' | 'so1ve/javascript/regexp' | 'so1ve/javascript/cli' | 'so1ve/comments/setup' | 'so1ve/comments/rules' | 'so1ve/node/setup' | 'so1ve/node/rules' | 'so1ve/only-error' | 'so1ve/promise/setup' | 'so1ve/promise/rules' | 'so1ve/sort-imports/setup' | 'so1ve/sort-imports/rules' | 'so1ve/imports/setup' | 'so1ve/imports/rules' | 'so1ve/imports/rules/dts' | 'so1ve/unicorn/setup' | 'so1ve/unicorn/rules' | 'so1ve/command' | 'so1ve/de-morgan' | 'so1ve/pnpm/package-json' | 'so1ve/pnpm/pnpm-workspace-yaml' | 'so1ve/yaml/pnpm-workspace-yaml-sort' | 'so1ve/html/setup' | 'so1ve/html/rules' | 'so1ve/typescript/setup' | 'so1ve/typescript/rules' | 'so1ve/typescript/rules/type-aware' | 'so1ve/typescript/rules/dts' | 'so1ve/typescript/rules/js' | 'so1ve/test/setup' | 'so1ve/test/rules' | 'antfu/astro/setup' | 'antfu/astro/rules' | 'so1ve/vue/setup' | 'so1ve/vue/rules' | 'so1ve/solid/setup' | 'so1ve/solid/rules' | 'so1ve/formatting/setup' | 'so1ve/formatting/rules' | 'so1ve/formatting/rules/sort-package-json' | 'so1ve/formatting/rules/sort-tsconfig' | 'so1ve/formatting/rules/test' | 'so1ve/perfectionist/setup' | 'so1ve/perfectionist/rules' | 'so1ve/jsonc/setup' | 'so1ve/jsonc/rules' | 'so1ve/toml/setup' | 'so1ve/toml/rules' | 'so1ve/yaml/setup' | 'so1ve/yaml/rules' | 'so1ve/mdx/setup' | 'so1ve/mdx/rules';
|
|
16297
16307
|
//#endregion
|
|
16298
16308
|
//#region src/types.d.ts
|
|
16299
16309
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -16358,10 +16368,10 @@ interface Options extends OptionsComponentExts {
|
|
|
16358
16368
|
/**
|
|
16359
16369
|
* Extend the global ignores.
|
|
16360
16370
|
*
|
|
16361
|
-
* Passing an array to extends the ignores.
|
|
16362
|
-
*
|
|
16371
|
+
* Passing an array to extends the ignores. Passing a function to modify the
|
|
16372
|
+
* default ignores.
|
|
16363
16373
|
*
|
|
16364
|
-
* @default []
|
|
16374
|
+
* @default [ ]
|
|
16365
16375
|
*/
|
|
16366
16376
|
ignores?: string[] | ((originals: string[]) => string[]);
|
|
16367
16377
|
/**
|
|
@@ -16475,6 +16485,9 @@ declare const command: () => Promise<TypedFlatConfigItem[]>;
|
|
|
16475
16485
|
//#region src/configs/comments.d.ts
|
|
16476
16486
|
declare const comments: () => TypedFlatConfigItem[];
|
|
16477
16487
|
//#endregion
|
|
16488
|
+
//#region src/configs/de-morgan.d.ts
|
|
16489
|
+
declare const deMorgan: () => TypedFlatConfigItem[];
|
|
16490
|
+
//#endregion
|
|
16478
16491
|
//#region src/configs/formatting.d.ts
|
|
16479
16492
|
declare function formatting(options?: Options): Promise<TypedFlatConfigItem[]>;
|
|
16480
16493
|
//#endregion
|
|
@@ -16628,4 +16641,4 @@ declare function interopDefault<T>(m: MaybePromise<T>): Promise<T extends {
|
|
|
16628
16641
|
default: infer U;
|
|
16629
16642
|
} ? U : T>;
|
|
16630
16643
|
//#endregion
|
|
16631
|
-
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, MaybeArray, MaybePromise, Options, OptionsComponentExts, OptionsHasTypeScript, OptionsOverrides, OptionsPnpm, OptionsTypeScriptParserOptions, ResolvedOptions, Rules, TypedFlatConfigItem, astro, command, comments, defaultPluginRenaming, formatting, getOverrides, html, ignores, imports, interopDefault, javascript, jsonc, mdx, node, onlyError, perfectionist, pnpm, promise, renameRules, so1ve, solid, sortImports, test, toml, typescript$1 as typescript, unicorn, vue, yaml };
|
|
16644
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, MaybeArray, MaybePromise, Options, OptionsComponentExts, OptionsHasTypeScript, OptionsOverrides, OptionsPnpm, OptionsTypeScriptParserOptions, ResolvedOptions, Rules, TypedFlatConfigItem, astro, command, comments, deMorgan, defaultPluginRenaming, formatting, getOverrides, html, ignores, imports, interopDefault, javascript, jsonc, mdx, node, onlyError, perfectionist, pnpm, promise, renameRules, so1ve, solid, sortImports, test, toml, typescript$1 as typescript, unicorn, vue, yaml };
|
package/dist/index.mjs
CHANGED
|
@@ -13,10 +13,10 @@ import * as pluginRegexp from "eslint-plugin-regexp";
|
|
|
13
13
|
import pluginUnicorn from "eslint-plugin-unicorn";
|
|
14
14
|
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
15
15
|
import globals from "globals";
|
|
16
|
-
import
|
|
16
|
+
import fsPromises from "node:fs/promises";
|
|
17
17
|
import process$1 from "node:process";
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
|
-
import fs
|
|
19
|
+
import fs from "node:fs";
|
|
20
20
|
import path from "node:path";
|
|
21
21
|
import tseslint from "typescript-eslint";
|
|
22
22
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
@@ -122,7 +122,7 @@ const GLOB_EXCLUDE = [
|
|
|
122
122
|
* ];
|
|
123
123
|
* ```
|
|
124
124
|
*/
|
|
125
|
-
const renameRules = (rules, map) => Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
125
|
+
const renameRules = (rules$1, map) => Object.fromEntries(Object.entries(rules$1).map(([key, value]) => {
|
|
126
126
|
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
127
127
|
return [key, value];
|
|
128
128
|
}));
|
|
@@ -176,9 +176,459 @@ async function astro({ overrides = {} } = {}) {
|
|
|
176
176
|
//#region src/configs/command.ts
|
|
177
177
|
const command = async () => [{
|
|
178
178
|
...createCommand(),
|
|
179
|
-
name: "so1ve/command
|
|
179
|
+
name: "so1ve/command"
|
|
180
180
|
}];
|
|
181
181
|
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/package.json.js
|
|
184
|
+
const name = "eslint-plugin-de-morgan";
|
|
185
|
+
const version = "2.0.0";
|
|
186
|
+
const repository = "azat-io/eslint-plugin-de-morgan";
|
|
187
|
+
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/create-test-with-parameters.js
|
|
190
|
+
function createTestWithParameters(...parameters) {
|
|
191
|
+
return (...predicates) => predicates.every((predicate) => predicate(...parameters));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-logical-expression.js
|
|
196
|
+
function isLogicalExpression(node$1) {
|
|
197
|
+
return node$1.type === "LogicalExpression";
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/find-outermost-parenthesized-node.js
|
|
202
|
+
function findOutermostParenthesizedNode(node$1, sourceCode) {
|
|
203
|
+
let current = node$1;
|
|
204
|
+
let [start, end] = current.range;
|
|
205
|
+
if (isInParentheses(start, end, sourceCode)) return current;
|
|
206
|
+
while (current.parent && isLogicalExpression(current)) {
|
|
207
|
+
current = current.parent;
|
|
208
|
+
[start, end] = current.range;
|
|
209
|
+
if (isInParentheses(start, end, sourceCode)) return current;
|
|
210
|
+
}
|
|
211
|
+
return current;
|
|
212
|
+
}
|
|
213
|
+
function isInParentheses(start, end, sourceCode) {
|
|
214
|
+
return sourceCode[start - 1] === "(" && sourceCode[end] === ")";
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-unary-expression.js
|
|
219
|
+
function isUnaryExpression(node$1) {
|
|
220
|
+
return node$1.type === "UnaryExpression";
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/has-operator.js
|
|
225
|
+
function hasOperator(operator) {
|
|
226
|
+
return (node$1) => node$1.operator === operator;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/has-negation-operator.js
|
|
231
|
+
function hasNegationOperator(node$1) {
|
|
232
|
+
return createTestWithParameters(node$1)(isUnaryExpression, hasOperator("!"));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/has-negation-inside-parens.js
|
|
237
|
+
function hasNegationInsideParens(node$1, context) {
|
|
238
|
+
let outermostNode = findOutermostParenthesizedNode(node$1, context.sourceCode.getText(node$1));
|
|
239
|
+
if (!isUnaryExpression(outermostNode)) return false;
|
|
240
|
+
return hasNegationInside(outermostNode.argument);
|
|
241
|
+
}
|
|
242
|
+
function hasNegationInside(node$1) {
|
|
243
|
+
if (isUnaryExpression(node$1) && node$1.operator === "!" && isUnaryExpression(node$1.argument) && node$1.argument.operator === "!") return hasNegationInside(node$1.argument.argument);
|
|
244
|
+
if (hasNegationOperator(node$1)) return true;
|
|
245
|
+
if (isLogicalExpression(node$1)) return hasNegationInside(node$1.left) || hasNegationInside(node$1.right);
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-binary-expression.js
|
|
251
|
+
function isBinaryExpression(node$1) {
|
|
252
|
+
return node$1.type === "BinaryExpression";
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/has-boolean-context.js
|
|
257
|
+
function hasBooleanContext(node$1, _context) {
|
|
258
|
+
return node$1.parent ? isControlFlowBooleanContext(node$1.parent) || isBooleanOperation(node$1.parent) || isBooleanFunction(node$1.parent) : false;
|
|
259
|
+
}
|
|
260
|
+
function isControlFlowBooleanContext(parent) {
|
|
261
|
+
return booleanControlFlowNodes.has(parent.type);
|
|
262
|
+
}
|
|
263
|
+
let booleanControlFlowNodes = /* @__PURE__ */ new Set([
|
|
264
|
+
"ConditionalExpression",
|
|
265
|
+
"LogicalExpression",
|
|
266
|
+
"DoWhileStatement",
|
|
267
|
+
"UnaryExpression",
|
|
268
|
+
"WhileStatement",
|
|
269
|
+
"ForStatement",
|
|
270
|
+
"IfStatement"
|
|
271
|
+
]);
|
|
272
|
+
function isBooleanOperation(parent) {
|
|
273
|
+
return isBinaryExpression(parent) && booleanOperators.has(parent.operator);
|
|
274
|
+
}
|
|
275
|
+
let booleanOperators = /* @__PURE__ */ new Set([
|
|
276
|
+
"instanceof",
|
|
277
|
+
"===",
|
|
278
|
+
"!==",
|
|
279
|
+
"==",
|
|
280
|
+
"!=",
|
|
281
|
+
"<=",
|
|
282
|
+
">=",
|
|
283
|
+
"in",
|
|
284
|
+
"<",
|
|
285
|
+
">"
|
|
286
|
+
]);
|
|
287
|
+
function isBooleanFunction(parent) {
|
|
288
|
+
return parent.type === "CallExpression" && parent.callee.type === "Identifier" && parent.callee.name === "Boolean";
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/apply-to-property.js
|
|
293
|
+
function applyToProperty(property, predicate) {
|
|
294
|
+
return (object) => predicate(object[property]);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-conjunction.js
|
|
299
|
+
function isConjunction(node$1) {
|
|
300
|
+
return createTestWithParameters(node$1)(isLogicalExpression, hasOperator("&&"));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/sanitize-code.js
|
|
305
|
+
function sanitizeCode(code) {
|
|
306
|
+
let stringLiterals = [];
|
|
307
|
+
let normalized = code.replaceAll(/(?<quote>["'`])(?:\\.|(?!\k<quote>)[^\\])*\k<quote>/gu, (match) => {
|
|
308
|
+
let placeholder = `__STRING_LITERAL_${stringLiterals.length}__`;
|
|
309
|
+
stringLiterals.push(match);
|
|
310
|
+
return placeholder;
|
|
311
|
+
}).replaceAll(/\/\/.*$/gmu, "").replaceAll(/\/\*[\s\S]*?\*\//gu, "").replaceAll(/\s+/gu, " ").replaceAll(/\(\s+/gu, "(").replaceAll(/\s+\)/gu, ")").trim();
|
|
312
|
+
for (let [index$1, string_] of stringLiterals.entries()) normalized = normalized.replace(`__STRING_LITERAL_${index$1}__`, string_);
|
|
313
|
+
return normalized;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-pure-group.js
|
|
318
|
+
function isPureGroup(node$1, context) {
|
|
319
|
+
let outermostNode = findOutermostParenthesizedNode(node$1, context.sourceCode.getText());
|
|
320
|
+
return !hasMixedOperators(getCodeInsideParentheses(context.sourceCode.getText(outermostNode)));
|
|
321
|
+
}
|
|
322
|
+
function hasMixedOperators(code) {
|
|
323
|
+
let depth = 0;
|
|
324
|
+
let operatorFound = null;
|
|
325
|
+
for (let i = 0; i < code.length; i++) {
|
|
326
|
+
let char = code[i];
|
|
327
|
+
if (char === "(") {
|
|
328
|
+
depth++;
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (char === ")") {
|
|
332
|
+
depth--;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (depth !== 0) continue;
|
|
336
|
+
let twoChars = code.slice(i, i + 2);
|
|
337
|
+
if (twoChars === "&&" || twoChars === "||") {
|
|
338
|
+
if (operatorFound === null) operatorFound = twoChars;
|
|
339
|
+
else if (operatorFound !== twoChars) return true;
|
|
340
|
+
i++;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
function getCodeInsideParentheses(code) {
|
|
346
|
+
if (code.startsWith("!(")) return code.slice(2, -1);
|
|
347
|
+
if (code.startsWith("(")) return code.slice(1, -1);
|
|
348
|
+
return code;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-negated.js
|
|
353
|
+
function isNegated(node$1) {
|
|
354
|
+
return hasNegationOperator(node$1) && !hasNegationOperator(node$1.argument) && (!node$1.parent || !hasNegationOperator(node$1.parent));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/parenthesize.js
|
|
359
|
+
function parenthesize(text, condition = true) {
|
|
360
|
+
return condition ? `(${text})` : text;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-boolean.js
|
|
365
|
+
function isBoolean(node$1) {
|
|
366
|
+
return node$1.type === "Literal" && typeof node$1.value === "boolean";
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/toggle-negation.js
|
|
371
|
+
function toggleNegation(node$1, context) {
|
|
372
|
+
let toggleStrategies = [
|
|
373
|
+
{
|
|
374
|
+
transformer: toggleBinaryExpression,
|
|
375
|
+
predicate: isBinaryExpression
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
transformer: toggleBooleanLiteral,
|
|
379
|
+
predicate: isBoolean
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
transformer: toggleLogicalExpression,
|
|
383
|
+
predicate: isLogicalExpression
|
|
384
|
+
}
|
|
385
|
+
];
|
|
386
|
+
for (let { transformer, predicate } of toggleStrategies) if (predicate(node$1)) return transformer(node$1, context);
|
|
387
|
+
return toggleUnaryExpression(node$1, context);
|
|
388
|
+
}
|
|
389
|
+
function toggleBinaryExpression(node$1, context) {
|
|
390
|
+
let left = context.sourceCode.getText(node$1.left).trim();
|
|
391
|
+
let right = context.sourceCode.getText(node$1.right).trim();
|
|
392
|
+
if ([
|
|
393
|
+
"<<",
|
|
394
|
+
">>",
|
|
395
|
+
">>>",
|
|
396
|
+
"+",
|
|
397
|
+
"-",
|
|
398
|
+
"*",
|
|
399
|
+
"/",
|
|
400
|
+
"%",
|
|
401
|
+
"**",
|
|
402
|
+
"|",
|
|
403
|
+
"^",
|
|
404
|
+
"&",
|
|
405
|
+
"in",
|
|
406
|
+
"instanceof"
|
|
407
|
+
].includes(node$1.operator)) return `!(${left} ${node$1.operator} ${right})`;
|
|
408
|
+
return `${left} ${{
|
|
409
|
+
"===": "!==",
|
|
410
|
+
"!==": "===",
|
|
411
|
+
"==": "!=",
|
|
412
|
+
"!=": "==",
|
|
413
|
+
"<": ">=",
|
|
414
|
+
">": "<=",
|
|
415
|
+
"<=": ">",
|
|
416
|
+
">=": "<"
|
|
417
|
+
}[node$1.operator]} ${right}`;
|
|
418
|
+
}
|
|
419
|
+
function toggleLogicalExpression(node$1, context) {
|
|
420
|
+
return toggleCode(parenthesize(context.sourceCode.getText(node$1).trim()));
|
|
421
|
+
}
|
|
422
|
+
function toggleUnaryExpression(node$1, context) {
|
|
423
|
+
return toggleCode(context.sourceCode.getText(node$1).trim());
|
|
424
|
+
}
|
|
425
|
+
function toggleCode(code) {
|
|
426
|
+
return code.startsWith("!") ? code.replace(/^!/u, "") : `!${code}`;
|
|
427
|
+
}
|
|
428
|
+
function toggleBooleanLiteral(node$1) {
|
|
429
|
+
return node$1.value ? "false" : "true";
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-disjunction.js
|
|
434
|
+
function isDisjunction(node$1) {
|
|
435
|
+
return createTestWithParameters(node$1)(isLogicalExpression, hasOperator("||"));
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/transform.js
|
|
440
|
+
const MAX_DEPTH = 10;
|
|
441
|
+
const OPERATOR_MAPPING = {
|
|
442
|
+
"&&": "||",
|
|
443
|
+
"||": "&&"
|
|
444
|
+
};
|
|
445
|
+
function transform({ shouldWrapInParens, expressionType, context, node: node$1 }) {
|
|
446
|
+
let argument = node$1.argument;
|
|
447
|
+
let sourceOperator = expressionType === "conjunction" ? "&&" : "||";
|
|
448
|
+
if (argument.operator !== sourceOperator) return null;
|
|
449
|
+
let originalText = context.sourceCode.getText(argument);
|
|
450
|
+
let transformUtilityOptions = {
|
|
451
|
+
expression: argument,
|
|
452
|
+
expressionType,
|
|
453
|
+
sourceOperator,
|
|
454
|
+
targetOperator: OPERATOR_MAPPING[sourceOperator],
|
|
455
|
+
context
|
|
456
|
+
};
|
|
457
|
+
return parenthesize(hasSpecialFormatting(originalText) ? transformWithFormatting(transformUtilityOptions) : transformSimple(transformUtilityOptions), shouldWrapInParens);
|
|
458
|
+
}
|
|
459
|
+
function transformWithFormatting({ sourceOperator, targetOperator, expression, context }) {
|
|
460
|
+
let { sourceCode } = context;
|
|
461
|
+
let leftText = toggleNegation(expression.left, context);
|
|
462
|
+
let rightText = toggleNegation(expression.right, context);
|
|
463
|
+
if (!expression.left.range || !expression.right.range) return `${leftText} ${targetOperator} ${rightText}`;
|
|
464
|
+
let [, leftEnd] = expression.left.range;
|
|
465
|
+
let [rightStart] = expression.right.range;
|
|
466
|
+
let textBetween = sourceCode.text.slice(leftEnd, rightStart);
|
|
467
|
+
if (/\(\s*$/u.test(textBetween)) textBetween = textBetween.replace(/\(\s*$/u, "");
|
|
468
|
+
return `${leftText}${textBetween.replaceAll(new RegExp(sourceOperator.replaceAll(/[$()*+.?[\\\]^{|}]/gu, String.raw`\$&`), "gu"), targetOperator)}${rightText}`;
|
|
469
|
+
}
|
|
470
|
+
function flattenOperands({ expressionType, expression, context }) {
|
|
471
|
+
let result = [];
|
|
472
|
+
let stack = [{
|
|
473
|
+
expr: expression,
|
|
474
|
+
depth: 0
|
|
475
|
+
}];
|
|
476
|
+
while (stack.length > 0) {
|
|
477
|
+
let { depth, expr } = stack.pop();
|
|
478
|
+
if (depth > MAX_DEPTH || !matchesExpressionType(expr, expressionType)) {
|
|
479
|
+
result.push(toggleNegation(expr, context));
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
let logicalExpr = expr;
|
|
483
|
+
stack.push({
|
|
484
|
+
expr: logicalExpr.right,
|
|
485
|
+
depth: depth + 1
|
|
486
|
+
}, {
|
|
487
|
+
expr: logicalExpr.left,
|
|
488
|
+
depth: depth + 1
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
return result;
|
|
492
|
+
}
|
|
493
|
+
function transformSimple({ expressionType, targetOperator, expression, context }) {
|
|
494
|
+
return flattenOperands({
|
|
495
|
+
expressionType,
|
|
496
|
+
expression,
|
|
497
|
+
context
|
|
498
|
+
}).join(` ${targetOperator} `);
|
|
499
|
+
}
|
|
500
|
+
function matchesExpressionType(expression, type) {
|
|
501
|
+
return type === "conjunction" ? isConjunction(expression) : isDisjunction(expression);
|
|
502
|
+
}
|
|
503
|
+
function hasSpecialFormatting(text) {
|
|
504
|
+
return text.includes("//") || text.includes("/*") || text.includes("\n") || /\s{2,}/u.test(text);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/not.js
|
|
509
|
+
function not(predicate) {
|
|
510
|
+
return (...arguments_) => !predicate(...arguments_);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/or.js
|
|
515
|
+
function or(...predicates) {
|
|
516
|
+
return (...arguments_) => predicates.some((predicate) => predicate(...arguments_));
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/rules/no-negated-conjunction.js
|
|
521
|
+
const noNegatedConjunction = {
|
|
522
|
+
create: (context) => ({ UnaryExpression: (node$1) => {
|
|
523
|
+
if (createTestWithParameters(node$1, context)(isNegated, applyToProperty("argument", isConjunction), isPureGroup, or(hasBooleanContext, not(hasNegationInsideParens)))) {
|
|
524
|
+
let fixedExpression = transform({
|
|
525
|
+
expressionType: "conjunction",
|
|
526
|
+
shouldWrapInParens: isConjunction(node$1.parent),
|
|
527
|
+
context,
|
|
528
|
+
node: node$1
|
|
529
|
+
});
|
|
530
|
+
if (fixedExpression) {
|
|
531
|
+
let originalExpression = context.sourceCode.getText(node$1);
|
|
532
|
+
context.report({
|
|
533
|
+
data: {
|
|
534
|
+
original: sanitizeCode(originalExpression),
|
|
535
|
+
fixed: sanitizeCode(fixedExpression)
|
|
536
|
+
},
|
|
537
|
+
fix: (fixer) => fixer.replaceText(node$1, fixedExpression),
|
|
538
|
+
messageId: "convertNegatedConjunction",
|
|
539
|
+
node: node$1
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
} }),
|
|
544
|
+
meta: {
|
|
545
|
+
docs: {
|
|
546
|
+
description: "Transforms the negation of a conjunction !(A && B) into the equivalent !A || !B according to De Morgan’s law",
|
|
547
|
+
url: `https://github.com/${repository}/blob/main/docs/no-negated-conjunction.md`,
|
|
548
|
+
category: "Best Practices",
|
|
549
|
+
recommended: true
|
|
550
|
+
},
|
|
551
|
+
messages: { convertNegatedConjunction: "Replace negated conjunction `{{ original }}` with `{{ fixed }}`" },
|
|
552
|
+
type: "suggestion",
|
|
553
|
+
fixable: "code",
|
|
554
|
+
schema: []
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
//#endregion
|
|
559
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/rules/no-negated-disjunction.js
|
|
560
|
+
const noNegatedDisjunction = {
|
|
561
|
+
create: (context) => ({ UnaryExpression: (node$1) => {
|
|
562
|
+
if (createTestWithParameters(node$1, context)(isNegated, applyToProperty("argument", isDisjunction), isPureGroup, or(hasBooleanContext, not(hasNegationInsideParens)))) {
|
|
563
|
+
let fixedExpression = transform({
|
|
564
|
+
expressionType: "disjunction",
|
|
565
|
+
shouldWrapInParens: false,
|
|
566
|
+
context,
|
|
567
|
+
node: node$1
|
|
568
|
+
});
|
|
569
|
+
if (fixedExpression) {
|
|
570
|
+
let originalExpression = context.sourceCode.getText(node$1);
|
|
571
|
+
context.report({
|
|
572
|
+
data: {
|
|
573
|
+
original: sanitizeCode(originalExpression),
|
|
574
|
+
fixed: sanitizeCode(fixedExpression)
|
|
575
|
+
},
|
|
576
|
+
fix: (fixer) => fixer.replaceText(node$1, fixedExpression),
|
|
577
|
+
messageId: "convertNegatedDisjunction",
|
|
578
|
+
node: node$1
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
} }),
|
|
583
|
+
meta: {
|
|
584
|
+
docs: {
|
|
585
|
+
description: "Transforms the negation of a disjunction !(A || B) into the equivalent !A && !B according to De Morgan’s law",
|
|
586
|
+
url: `https://github.com/${repository}/blob/main/docs/no-negated-disjunction.md`,
|
|
587
|
+
category: "Best Practices",
|
|
588
|
+
recommended: true
|
|
589
|
+
},
|
|
590
|
+
messages: { convertNegatedDisjunction: "Replace negated disjunction `{{ original }}` with `{{ fixed }}`" },
|
|
591
|
+
type: "suggestion",
|
|
592
|
+
fixable: "code",
|
|
593
|
+
schema: []
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
//#endregion
|
|
598
|
+
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/index.js
|
|
599
|
+
let pluginName = "de-morgan";
|
|
600
|
+
let rules = {
|
|
601
|
+
"no-negated-conjunction": noNegatedConjunction,
|
|
602
|
+
"no-negated-disjunction": noNegatedDisjunction
|
|
603
|
+
};
|
|
604
|
+
function getRules() {
|
|
605
|
+
return Object.fromEntries(Object.keys(rules).map((ruleName) => [`${pluginName}/${ruleName}`, "error"]));
|
|
606
|
+
}
|
|
607
|
+
function createConfig() {
|
|
608
|
+
return {
|
|
609
|
+
plugins: { [pluginName]: { rules } },
|
|
610
|
+
rules: getRules()
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
function createLegacyConfig() {
|
|
614
|
+
return {
|
|
615
|
+
plugins: [pluginName],
|
|
616
|
+
rules: getRules()
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
let configs = {
|
|
620
|
+
"recommended-legacy": createLegacyConfig(),
|
|
621
|
+
recommended: createConfig()
|
|
622
|
+
};
|
|
623
|
+
const index = {
|
|
624
|
+
meta: {
|
|
625
|
+
version,
|
|
626
|
+
name
|
|
627
|
+
},
|
|
628
|
+
configs,
|
|
629
|
+
rules
|
|
630
|
+
};
|
|
631
|
+
|
|
182
632
|
//#endregion
|
|
183
633
|
//#region src/configs/comments.ts
|
|
184
634
|
const comments = () => [{
|
|
@@ -195,6 +645,13 @@ const comments = () => [{
|
|
|
195
645
|
}
|
|
196
646
|
}];
|
|
197
647
|
|
|
648
|
+
//#endregion
|
|
649
|
+
//#region src/configs/de-morgan.ts
|
|
650
|
+
const deMorgan = () => [{
|
|
651
|
+
...index.configs.recommended,
|
|
652
|
+
name: "so1ve/de-morgan"
|
|
653
|
+
}];
|
|
654
|
+
|
|
198
655
|
//#endregion
|
|
199
656
|
//#region src/configs/formatting.ts
|
|
200
657
|
async function formatting(options) {
|
|
@@ -246,6 +703,59 @@ async function formatting(options) {
|
|
|
246
703
|
files: [GLOB_PACKAGEJSON],
|
|
247
704
|
rules: { "jsonc/sort-keys": [
|
|
248
705
|
"error",
|
|
706
|
+
{
|
|
707
|
+
pathPattern: "^$",
|
|
708
|
+
order: [
|
|
709
|
+
"name",
|
|
710
|
+
"displayName",
|
|
711
|
+
"private",
|
|
712
|
+
"preview",
|
|
713
|
+
"version",
|
|
714
|
+
"packageManager",
|
|
715
|
+
"publisher",
|
|
716
|
+
"author",
|
|
717
|
+
"contributors",
|
|
718
|
+
"type",
|
|
719
|
+
"description",
|
|
720
|
+
"keywords",
|
|
721
|
+
"homepage",
|
|
722
|
+
"repository",
|
|
723
|
+
"bugs",
|
|
724
|
+
"funding",
|
|
725
|
+
"categories",
|
|
726
|
+
"license",
|
|
727
|
+
"sideEffects",
|
|
728
|
+
"exports",
|
|
729
|
+
"bin",
|
|
730
|
+
"main",
|
|
731
|
+
"module",
|
|
732
|
+
"browser",
|
|
733
|
+
"unpkg",
|
|
734
|
+
"jsdelivr",
|
|
735
|
+
"types",
|
|
736
|
+
"typesVersions",
|
|
737
|
+
"icon",
|
|
738
|
+
"files",
|
|
739
|
+
"engines",
|
|
740
|
+
"extensionKind",
|
|
741
|
+
"activationEvents",
|
|
742
|
+
"contributes",
|
|
743
|
+
"eslintConfig",
|
|
744
|
+
"publishConfig",
|
|
745
|
+
"scripts",
|
|
746
|
+
"husky",
|
|
747
|
+
"simple-git-hooks",
|
|
748
|
+
"lint-staged",
|
|
749
|
+
"dependencies",
|
|
750
|
+
"devDependencies",
|
|
751
|
+
"optionalDependencies",
|
|
752
|
+
"peerDependencies",
|
|
753
|
+
"peerDependenciesMeta",
|
|
754
|
+
"pnpm",
|
|
755
|
+
"overrides",
|
|
756
|
+
"resolutions"
|
|
757
|
+
]
|
|
758
|
+
},
|
|
249
759
|
{
|
|
250
760
|
pathPattern: "^exports$",
|
|
251
761
|
order: { type: "asc" }
|
|
@@ -258,122 +768,170 @@ async function formatting(options) {
|
|
|
258
768
|
"import",
|
|
259
769
|
"default"
|
|
260
770
|
]
|
|
261
|
-
}
|
|
262
|
-
] }
|
|
263
|
-
}, {
|
|
264
|
-
name: "so1ve/formatting/rules/sort-tsconfig",
|
|
265
|
-
files: GLOB_TSCONFIG,
|
|
266
|
-
rules: { "jsonc/sort-keys": [
|
|
267
|
-
"error",
|
|
771
|
+
},
|
|
268
772
|
{
|
|
269
|
-
pathPattern: "
|
|
270
|
-
order:
|
|
271
|
-
"extends",
|
|
272
|
-
"compilerOptions",
|
|
273
|
-
"references",
|
|
274
|
-
"files",
|
|
275
|
-
"include",
|
|
276
|
-
"exclude"
|
|
277
|
-
]
|
|
773
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$",
|
|
774
|
+
order: { type: "asc" }
|
|
278
775
|
},
|
|
279
776
|
{
|
|
280
|
-
pathPattern: "^
|
|
281
|
-
order:
|
|
282
|
-
"incremental",
|
|
283
|
-
"composite",
|
|
284
|
-
"tsBuildInfoFile",
|
|
285
|
-
"disableSourceOfProjectReferenceRedirect",
|
|
286
|
-
"disableSolutionSearching",
|
|
287
|
-
"disableReferencedProjectLoad",
|
|
288
|
-
"target",
|
|
289
|
-
"jsx",
|
|
290
|
-
"jsxFactory",
|
|
291
|
-
"jsxFragmentFactory",
|
|
292
|
-
"jsxImportSource",
|
|
293
|
-
"lib",
|
|
294
|
-
"moduleDetection",
|
|
295
|
-
"noLib",
|
|
296
|
-
"reactNamespace",
|
|
297
|
-
"useDefineForClassFields",
|
|
298
|
-
"emitDecoratorMetadata",
|
|
299
|
-
"experimentalDecorators",
|
|
300
|
-
"baseUrl",
|
|
301
|
-
"rootDir",
|
|
302
|
-
"rootDirs",
|
|
303
|
-
"customConditions",
|
|
304
|
-
"module",
|
|
305
|
-
"moduleResolution",
|
|
306
|
-
"moduleSuffixes",
|
|
307
|
-
"noResolve",
|
|
308
|
-
"resolveJsonModule",
|
|
309
|
-
"resolvePackageJsonExports",
|
|
310
|
-
"resolvePackageJsonImports",
|
|
311
|
-
"typeRoots",
|
|
312
|
-
"types",
|
|
313
|
-
"allowArbitraryExtensions",
|
|
314
|
-
"allowImportingTsExtensions",
|
|
315
|
-
"allowUmdGlobalAccess",
|
|
316
|
-
"allowJs",
|
|
317
|
-
"checkJs",
|
|
318
|
-
"maxNodeModuleJsDepth",
|
|
319
|
-
"strict",
|
|
320
|
-
"strictBindCallApply",
|
|
321
|
-
"strictFunctionTypes",
|
|
322
|
-
"strictNullChecks",
|
|
323
|
-
"strictPropertyInitialization",
|
|
324
|
-
"allowUnreachableCode",
|
|
325
|
-
"allowUnusedLabels",
|
|
326
|
-
"alwaysStrict",
|
|
327
|
-
"exactOptionalPropertyTypes",
|
|
328
|
-
"noFallthroughCasesInSwitch",
|
|
329
|
-
"noImplicitAny",
|
|
330
|
-
"noImplicitOverride",
|
|
331
|
-
"noImplicitReturns",
|
|
332
|
-
"noImplicitThis",
|
|
333
|
-
"noPropertyAccessFromIndexSignature",
|
|
334
|
-
"noUncheckedIndexedAccess",
|
|
335
|
-
"noUnusedLocals",
|
|
336
|
-
"noUnusedParameters",
|
|
337
|
-
"useUnknownInCatchVariables",
|
|
338
|
-
"declaration",
|
|
339
|
-
"declarationDir",
|
|
340
|
-
"declarationMap",
|
|
341
|
-
"downlevelIteration",
|
|
342
|
-
"emitBOM",
|
|
343
|
-
"emitDeclarationOnly",
|
|
344
|
-
"importHelpers",
|
|
345
|
-
"importsNotUsedAsValues",
|
|
346
|
-
"inlineSourceMap",
|
|
347
|
-
"inlineSources",
|
|
348
|
-
"mapRoot",
|
|
349
|
-
"newLine",
|
|
350
|
-
"noEmit",
|
|
351
|
-
"noEmitHelpers",
|
|
352
|
-
"noEmitOnError",
|
|
353
|
-
"outDir",
|
|
354
|
-
"outFile",
|
|
355
|
-
"preserveConstEnums",
|
|
356
|
-
"preserveValueImports",
|
|
357
|
-
"removeComments",
|
|
358
|
-
"sourceMap",
|
|
359
|
-
"sourceRoot",
|
|
360
|
-
"stripInternal",
|
|
361
|
-
"allowSyntheticDefaultImports",
|
|
362
|
-
"esModuleInterop",
|
|
363
|
-
"forceConsistentCasingInFileNames",
|
|
364
|
-
"isolatedModules",
|
|
365
|
-
"preserveSymlinks",
|
|
366
|
-
"verbatimModuleSyntax",
|
|
367
|
-
"skipDefaultLibCheck",
|
|
368
|
-
"skipLibCheck",
|
|
369
|
-
"paths"
|
|
370
|
-
]
|
|
777
|
+
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$",
|
|
778
|
+
order: { type: "asc" }
|
|
371
779
|
},
|
|
372
780
|
{
|
|
373
|
-
pathPattern: "^
|
|
781
|
+
pathPattern: "^workspaces\\.catalog$",
|
|
374
782
|
order: { type: "asc" }
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
pathPattern: "^workspaces\\.catalogs\\.[^.]+$",
|
|
786
|
+
order: { type: "asc" }
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$",
|
|
790
|
+
order: [
|
|
791
|
+
"pre-commit",
|
|
792
|
+
"prepare-commit-msg",
|
|
793
|
+
"commit-msg",
|
|
794
|
+
"post-commit",
|
|
795
|
+
"pre-rebase",
|
|
796
|
+
"post-rewrite",
|
|
797
|
+
"post-checkout",
|
|
798
|
+
"post-merge",
|
|
799
|
+
"pre-push",
|
|
800
|
+
"pre-auto-gc"
|
|
801
|
+
]
|
|
375
802
|
}
|
|
376
803
|
] }
|
|
804
|
+
}, {
|
|
805
|
+
name: "so1ve/formatting/rules/sort-tsconfig",
|
|
806
|
+
files: GLOB_TSCONFIG,
|
|
807
|
+
rules: {
|
|
808
|
+
"jsonc/sort-array-values": [
|
|
809
|
+
"error",
|
|
810
|
+
{
|
|
811
|
+
pathPattern: "^compilerOptions\\.types$",
|
|
812
|
+
order: { type: "asc" }
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
pathPattern: "^include$",
|
|
816
|
+
order: { type: "asc" }
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
pathPattern: "^exclude$",
|
|
820
|
+
order: { type: "asc" }
|
|
821
|
+
}
|
|
822
|
+
],
|
|
823
|
+
"jsonc/sort-keys": [
|
|
824
|
+
"error",
|
|
825
|
+
{
|
|
826
|
+
pathPattern: "^$",
|
|
827
|
+
order: [
|
|
828
|
+
"extends",
|
|
829
|
+
"compilerOptions",
|
|
830
|
+
"references",
|
|
831
|
+
"files",
|
|
832
|
+
"include",
|
|
833
|
+
"exclude"
|
|
834
|
+
]
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
pathPattern: "^compilerOptions$",
|
|
838
|
+
order: [
|
|
839
|
+
"incremental",
|
|
840
|
+
"composite",
|
|
841
|
+
"tsBuildInfoFile",
|
|
842
|
+
"disableSourceOfProjectReferenceRedirect",
|
|
843
|
+
"disableSolutionSearching",
|
|
844
|
+
"disableReferencedProjectLoad",
|
|
845
|
+
"target",
|
|
846
|
+
"jsx",
|
|
847
|
+
"jsxFactory",
|
|
848
|
+
"jsxFragmentFactory",
|
|
849
|
+
"jsxImportSource",
|
|
850
|
+
"lib",
|
|
851
|
+
"moduleDetection",
|
|
852
|
+
"noLib",
|
|
853
|
+
"reactNamespace",
|
|
854
|
+
"useDefineForClassFields",
|
|
855
|
+
"emitDecoratorMetadata",
|
|
856
|
+
"experimentalDecorators",
|
|
857
|
+
"baseUrl",
|
|
858
|
+
"rootDir",
|
|
859
|
+
"rootDirs",
|
|
860
|
+
"customConditions",
|
|
861
|
+
"module",
|
|
862
|
+
"moduleResolution",
|
|
863
|
+
"moduleSuffixes",
|
|
864
|
+
"noResolve",
|
|
865
|
+
"resolveJsonModule",
|
|
866
|
+
"resolvePackageJsonExports",
|
|
867
|
+
"resolvePackageJsonImports",
|
|
868
|
+
"typeRoots",
|
|
869
|
+
"types",
|
|
870
|
+
"allowArbitraryExtensions",
|
|
871
|
+
"allowImportingTsExtensions",
|
|
872
|
+
"allowUmdGlobalAccess",
|
|
873
|
+
"allowJs",
|
|
874
|
+
"checkJs",
|
|
875
|
+
"maxNodeModuleJsDepth",
|
|
876
|
+
"strict",
|
|
877
|
+
"strictBindCallApply",
|
|
878
|
+
"strictFunctionTypes",
|
|
879
|
+
"strictNullChecks",
|
|
880
|
+
"strictPropertyInitialization",
|
|
881
|
+
"allowUnreachableCode",
|
|
882
|
+
"allowUnusedLabels",
|
|
883
|
+
"alwaysStrict",
|
|
884
|
+
"exactOptionalPropertyTypes",
|
|
885
|
+
"noFallthroughCasesInSwitch",
|
|
886
|
+
"noImplicitAny",
|
|
887
|
+
"noImplicitOverride",
|
|
888
|
+
"noImplicitReturns",
|
|
889
|
+
"noImplicitThis",
|
|
890
|
+
"noPropertyAccessFromIndexSignature",
|
|
891
|
+
"noUncheckedIndexedAccess",
|
|
892
|
+
"noUnusedLocals",
|
|
893
|
+
"noUnusedParameters",
|
|
894
|
+
"useUnknownInCatchVariables",
|
|
895
|
+
"declaration",
|
|
896
|
+
"declarationDir",
|
|
897
|
+
"declarationMap",
|
|
898
|
+
"downlevelIteration",
|
|
899
|
+
"emitBOM",
|
|
900
|
+
"emitDeclarationOnly",
|
|
901
|
+
"importHelpers",
|
|
902
|
+
"importsNotUsedAsValues",
|
|
903
|
+
"inlineSourceMap",
|
|
904
|
+
"inlineSources",
|
|
905
|
+
"mapRoot",
|
|
906
|
+
"newLine",
|
|
907
|
+
"noEmit",
|
|
908
|
+
"noEmitHelpers",
|
|
909
|
+
"noEmitOnError",
|
|
910
|
+
"outDir",
|
|
911
|
+
"outFile",
|
|
912
|
+
"preserveConstEnums",
|
|
913
|
+
"preserveValueImports",
|
|
914
|
+
"removeComments",
|
|
915
|
+
"sourceMap",
|
|
916
|
+
"sourceRoot",
|
|
917
|
+
"stripInternal",
|
|
918
|
+
"allowSyntheticDefaultImports",
|
|
919
|
+
"esModuleInterop",
|
|
920
|
+
"forceConsistentCasingInFileNames",
|
|
921
|
+
"isolatedModules",
|
|
922
|
+
"preserveSymlinks",
|
|
923
|
+
"verbatimModuleSyntax",
|
|
924
|
+
"skipDefaultLibCheck",
|
|
925
|
+
"skipLibCheck",
|
|
926
|
+
"paths"
|
|
927
|
+
]
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
pathPattern: "^compilerOptions\\.paths$",
|
|
931
|
+
order: { type: "asc" }
|
|
932
|
+
}
|
|
933
|
+
]
|
|
934
|
+
}
|
|
377
935
|
}],
|
|
378
936
|
(options?.test ?? true) && {
|
|
379
937
|
name: "so1ve/formatting/rules/test",
|
|
@@ -516,7 +1074,7 @@ async function javascript({ overrides } = {}) {
|
|
|
516
1074
|
{
|
|
517
1075
|
name: "so1ve/javascript/rules",
|
|
518
1076
|
languageOptions: {
|
|
519
|
-
ecmaVersion:
|
|
1077
|
+
ecmaVersion: "latest",
|
|
520
1078
|
globals: {
|
|
521
1079
|
...globals.browser,
|
|
522
1080
|
...globals.es2021,
|
|
@@ -527,7 +1085,7 @@ async function javascript({ overrides } = {}) {
|
|
|
527
1085
|
},
|
|
528
1086
|
parserOptions: {
|
|
529
1087
|
ecmaFeatures: { jsx: true },
|
|
530
|
-
ecmaVersion:
|
|
1088
|
+
ecmaVersion: "latest",
|
|
531
1089
|
sourceType: "module"
|
|
532
1090
|
},
|
|
533
1091
|
sourceType: "module"
|
|
@@ -946,30 +1504,30 @@ async function perfectionist() {
|
|
|
946
1504
|
//#endregion
|
|
947
1505
|
//#region ../../node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
|
|
948
1506
|
const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
949
|
-
async function findUp(name, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
|
|
1507
|
+
async function findUp(name$1, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
|
|
950
1508
|
let directory = path.resolve(toPath(cwd) ?? "");
|
|
951
1509
|
const { root } = path.parse(directory);
|
|
952
1510
|
stopAt = path.resolve(directory, toPath(stopAt ?? root));
|
|
953
|
-
const isAbsoluteName = path.isAbsolute(name);
|
|
1511
|
+
const isAbsoluteName = path.isAbsolute(name$1);
|
|
954
1512
|
while (directory) {
|
|
955
|
-
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
1513
|
+
const filePath = isAbsoluteName ? name$1 : path.join(directory, name$1);
|
|
956
1514
|
try {
|
|
957
|
-
const stats = await
|
|
1515
|
+
const stats = await fsPromises.stat(filePath);
|
|
958
1516
|
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
|
|
959
1517
|
} catch {}
|
|
960
1518
|
if (directory === stopAt || directory === root) break;
|
|
961
1519
|
directory = path.dirname(directory);
|
|
962
1520
|
}
|
|
963
1521
|
}
|
|
964
|
-
function findUpSync(name, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
|
|
1522
|
+
function findUpSync(name$1, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
|
|
965
1523
|
let directory = path.resolve(toPath(cwd) ?? "");
|
|
966
1524
|
const { root } = path.parse(directory);
|
|
967
1525
|
stopAt = path.resolve(directory, toPath(stopAt) ?? root);
|
|
968
|
-
const isAbsoluteName = path.isAbsolute(name);
|
|
1526
|
+
const isAbsoluteName = path.isAbsolute(name$1);
|
|
969
1527
|
while (directory) {
|
|
970
|
-
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
1528
|
+
const filePath = isAbsoluteName ? name$1 : path.join(directory, name$1);
|
|
971
1529
|
try {
|
|
972
|
-
const stats = fs
|
|
1530
|
+
const stats = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
973
1531
|
if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
|
|
974
1532
|
} catch {}
|
|
975
1533
|
if (directory === stopAt || directory === root) break;
|
|
@@ -982,7 +1540,7 @@ function findUpSync(name, { cwd = process$1.cwd(), type = "file", stopAt } = {})
|
|
|
982
1540
|
async function detectCatalogUsage() {
|
|
983
1541
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
984
1542
|
if (!workspaceFile) return false;
|
|
985
|
-
const yaml$1 = await
|
|
1543
|
+
const yaml$1 = await fsPromises.readFile(workspaceFile, "utf-8");
|
|
986
1544
|
return yaml$1.includes("catalog:") || yaml$1.includes("catalogs:");
|
|
987
1545
|
}
|
|
988
1546
|
async function pnpm(options) {
|
|
@@ -992,8 +1550,8 @@ async function pnpm(options) {
|
|
|
992
1550
|
yaml$1 ? interopDefault(import("yaml-eslint-parser")) : void 0,
|
|
993
1551
|
json ? interopDefault(import("jsonc-eslint-parser")) : void 0
|
|
994
1552
|
]);
|
|
995
|
-
const configs = [];
|
|
996
|
-
if (json) configs.push({
|
|
1553
|
+
const configs$1 = [];
|
|
1554
|
+
if (json) configs$1.push({
|
|
997
1555
|
files: ["package.json", "**/package.json"],
|
|
998
1556
|
languageOptions: { parser: jsoncParser },
|
|
999
1557
|
name: "so1ve/pnpm/package-json",
|
|
@@ -1004,7 +1562,7 @@ async function pnpm(options) {
|
|
|
1004
1562
|
"pnpm/json-valid-catalog": "error"
|
|
1005
1563
|
}
|
|
1006
1564
|
});
|
|
1007
|
-
if (yaml$1) configs.push({
|
|
1565
|
+
if (yaml$1) configs$1.push({
|
|
1008
1566
|
files: ["pnpm-workspace.yaml"],
|
|
1009
1567
|
languageOptions: { parser: yamlParser },
|
|
1010
1568
|
name: "so1ve/pnpm/pnpm-workspace-yaml",
|
|
@@ -1089,7 +1647,7 @@ async function pnpm(options) {
|
|
|
1089
1647
|
}
|
|
1090
1648
|
] }
|
|
1091
1649
|
});
|
|
1092
|
-
return configs;
|
|
1650
|
+
return configs$1;
|
|
1093
1651
|
}
|
|
1094
1652
|
|
|
1095
1653
|
//#endregion
|
|
@@ -1727,38 +2285,38 @@ const defaultPluginRenaming = {
|
|
|
1727
2285
|
*/
|
|
1728
2286
|
function so1ve(options = {}, ...userConfigs) {
|
|
1729
2287
|
const { astro: enableAstro = isPackageExists("astro"), componentExts = [], gitignore: enableGitignore = true, ignores: userIgnores = [], pnpm: enablePnpm = !!findUpSync("pnpm-workspace.yaml"), solid: enableSolid = isPackageExists("solid-js"), typescript: enableTypeScript = isPackageExists("typescript"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
1730
|
-
const configs = [];
|
|
2288
|
+
const configs$1 = [];
|
|
1731
2289
|
if (enableGitignore) if (typeof enableGitignore === "boolean") {
|
|
1732
|
-
if (fs
|
|
1733
|
-
} else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
1734
|
-
configs.push(ignores(userIgnores), javascript({ overrides: getOverrides(options, "javascript") }), comments(), node(), onlyError(), promise(), sortImports(), imports(), unicorn(), command());
|
|
1735
|
-
if (enablePnpm) configs.push(pnpm({
|
|
2290
|
+
if (fs.existsSync(".gitignore")) configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
2291
|
+
} else configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
2292
|
+
configs$1.push(ignores(userIgnores), javascript({ overrides: getOverrides(options, "javascript") }), comments(), node(), onlyError(), promise(), sortImports(), imports(), unicorn(), command(), deMorgan());
|
|
2293
|
+
if (enablePnpm) configs$1.push(pnpm({
|
|
1736
2294
|
json: options.jsonc !== false,
|
|
1737
2295
|
yaml: options.yaml !== false,
|
|
1738
2296
|
...typeof enablePnpm === "boolean" ? {} : enablePnpm
|
|
1739
2297
|
}));
|
|
1740
2298
|
if (enableVue) componentExts.push("vue");
|
|
1741
|
-
if (options.html ?? true) configs.push(html());
|
|
1742
|
-
if (enableTypeScript) configs.push(typescript({
|
|
2299
|
+
if (options.html ?? true) configs$1.push(html());
|
|
2300
|
+
if (enableTypeScript) configs$1.push(typescript({
|
|
1743
2301
|
componentExts,
|
|
1744
2302
|
overrides: getOverrides(options, "typescript")
|
|
1745
2303
|
}));
|
|
1746
|
-
if (options.test ?? true) configs.push(test({ overrides: getOverrides(options, "test") }));
|
|
1747
|
-
if (enableAstro) configs.push(astro({ overrides: getOverrides(options, "astro") }));
|
|
1748
|
-
if (enableVue) configs.push(vue({
|
|
2304
|
+
if (options.test ?? true) configs$1.push(test({ overrides: getOverrides(options, "test") }));
|
|
2305
|
+
if (enableAstro) configs$1.push(astro({ overrides: getOverrides(options, "astro") }));
|
|
2306
|
+
if (enableVue) configs$1.push(vue({
|
|
1749
2307
|
overrides: getOverrides(options, "vue"),
|
|
1750
2308
|
typescript: !!enableTypeScript
|
|
1751
2309
|
}));
|
|
1752
|
-
if (enableSolid) configs.push(solid({
|
|
2310
|
+
if (enableSolid) configs$1.push(solid({
|
|
1753
2311
|
overrides: getOverrides(options, "solid"),
|
|
1754
2312
|
typescript: !!enableTypeScript
|
|
1755
2313
|
}));
|
|
1756
|
-
if (options.formatting ?? true) configs.push(formatting(options));
|
|
1757
|
-
if (options.perfectionist ?? true) configs.push(perfectionist());
|
|
1758
|
-
if (options.jsonc ?? true) configs.push(jsonc());
|
|
1759
|
-
if (options.toml ?? true) configs.push(toml({ overrides: getOverrides(options, "toml") }));
|
|
1760
|
-
if (options.yaml ?? true) configs.push(yaml({ overrides: getOverrides(options, "yaml") }));
|
|
1761
|
-
if (options.mdx ?? true) configs.push(mdx({
|
|
2314
|
+
if (options.formatting ?? true) configs$1.push(formatting(options));
|
|
2315
|
+
if (options.perfectionist ?? true) configs$1.push(perfectionist());
|
|
2316
|
+
if (options.jsonc ?? true) configs$1.push(jsonc());
|
|
2317
|
+
if (options.toml ?? true) configs$1.push(toml({ overrides: getOverrides(options, "toml") }));
|
|
2318
|
+
if (options.yaml ?? true) configs$1.push(yaml({ overrides: getOverrides(options, "yaml") }));
|
|
2319
|
+
if (options.mdx ?? true) configs$1.push(mdx({
|
|
1762
2320
|
componentExts,
|
|
1763
2321
|
overrides: getOverrides(options, "mdx")
|
|
1764
2322
|
}));
|
|
@@ -1766,8 +2324,8 @@ function so1ve(options = {}, ...userConfigs) {
|
|
|
1766
2324
|
if (key in options) acc[key] = options[key];
|
|
1767
2325
|
return acc;
|
|
1768
2326
|
}, {});
|
|
1769
|
-
if (Object.keys(fusedConfig).length > 0) configs.push([fusedConfig]);
|
|
1770
|
-
return new FlatConfigComposer().append(...configs, ...userConfigs).renamePlugins(defaultPluginRenaming);
|
|
2327
|
+
if (Object.keys(fusedConfig).length > 0) configs$1.push([fusedConfig]);
|
|
2328
|
+
return new FlatConfigComposer().append(...configs$1, ...userConfigs).renamePlugins(defaultPluginRenaming);
|
|
1771
2329
|
}
|
|
1772
2330
|
function getOverrides(options, key) {
|
|
1773
2331
|
const sub = typeof options[key] === "boolean" ? {} : options[key] ?? {};
|
|
@@ -1778,4 +2336,4 @@ function getOverrides(options, key) {
|
|
|
1778
2336
|
}
|
|
1779
2337
|
|
|
1780
2338
|
//#endregion
|
|
1781
|
-
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, astro, command, comments, defaultPluginRenaming, formatting, getOverrides, html, ignores, imports, interopDefault, javascript, jsonc, mdx, node, onlyError, perfectionist, pnpm, promise, renameRules, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, yaml };
|
|
2339
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, astro, command, comments, deMorgan, defaultPluginRenaming, formatting, getOverrides, html, ignores, imports, interopDefault, javascript, jsonc, mdx, node, onlyError, perfectionist, pnpm, promise, renameRules, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, yaml };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@so1ve/eslint-config",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.25.0",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Ray's eslint config.",
|
|
@@ -76,10 +76,11 @@
|
|
|
76
76
|
"typescript-eslint": "^8.50.1",
|
|
77
77
|
"vue-eslint-parser": "^10.2.0",
|
|
78
78
|
"yaml-eslint-parser": "^1.3.2",
|
|
79
|
-
"@so1ve/eslint-plugin": "3.
|
|
80
|
-
"@so1ve/eslint-plugin-sort-imports": "3.
|
|
79
|
+
"@so1ve/eslint-plugin": "3.25.0",
|
|
80
|
+
"@so1ve/eslint-plugin-sort-imports": "3.25.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
+
"eslint-plugin-de-morgan": "^2.0.0",
|
|
83
84
|
"find-up-simple": "^1.0.1"
|
|
84
85
|
},
|
|
85
86
|
"peerDependencies": {
|