@bastidood/eslint-config 0.1.0 → 0.2.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/compose/index.mjs +6 -6
- package/dist/{convert-CYKE8SNU.mjs → convert-axs1VQcN.mjs} +102 -80
- package/dist/core.mjs +4 -2
- package/dist/jsdoc.mjs +1 -1
- package/dist/node.mjs +1 -1
- package/dist/promise.mjs +1 -1
- package/dist/unicorn.mjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/package.json +5 -4
package/dist/compose/index.mjs
CHANGED
|
@@ -13,12 +13,12 @@ var RestrictionLists = class RestrictionLists {
|
|
|
13
13
|
#properties = ["error"];
|
|
14
14
|
#syntax = ["error"];
|
|
15
15
|
/** Append every list of an entry point's restrictions. */
|
|
16
|
-
append(
|
|
17
|
-
appendAll(this.#imports.paths,
|
|
18
|
-
appendAll(this.#imports.patterns,
|
|
19
|
-
appendAll(this.#globals,
|
|
20
|
-
appendAll(this.#properties,
|
|
21
|
-
appendAll(this.#syntax,
|
|
16
|
+
append({ importPaths, importPatterns, globals, properties, syntax }) {
|
|
17
|
+
appendAll(this.#imports.paths, importPaths);
|
|
18
|
+
appendAll(this.#imports.patterns, importPatterns);
|
|
19
|
+
appendAll(this.#globals, globals);
|
|
20
|
+
appendAll(this.#properties, properties);
|
|
21
|
+
appendAll(this.#syntax, syntax);
|
|
22
22
|
}
|
|
23
23
|
/** Copy these lists so that a scoped override can extend them without changing the top-level rules. */
|
|
24
24
|
copy() {
|
|
@@ -10,6 +10,9 @@ const CORE = {
|
|
|
10
10
|
jsPlugins: [{
|
|
11
11
|
name: "eslint-js",
|
|
12
12
|
specifier: "oxlint-plugin-eslint"
|
|
13
|
+
}, {
|
|
14
|
+
name: "slopstopper",
|
|
15
|
+
specifier: "@bastidood/eslint-plugin-slopstopper"
|
|
13
16
|
}],
|
|
14
17
|
categories: {
|
|
15
18
|
correctness: "error",
|
|
@@ -271,6 +274,28 @@ const CORE = {
|
|
|
271
274
|
radix: "error",
|
|
272
275
|
"require-unicode-regexp": "error",
|
|
273
276
|
"require-yield": "error",
|
|
277
|
+
"slopstopper/destructure-on-sight": "error",
|
|
278
|
+
"slopstopper/handle-or-rethrow": "error",
|
|
279
|
+
"slopstopper/merge-exclusive-branches": "error",
|
|
280
|
+
"slopstopper/needless-type-intersection": "error",
|
|
281
|
+
"slopstopper/no-alias-object-type": "error",
|
|
282
|
+
"slopstopper/no-equality-chain": "error",
|
|
283
|
+
"slopstopper/no-inferrable-return-type": "error",
|
|
284
|
+
"slopstopper/no-multiple-optional-parameters": "error",
|
|
285
|
+
"slopstopper/no-negated-group": "error",
|
|
286
|
+
"slopstopper/no-negated-quantifier-callback": "error",
|
|
287
|
+
"slopstopper/no-plain-template-literal": "error",
|
|
288
|
+
"slopstopper/no-positional-scalars": "error",
|
|
289
|
+
"slopstopper/no-private-modifier": "error",
|
|
290
|
+
"slopstopper/no-temporary-access": "error",
|
|
291
|
+
"slopstopper/no-type-predicates": "error",
|
|
292
|
+
"slopstopper/prefer-class-over-factory": "error",
|
|
293
|
+
"slopstopper/prefer-de-morgan": "error",
|
|
294
|
+
"slopstopper/prefer-prefix-increment": "error",
|
|
295
|
+
"slopstopper/prefer-switch": "error",
|
|
296
|
+
"slopstopper/prefer-typeof-undefined": "error",
|
|
297
|
+
"slopstopper/prefer-while-true": "error",
|
|
298
|
+
"slopstopper/stepdown-order": "error",
|
|
274
299
|
"sort-keys": "off",
|
|
275
300
|
"symbol-description": "error",
|
|
276
301
|
"typescript/adjacent-overload-signatures": "error",
|
|
@@ -400,7 +425,7 @@ const CORE = {
|
|
|
400
425
|
"typescript/switch-exhaustiveness-check": ["error", {
|
|
401
426
|
allowDefaultCaseForExhaustiveSwitch: false,
|
|
402
427
|
considerDefaultExhaustiveForUnions: false,
|
|
403
|
-
requireDefaultForNonUnion:
|
|
428
|
+
requireDefaultForNonUnion: false
|
|
404
429
|
}],
|
|
405
430
|
"typescript/triple-slash-reference": "error",
|
|
406
431
|
"typescript/unbound-method": "error",
|
|
@@ -431,15 +456,12 @@ const CORE = {
|
|
|
431
456
|
message: "Read environment variables only in the entry point: validate them there and pass the values as explicit parameters. Opt the entry point out with a file-level disable comment."
|
|
432
457
|
}],
|
|
433
458
|
syntax: [{
|
|
434
|
-
selector: "[accessibility=\"private\"]:not(MethodDefinition[kind=\"constructor\"])",
|
|
435
|
-
message: "Use an ECMAScript `#private` member instead of the TypeScript `private` modifier."
|
|
436
|
-
}, {
|
|
437
459
|
selector: "UnaryExpression[operator=\"void\"][argument.type=\"Literal\"]:not(:matches(CallExpression, NewExpression) > UnaryExpression.arguments)",
|
|
438
460
|
message: "Do not write `void 0` to produce `undefined`: omit the absent value by conditionally inserting the property (as `exactOptionalPropertyTypes` requires). `void 0` is allowed only as an argument to a parameter that cannot be omitted and is explicitly typed to accept `undefined`."
|
|
439
461
|
}]
|
|
440
462
|
}
|
|
441
463
|
};
|
|
442
|
-
// ../../node_modules/.pnpm/eslint-plugin-oxlint@1.90.
|
|
464
|
+
// ../../node_modules/.pnpm/eslint-plugin-oxlint@1.90.0_oxlint@1.90.0_oxlint-tsgolint@7.0.2005_/node_modules/eslint-plugin-oxlint/dist/generated/rules-by-category.mjs
|
|
443
465
|
const pedanticRules = {
|
|
444
466
|
"accessor-pairs": "off",
|
|
445
467
|
"array-callback-return": "off",
|
|
@@ -1362,7 +1384,7 @@ const restrictionTypeAwareRules = {
|
|
|
1362
1384
|
"@typescript-eslint/promise-function-async": "off",
|
|
1363
1385
|
"@typescript-eslint/use-unknown-in-catch-callback-variable": "off"
|
|
1364
1386
|
};
|
|
1365
|
-
// ../../node_modules/.pnpm/eslint-plugin-oxlint@1.90.
|
|
1387
|
+
// ../../node_modules/.pnpm/eslint-plugin-oxlint@1.90.0_oxlint@1.90.0_oxlint-tsgolint@7.0.2005_/node_modules/eslint-plugin-oxlint/dist/generated/rules-by-scope.mjs
|
|
1366
1388
|
const reactHooksRules = {
|
|
1367
1389
|
"react-hooks/capitalized-calls": "off",
|
|
1368
1390
|
"react-hooks/error-boundaries": "off",
|
|
@@ -1407,44 +1429,37 @@ const REACT_PERF = ["react-perf"];
|
|
|
1407
1429
|
const TYPESCRIPT = ["@typescript-eslint"];
|
|
1408
1430
|
const UNICORN = ["unicorn"];
|
|
1409
1431
|
const VITEST = ["vitest"];
|
|
1410
|
-
/** ESLint
|
|
1411
|
-
function
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
case "promise": return PROMISE;
|
|
1419
|
-
case "react": return REACT;
|
|
1420
|
-
case "react-perf": return REACT_PERF;
|
|
1421
|
-
case "typescript": return TYPESCRIPT;
|
|
1422
|
-
case "unicorn": return UNICORN;
|
|
1423
|
-
case "vitest": return VITEST;
|
|
1424
|
-
default: return null;
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
/**
|
|
1428
|
-
* Whether ESLint can run a rule, given its ESLint name. The conversion prunes unsupported rules: Oxlint-only rules,
|
|
1429
|
-
* and rules or options that the ESLint 10 plugins lack.
|
|
1430
|
-
*/
|
|
1431
|
-
function isSupportedInEslint(eslintName) {
|
|
1432
|
-
switch (eslintName) {
|
|
1433
|
-
case "import/consistent-type-specifier-style": return false;
|
|
1434
|
-
default: return !eslintName.startsWith("oxc/");
|
|
1432
|
+
/** Write the ESLint equivalents of explicitly configured Oxlint rules, skipping rules that ESLint cannot run. */
|
|
1433
|
+
function writeEslintRules(target, rules) {
|
|
1434
|
+
for (const name in rules) {
|
|
1435
|
+
if (!Object.hasOwn(rules, name)) continue;
|
|
1436
|
+
const rule = rules[name];
|
|
1437
|
+
if (typeof rule === "undefined") continue;
|
|
1438
|
+
const eslintName = toEslintRuleName(name);
|
|
1439
|
+
if (isSupportedInEslint(eslintName)) target[eslintName] = toEslintRuleEntry(rule);
|
|
1435
1440
|
}
|
|
1436
1441
|
}
|
|
1437
|
-
/**
|
|
1438
|
-
function
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
+
/** Translate an Oxlint rule name into the name of the same rule in ESLint and its plugins. */
|
|
1443
|
+
function toEslintRuleName(name) {
|
|
1444
|
+
const separator = name.indexOf("/");
|
|
1445
|
+
if (separator === -1) return name;
|
|
1446
|
+
const rule = name.slice(separator + 1);
|
|
1447
|
+
switch (name.slice(0, separator)) {
|
|
1448
|
+
case "eslint-js": return rule;
|
|
1449
|
+
case "typescript": return `@typescript-eslint/${rule}`;
|
|
1450
|
+
case "node": return `n/${rule}`;
|
|
1451
|
+
case "unicorn": return renamedInEslint(name);
|
|
1452
|
+
case "react": {
|
|
1453
|
+
const hook = `react-hooks/${rule}`;
|
|
1454
|
+
return Object.hasOwn(reactHooksRules, hook) ? hook : name;
|
|
1455
|
+
}
|
|
1456
|
+
default: return name;
|
|
1442
1457
|
}
|
|
1443
1458
|
}
|
|
1444
|
-
function
|
|
1445
|
-
|
|
1446
|
-
return separator === -1 ? "eslint" : eslintName.slice(0, separator);
|
|
1459
|
+
function toEslintRuleEntry(rule) {
|
|
1460
|
+
return Array.isArray(rule) ? [toEslintSeverity(rule[0]), ...rule.values().drop(1)] : toEslintSeverity(rule);
|
|
1447
1461
|
}
|
|
1462
|
+
const CATEGORY_INDEX = indexCategories();
|
|
1448
1463
|
/** Index the published category lists once: category, then ESLint namespace, then rule names. */
|
|
1449
1464
|
function indexCategories() {
|
|
1450
1465
|
const sources = [
|
|
@@ -1471,50 +1486,25 @@ function indexCategories() {
|
|
|
1471
1486
|
}
|
|
1472
1487
|
return index;
|
|
1473
1488
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
case "typescript": return `@typescript-eslint/${rule}`;
|
|
1483
|
-
case "node": return `n/${rule}`;
|
|
1484
|
-
case "unicorn": return renamedInEslint(name);
|
|
1485
|
-
case "react": {
|
|
1486
|
-
const hook = `react-hooks/${rule}`;
|
|
1487
|
-
return Object.hasOwn(reactHooksRules, hook) ? hook : name;
|
|
1488
|
-
}
|
|
1489
|
-
default: return name;
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
function toEslintSeverity(severity) {
|
|
1493
|
-
switch (severity) {
|
|
1494
|
-
case "deny":
|
|
1495
|
-
case "error": return "error";
|
|
1496
|
-
case "allow":
|
|
1497
|
-
case "off": return "off";
|
|
1498
|
-
case "warn": return "warn";
|
|
1499
|
-
default: switch (severity) {
|
|
1500
|
-
case 0:
|
|
1501
|
-
case 1:
|
|
1502
|
-
case 2: return severity;
|
|
1503
|
-
default: throw new UnsupportedSeverityError(severity);
|
|
1504
|
-
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Whether ESLint can run a rule, given its ESLint name. The conversion prunes unsupported rules: Oxlint-only rules,
|
|
1491
|
+
* and rules or options that the ESLint 10 plugins lack.
|
|
1492
|
+
*/
|
|
1493
|
+
function isSupportedInEslint(eslintName) {
|
|
1494
|
+
switch (eslintName) {
|
|
1495
|
+
case "import/consistent-type-specifier-style": return false;
|
|
1496
|
+
default: return !eslintName.startsWith("oxc/");
|
|
1505
1497
|
}
|
|
1506
1498
|
}
|
|
1507
|
-
function
|
|
1508
|
-
|
|
1499
|
+
function namespaceOf(eslintName) {
|
|
1500
|
+
const separator = eslintName.lastIndexOf("/");
|
|
1501
|
+
return separator === -1 ? "eslint" : eslintName.slice(0, separator);
|
|
1509
1502
|
}
|
|
1510
|
-
/**
|
|
1511
|
-
function
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
if (typeof rule === "undefined") continue;
|
|
1516
|
-
const eslintName = toEslintRuleName(name);
|
|
1517
|
-
if (isSupportedInEslint(eslintName)) target[eslintName] = toEslintRuleEntry(rule);
|
|
1503
|
+
/** Rename the rules that an ESLint 10 plugin publishes under a different name than Oxlint's `eslint-plugin-oxlint` lists. */
|
|
1504
|
+
function renamedInEslint(eslintName) {
|
|
1505
|
+
switch (eslintName) {
|
|
1506
|
+
case "unicorn/no-array-for-each": return "unicorn/no-for-each";
|
|
1507
|
+
default: return eslintName;
|
|
1518
1508
|
}
|
|
1519
1509
|
}
|
|
1520
1510
|
/**
|
|
@@ -1558,4 +1548,36 @@ function writeNamespaceRules(target, byNamespace, plugins, severity) {
|
|
|
1558
1548
|
}
|
|
1559
1549
|
}
|
|
1560
1550
|
}
|
|
1551
|
+
/** ESLint rule namespaces that an Oxlint plugin covers. */
|
|
1552
|
+
function namespacesOf(plugin) {
|
|
1553
|
+
switch (plugin) {
|
|
1554
|
+
case "eslint": return ESLINT;
|
|
1555
|
+
case "import": return IMPORT;
|
|
1556
|
+
case "jsdoc": return JSDOC;
|
|
1557
|
+
case "jsx-a11y": return JSX_A11Y;
|
|
1558
|
+
case "node": return NODE;
|
|
1559
|
+
case "promise": return PROMISE;
|
|
1560
|
+
case "react": return REACT;
|
|
1561
|
+
case "react-perf": return REACT_PERF;
|
|
1562
|
+
case "typescript": return TYPESCRIPT;
|
|
1563
|
+
case "unicorn": return UNICORN;
|
|
1564
|
+
case "vitest": return VITEST;
|
|
1565
|
+
default: return null;
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
function toEslintSeverity(severity) {
|
|
1569
|
+
switch (severity) {
|
|
1570
|
+
case "deny":
|
|
1571
|
+
case "error": return "error";
|
|
1572
|
+
case "allow":
|
|
1573
|
+
case "off": return "off";
|
|
1574
|
+
case "warn": return "warn";
|
|
1575
|
+
default: switch (severity) {
|
|
1576
|
+
case 0:
|
|
1577
|
+
case 1:
|
|
1578
|
+
case 2: return severity;
|
|
1579
|
+
default: throw new UnsupportedSeverityError(severity);
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1561
1583
|
export { CORE as i, writeEslintRules as n, writeExtensionRules as r, writeCategoryRules as t };
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { i as CORE$1, n as writeEslintRules, r as writeExtensionRules, t as writeCategoryRules } from "./convert-
|
|
1
|
+
import { i as CORE$1, n as writeEslintRules, r as writeExtensionRules, t as writeCategoryRules } from "./convert-axs1VQcN.mjs";
|
|
2
|
+
import SLOPSTOPPER from "@bastidood/eslint-plugin-slopstopper";
|
|
2
3
|
import { importX } from "eslint-plugin-import-x";
|
|
3
4
|
import tseslint from "typescript-eslint";
|
|
4
5
|
// src/core.ts
|
|
@@ -22,7 +23,8 @@ for (const { files, rules } of OVERRIDES) {
|
|
|
22
23
|
}
|
|
23
24
|
const PLUGIN_DEFINITIONS = {
|
|
24
25
|
"@typescript-eslint": TYPESCRIPT_ESLINT,
|
|
25
|
-
import: importX
|
|
26
|
+
import: importX,
|
|
27
|
+
slopstopper: SLOPSTOPPER
|
|
26
28
|
};
|
|
27
29
|
const RESTRICTIONS = {
|
|
28
30
|
...CORE$1.restrictions,
|
package/dist/jsdoc.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as CORE, n as writeEslintRules, t as writeCategoryRules } from "./convert-
|
|
1
|
+
import { i as CORE, n as writeEslintRules, t as writeCategoryRules } from "./convert-axs1VQcN.mjs";
|
|
2
2
|
import jsdocPlugin from "eslint-plugin-jsdoc";
|
|
3
3
|
// ../oxlint/src/jsdoc.ts
|
|
4
4
|
const JSDOC$1 = { config: {
|
package/dist/node.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as CORE, n as writeEslintRules, t as writeCategoryRules } from "./convert-
|
|
1
|
+
import { i as CORE, n as writeEslintRules, t as writeCategoryRules } from "./convert-axs1VQcN.mjs";
|
|
2
2
|
import nodePlugin from "eslint-plugin-n";
|
|
3
3
|
// ../oxlint/src/node.ts
|
|
4
4
|
/** Node.js rules for code that runs on Node.js. */
|
package/dist/promise.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as CORE, n as writeEslintRules, t as writeCategoryRules } from "./convert-
|
|
1
|
+
import { i as CORE, n as writeEslintRules, t as writeCategoryRules } from "./convert-axs1VQcN.mjs";
|
|
2
2
|
import promisePlugin from "eslint-plugin-promise";
|
|
3
3
|
// ../oxlint/src/promise.ts
|
|
4
4
|
const PROMISE$1 = { config: {
|
package/dist/unicorn.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as CORE, n as writeEslintRules, t as writeCategoryRules } from "./convert-
|
|
1
|
+
import { i as CORE, n as writeEslintRules, t as writeCategoryRules } from "./convert-axs1VQcN.mjs";
|
|
2
2
|
import unicornPlugin from "eslint-plugin-unicorn";
|
|
3
3
|
// ../oxlint/src/unicorn.ts
|
|
4
4
|
const UNICORN$1 = { config: {
|
package/dist/vitest.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as CORE, n as writeEslintRules, t as writeCategoryRules } from "./convert-
|
|
1
|
+
import { i as CORE, n as writeEslintRules, t as writeCategoryRules } from "./convert-axs1VQcN.mjs";
|
|
2
2
|
import vitestPlugin from "@vitest/eslint-plugin";
|
|
3
3
|
// ../oxlint/src/vitest.ts
|
|
4
4
|
const VITEST$1 = { config: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastidood/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Strict baseline ESLint configuration generated from @bastidood/oxlint-config.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/BastiDood/slopstopper",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@bastidood/eslint-plugin-slopstopper": "^0.1.0",
|
|
29
30
|
"@vitest/eslint-plugin": "^1.6.28",
|
|
30
31
|
"eslint-plugin-import-x": "^4.17.1",
|
|
31
32
|
"eslint-plugin-jsdoc": "^65.4.2",
|
|
@@ -35,12 +36,12 @@
|
|
|
35
36
|
"typescript-eslint": "^8.72.1"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@bastidood/oxlint-config": "0.
|
|
39
|
-
"@bastidood/tsconfig": "0.1.
|
|
39
|
+
"@bastidood/oxlint-config": "0.2.0",
|
|
40
|
+
"@bastidood/tsconfig": "0.1.1",
|
|
40
41
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
41
42
|
"eslint": "^10.13.0",
|
|
42
43
|
"eslint-plugin-oxlint": "^1.90.0",
|
|
43
|
-
"tsdown": "^0.23.
|
|
44
|
+
"tsdown": "^0.23.4",
|
|
44
45
|
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|