@so1ve/eslint-config 3.24.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 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/rules' | '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';
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>;
@@ -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
@@ -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/rules"
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) {
@@ -1047,13 +1504,13 @@ async function perfectionist() {
1047
1504
  //#endregion
1048
1505
  //#region ../../node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
1049
1506
  const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
1050
- async function findUp(name, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
1507
+ async function findUp(name$1, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
1051
1508
  let directory = path.resolve(toPath(cwd) ?? "");
1052
1509
  const { root } = path.parse(directory);
1053
1510
  stopAt = path.resolve(directory, toPath(stopAt ?? root));
1054
- const isAbsoluteName = path.isAbsolute(name);
1511
+ const isAbsoluteName = path.isAbsolute(name$1);
1055
1512
  while (directory) {
1056
- const filePath = isAbsoluteName ? name : path.join(directory, name);
1513
+ const filePath = isAbsoluteName ? name$1 : path.join(directory, name$1);
1057
1514
  try {
1058
1515
  const stats = await fsPromises.stat(filePath);
1059
1516
  if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
@@ -1062,13 +1519,13 @@ async function findUp(name, { cwd = process$1.cwd(), type = "file", stopAt } = {
1062
1519
  directory = path.dirname(directory);
1063
1520
  }
1064
1521
  }
1065
- function findUpSync(name, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
1522
+ function findUpSync(name$1, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
1066
1523
  let directory = path.resolve(toPath(cwd) ?? "");
1067
1524
  const { root } = path.parse(directory);
1068
1525
  stopAt = path.resolve(directory, toPath(stopAt) ?? root);
1069
- const isAbsoluteName = path.isAbsolute(name);
1526
+ const isAbsoluteName = path.isAbsolute(name$1);
1070
1527
  while (directory) {
1071
- const filePath = isAbsoluteName ? name : path.join(directory, name);
1528
+ const filePath = isAbsoluteName ? name$1 : path.join(directory, name$1);
1072
1529
  try {
1073
1530
  const stats = fs.statSync(filePath, { throwIfNoEntry: false });
1074
1531
  if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
@@ -1093,8 +1550,8 @@ async function pnpm(options) {
1093
1550
  yaml$1 ? interopDefault(import("yaml-eslint-parser")) : void 0,
1094
1551
  json ? interopDefault(import("jsonc-eslint-parser")) : void 0
1095
1552
  ]);
1096
- const configs = [];
1097
- if (json) configs.push({
1553
+ const configs$1 = [];
1554
+ if (json) configs$1.push({
1098
1555
  files: ["package.json", "**/package.json"],
1099
1556
  languageOptions: { parser: jsoncParser },
1100
1557
  name: "so1ve/pnpm/package-json",
@@ -1105,7 +1562,7 @@ async function pnpm(options) {
1105
1562
  "pnpm/json-valid-catalog": "error"
1106
1563
  }
1107
1564
  });
1108
- if (yaml$1) configs.push({
1565
+ if (yaml$1) configs$1.push({
1109
1566
  files: ["pnpm-workspace.yaml"],
1110
1567
  languageOptions: { parser: yamlParser },
1111
1568
  name: "so1ve/pnpm/pnpm-workspace-yaml",
@@ -1190,7 +1647,7 @@ async function pnpm(options) {
1190
1647
  }
1191
1648
  ] }
1192
1649
  });
1193
- return configs;
1650
+ return configs$1;
1194
1651
  }
1195
1652
 
1196
1653
  //#endregion
@@ -1828,38 +2285,38 @@ const defaultPluginRenaming = {
1828
2285
  */
1829
2286
  function so1ve(options = {}, ...userConfigs) {
1830
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;
1831
- const configs = [];
2288
+ const configs$1 = [];
1832
2289
  if (enableGitignore) if (typeof enableGitignore === "boolean") {
1833
- if (fs.existsSync(".gitignore")) configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
1834
- } else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1835
- configs.push(ignores(userIgnores), javascript({ overrides: getOverrides(options, "javascript") }), comments(), node(), onlyError(), promise(), sortImports(), imports(), unicorn(), command());
1836
- 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({
1837
2294
  json: options.jsonc !== false,
1838
2295
  yaml: options.yaml !== false,
1839
2296
  ...typeof enablePnpm === "boolean" ? {} : enablePnpm
1840
2297
  }));
1841
2298
  if (enableVue) componentExts.push("vue");
1842
- if (options.html ?? true) configs.push(html());
1843
- if (enableTypeScript) configs.push(typescript({
2299
+ if (options.html ?? true) configs$1.push(html());
2300
+ if (enableTypeScript) configs$1.push(typescript({
1844
2301
  componentExts,
1845
2302
  overrides: getOverrides(options, "typescript")
1846
2303
  }));
1847
- if (options.test ?? true) configs.push(test({ overrides: getOverrides(options, "test") }));
1848
- if (enableAstro) configs.push(astro({ overrides: getOverrides(options, "astro") }));
1849
- 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({
1850
2307
  overrides: getOverrides(options, "vue"),
1851
2308
  typescript: !!enableTypeScript
1852
2309
  }));
1853
- if (enableSolid) configs.push(solid({
2310
+ if (enableSolid) configs$1.push(solid({
1854
2311
  overrides: getOverrides(options, "solid"),
1855
2312
  typescript: !!enableTypeScript
1856
2313
  }));
1857
- if (options.formatting ?? true) configs.push(formatting(options));
1858
- if (options.perfectionist ?? true) configs.push(perfectionist());
1859
- if (options.jsonc ?? true) configs.push(jsonc());
1860
- if (options.toml ?? true) configs.push(toml({ overrides: getOverrides(options, "toml") }));
1861
- if (options.yaml ?? true) configs.push(yaml({ overrides: getOverrides(options, "yaml") }));
1862
- 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({
1863
2320
  componentExts,
1864
2321
  overrides: getOverrides(options, "mdx")
1865
2322
  }));
@@ -1867,8 +2324,8 @@ function so1ve(options = {}, ...userConfigs) {
1867
2324
  if (key in options) acc[key] = options[key];
1868
2325
  return acc;
1869
2326
  }, {});
1870
- if (Object.keys(fusedConfig).length > 0) configs.push([fusedConfig]);
1871
- 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);
1872
2329
  }
1873
2330
  function getOverrides(options, key) {
1874
2331
  const sub = typeof options[key] === "boolean" ? {} : options[key] ?? {};
@@ -1879,4 +2336,4 @@ function getOverrides(options, key) {
1879
2336
  }
1880
2337
 
1881
2338
  //#endregion
1882
- 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.24.0",
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.24.0",
80
- "@so1ve/eslint-plugin-sort-imports": "3.24.0"
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": {