@moso/eslint-config 3.4.0 → 3.6.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/README.md +86 -1
- package/dist/index.d.mts +1729 -544
- package/dist/index.mjs +492 -266
- package/package.json +41 -27
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { AST_NODE_TYPES, AST_TOKEN_TYPES, ESLintUtils } from "@typescript-eslint
|
|
|
5
5
|
import { isIdentifier } from "@typescript-eslint/utils/ast-utils";
|
|
6
6
|
import globals from "globals";
|
|
7
7
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
8
|
-
|
|
8
|
+
// package.json
|
|
9
9
|
var peerDependenciesMeta = {
|
|
10
10
|
"@eslint-react/eslint-plugin": { "optional": true },
|
|
11
11
|
"@next/eslint-plugin-next": { "optional": true },
|
|
@@ -17,12 +17,13 @@ var peerDependenciesMeta = {
|
|
|
17
17
|
"eslint-plugin-react-hooks": { "optional": true },
|
|
18
18
|
"eslint-plugin-react-refresh": { "optional": true },
|
|
19
19
|
"eslint-plugin-react-you-might-not-need-an-effect": { "optional": true },
|
|
20
|
+
"eslint-plugin-svelte": { "optional": true },
|
|
20
21
|
"eslint-plugin-vue": { "optional": true },
|
|
21
22
|
"eslint-plugin-vuejs-accessibility": { "optional": true },
|
|
23
|
+
"svelte-eslint-parser": { "optional": true },
|
|
22
24
|
"typescript": { "optional": true }
|
|
23
25
|
};
|
|
24
|
-
|
|
25
|
-
//#region src/utils.ts
|
|
26
|
+
// src/utils.ts
|
|
26
27
|
/**
|
|
27
28
|
* Resolve and flatten any mix of (awaitable) config items or arrays
|
|
28
29
|
* into a single flat array of config items.
|
|
@@ -202,8 +203,7 @@ const vueInlineElements = [
|
|
|
202
203
|
"var",
|
|
203
204
|
"video"
|
|
204
205
|
];
|
|
205
|
-
|
|
206
|
-
//#region src/tools.ts
|
|
206
|
+
// src/tools.ts
|
|
207
207
|
const scopeURL = import.meta.dirname;
|
|
208
208
|
/**
|
|
209
209
|
* The optional peer dependencies in a self-maintained list.
|
|
@@ -248,8 +248,7 @@ const loadPackages = async (packageIds) => {
|
|
|
248
248
|
}
|
|
249
249
|
return Promise.all(packageIds.map(async (id) => interopDefault(import(id))));
|
|
250
250
|
};
|
|
251
|
-
|
|
252
|
-
//#region src/configs/astro.ts
|
|
251
|
+
// src/configs/astro.ts
|
|
253
252
|
const astro = async (options) => {
|
|
254
253
|
const { a11y, files, lessOpinionated, overrides, overridesA11y, parserOptions, stylistic, typescript } = options;
|
|
255
254
|
const stylisticEnabled = stylistic !== false;
|
|
@@ -311,15 +310,14 @@ const astro = async (options) => {
|
|
|
311
310
|
}
|
|
312
311
|
}];
|
|
313
312
|
};
|
|
314
|
-
|
|
315
|
-
//#region src/configs/baseline.ts
|
|
313
|
+
// src/configs/baseline.ts
|
|
316
314
|
const defaultIgnoreFeatures = ["functions-caller-arguments"];
|
|
317
315
|
const baseline = async (options) => {
|
|
318
|
-
const { baseline, files, filesTypeAware, hasDOM, ignoreFeatures, ignoreNodeTypes, ignoresTypeAware, overrides, overridesTypeAware, parserOptions, projectRoot, typescript } = options;
|
|
316
|
+
const { baseline = "widely", files, filesTypeAware, hasDOM, ignoreFeatures, ignoreNodeTypes, ignoresTypeAware, overrides, overridesTypeAware, parserOptions, projectRoot, typescript } = options;
|
|
319
317
|
const isTypeAware = typescript && typeof projectRoot === "string" && parserOptions?.projectService !== false;
|
|
320
318
|
const [baselinePlugin] = await loadPackages(["eslint-plugin-baseline-js"]);
|
|
321
319
|
const baselineRule = (typeAware) => ({ "baseline-js/use-baseline": ["warn", {
|
|
322
|
-
available: baseline
|
|
320
|
+
available: baseline,
|
|
323
321
|
ignoreFeatures: [...defaultIgnoreFeatures, ...ignoreFeatures ?? []],
|
|
324
322
|
ignoreNodeTypes,
|
|
325
323
|
includeJsBuiltins: { preset: typeAware ? "type-aware" : "auto" },
|
|
@@ -349,8 +347,7 @@ const baseline = async (options) => {
|
|
|
349
347
|
}] : []
|
|
350
348
|
];
|
|
351
349
|
};
|
|
352
|
-
|
|
353
|
-
//#region src/globs.ts
|
|
350
|
+
// src/globs.ts
|
|
354
351
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
355
352
|
const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
356
353
|
const GLOB_JS = "**/*.?([cm])js";
|
|
@@ -374,6 +371,8 @@ const GLOB_JSONC = "**/*.jsonc";
|
|
|
374
371
|
const GLOB_ASTRO = "**/*.astro";
|
|
375
372
|
const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
376
373
|
const GLOB_MARKDOWN = "**/*.md";
|
|
374
|
+
const GLOB_SVELTE = "**/*.svelte?(.{js,ts})";
|
|
375
|
+
const GLOB_SVELTE_MODULE = "**/*.svelte.{js,ts}";
|
|
377
376
|
const GLOB_TOML = "**/*.toml";
|
|
378
377
|
const GLOB_VUE = "**/*.vue";
|
|
379
378
|
const GLOB_YAML = "**/*.y?(a)ml";
|
|
@@ -416,6 +415,7 @@ const GLOB_EXCLUDE = [
|
|
|
416
415
|
"**/.nitro",
|
|
417
416
|
"**/.nuxt",
|
|
418
417
|
"**/.output",
|
|
418
|
+
"**/.svelte-kit",
|
|
419
419
|
"**/.temp",
|
|
420
420
|
"**/.tmp",
|
|
421
421
|
"**/.vercel",
|
|
@@ -433,8 +433,7 @@ const GLOB_EXCLUDE = [
|
|
|
433
433
|
GLOB_CSS_IN_JS,
|
|
434
434
|
...GLOB_AI
|
|
435
435
|
];
|
|
436
|
-
|
|
437
|
-
//#region src/configs/disables.ts
|
|
436
|
+
// src/configs/disables.ts
|
|
438
437
|
const disables = async (functionalEnabled = false) => {
|
|
439
438
|
const [functionalPlugin] = functionalEnabled ? await loadPackages(["eslint-plugin-functional"]) : [void 0];
|
|
440
439
|
return [
|
|
@@ -508,6 +507,7 @@ const disables = async (functionalEnabled = false) => {
|
|
|
508
507
|
GLOB_ASTRO_TS,
|
|
509
508
|
GLOB_DTS,
|
|
510
509
|
GLOB_JSX,
|
|
510
|
+
GLOB_SVELTE,
|
|
511
511
|
GLOB_TS,
|
|
512
512
|
GLOB_TSX,
|
|
513
513
|
GLOB_VUE
|
|
@@ -615,8 +615,7 @@ const disables = async (functionalEnabled = false) => {
|
|
|
615
615
|
}
|
|
616
616
|
];
|
|
617
617
|
};
|
|
618
|
-
|
|
619
|
-
//#region src/configs/e18e.ts
|
|
618
|
+
// src/configs/e18e.ts
|
|
620
619
|
const e18e = async (options) => {
|
|
621
620
|
const { isInEditor, lessOpinionated, mode, modernization, moduleReplacements, overrides, performanceImprovements } = options;
|
|
622
621
|
const [e18ePlugin] = await loadPackages(["@e18e/eslint-plugin"]);
|
|
@@ -643,8 +642,7 @@ const e18e = async (options) => {
|
|
|
643
642
|
}
|
|
644
643
|
}];
|
|
645
644
|
};
|
|
646
|
-
|
|
647
|
-
//#region src/configs/eslint-comments.ts
|
|
645
|
+
// src/configs/eslint-comments.ts
|
|
648
646
|
const comments = async (options) => {
|
|
649
647
|
const { overrides } = options;
|
|
650
648
|
const [eslintComments] = await loadPackages(["@eslint-community/eslint-plugin-eslint-comments"]);
|
|
@@ -658,10 +656,10 @@ const comments = async (options) => {
|
|
|
658
656
|
}
|
|
659
657
|
}];
|
|
660
658
|
};
|
|
661
|
-
|
|
662
|
-
//#region src/configs/functional.ts
|
|
659
|
+
// src/configs/functional.ts
|
|
663
660
|
const functional = async (options) => {
|
|
664
|
-
const { filesTypeAware, functionalEnforcement, ignoreNamePattern, mode, overrides, stylistic } = options;
|
|
661
|
+
const { filesTypeAware, functionalEnforcement, ignoreNamePattern, mode, overrides, parserOptions, stylistic } = options;
|
|
662
|
+
const isTypeAware = parserOptions.projectService !== false;
|
|
665
663
|
const [functionalPlugin] = await loadPackages(["eslint-plugin-functional"]);
|
|
666
664
|
const stylisticEnabled = stylistic !== false;
|
|
667
665
|
const commonRules = {
|
|
@@ -758,7 +756,7 @@ const functional = async (options) => {
|
|
|
758
756
|
}
|
|
759
757
|
}, {
|
|
760
758
|
name: "moso/functional/disable-type-aware",
|
|
761
|
-
ignores: filesTypeAware,
|
|
759
|
+
...isTypeAware && { ignores: filesTypeAware },
|
|
762
760
|
rules: {
|
|
763
761
|
...(assert.ok(!Array.isArray(functionalPlugin.configs.disableTypeChecked)), functionalPlugin.configs.disableTypeChecked.rules),
|
|
764
762
|
"functional/no-let": ["error", {
|
|
@@ -768,8 +766,7 @@ const functional = async (options) => {
|
|
|
768
766
|
}
|
|
769
767
|
}];
|
|
770
768
|
};
|
|
771
|
-
|
|
772
|
-
//#region src/configs/ignores.ts
|
|
769
|
+
// src/configs/ignores.ts
|
|
773
770
|
const ignores = async (options) => {
|
|
774
771
|
const { gitignore = true, ignoreTypeScript, userIgnores } = options;
|
|
775
772
|
const [eslintConfigFlatGitIgnore] = await loadPackages(["eslint-config-flat-gitignore"]);
|
|
@@ -784,8 +781,7 @@ const ignores = async (options) => {
|
|
|
784
781
|
}));
|
|
785
782
|
return mut_configs;
|
|
786
783
|
};
|
|
787
|
-
|
|
788
|
-
//#region src/rules/utils.ts
|
|
784
|
+
// src/rules/utils.ts
|
|
789
785
|
/**
|
|
790
786
|
* Typed rule factory for every rule in this plugin.
|
|
791
787
|
*
|
|
@@ -894,7 +890,7 @@ const functionLikeTypes = /* @__PURE__ */ new Set([
|
|
|
894
890
|
/**
|
|
895
891
|
* Whether `node` is a function declaration, function expression, or arrow function.
|
|
896
892
|
*/
|
|
897
|
-
const isFunctionLike = (node) => node
|
|
893
|
+
const isFunctionLike = (node) => node !== null && node !== void 0 && functionLikeTypes.has(node.type);
|
|
898
894
|
/**
|
|
899
895
|
* Whether `node` is an identifier matching `name` given as an exact string,
|
|
900
896
|
* a list of accepted names, or a predicate over the identifier's name.
|
|
@@ -932,8 +928,7 @@ const makeProgramListener = (pattern, onReport) => ({ Program: (program) => {
|
|
|
932
928
|
* Lets a derived value be computed inline where a statement would otherwise be needed.
|
|
933
929
|
*/
|
|
934
930
|
const wrap = (input, callback) => callback(input);
|
|
935
|
-
|
|
936
|
-
//#region src/rules/avoid-barrel-files/avoid-barrel-files.ts
|
|
931
|
+
// src/rules/avoid-barrel-files/avoid-barrel-files.ts
|
|
937
932
|
const declarationTypes = /* @__PURE__ */ new Set([
|
|
938
933
|
AST_NODE_TYPES.ClassDeclaration,
|
|
939
934
|
AST_NODE_TYPES.FunctionDeclaration,
|
|
@@ -958,9 +953,9 @@ const ruleAvoidBarrelFiles = createRule({
|
|
|
958
953
|
} },
|
|
959
954
|
additionalProperties: false
|
|
960
955
|
}],
|
|
961
|
-
messages: { avoidBarrelFiles: "Barrel file detected." }
|
|
956
|
+
messages: { avoidBarrelFiles: "Barrel file detected." },
|
|
957
|
+
defaultOptions: [{ amountOfExportsToConsiderModuleAsBarrel: 3 }]
|
|
962
958
|
},
|
|
963
|
-
defaultOptions: [{ amountOfExportsToConsiderModuleAsBarrel: 3 }],
|
|
964
959
|
create: (context, [{ amountOfExportsToConsiderModuleAsBarrel }]) => ({ Program(node) {
|
|
965
960
|
const { declarationCount, exportCount } = node.body.reduce(({ declarationCount, exportCount }, statement) => {
|
|
966
961
|
if (statement.type === AST_NODE_TYPES.VariableDeclaration) return {
|
|
@@ -1003,8 +998,7 @@ const ruleAvoidBarrelFiles = createRule({
|
|
|
1003
998
|
});
|
|
1004
999
|
} })
|
|
1005
1000
|
});
|
|
1006
|
-
|
|
1007
|
-
//#region src/rules/no-bidi/no-bidi.ts
|
|
1001
|
+
// src/rules/no-bidi/no-bidi.ts
|
|
1008
1002
|
const BIDI_PATTERN = /[\u{61C}\u{202A}-\u{202E}\u{2066}-\u{2069}]/u;
|
|
1009
1003
|
const BIDI_PATTERN_GLOBAL = new RegExp(BIDI_PATTERN.source, "gu");
|
|
1010
1004
|
const ruleNoBidi = createRule({
|
|
@@ -1032,8 +1026,7 @@ const ruleNoBidi = createRule({
|
|
|
1032
1026
|
});
|
|
1033
1027
|
})
|
|
1034
1028
|
});
|
|
1035
|
-
|
|
1036
|
-
//#region src/rules/no-force-cast-via-top-type/no-force-cast-via-top-type.ts
|
|
1029
|
+
// src/rules/no-force-cast-via-top-type/no-force-cast-via-top-type.ts
|
|
1037
1030
|
const isTopType = (node) => node.type === AST_NODE_TYPES.TSAnyKeyword || node.type === AST_NODE_TYPES.TSUnknownKeyword;
|
|
1038
1031
|
const isCastToAnotherType = (node) => node?.type === AST_NODE_TYPES.TSAsExpression && !isTopType(node.typeAnnotation);
|
|
1039
1032
|
const ruleNoForceCastViaTopType = createRule({
|
|
@@ -1058,8 +1051,7 @@ const ruleNoForceCastViaTopType = createRule({
|
|
|
1058
1051
|
});
|
|
1059
1052
|
} })
|
|
1060
1053
|
});
|
|
1061
|
-
|
|
1062
|
-
//#region src/rules/no-import-duplicates/no-import-duplicates.ts
|
|
1054
|
+
// src/rules/no-import-duplicates/no-import-duplicates.ts
|
|
1063
1055
|
const ruleNoImportDuplicates = createRule({
|
|
1064
1056
|
name: "no-import-duplicates",
|
|
1065
1057
|
meta: {
|
|
@@ -1097,8 +1089,7 @@ const ruleNoImportDuplicates = createRule({
|
|
|
1097
1089
|
}, /* @__PURE__ */ new Set());
|
|
1098
1090
|
} })
|
|
1099
1091
|
});
|
|
1100
|
-
|
|
1101
|
-
//#region src/rules/no-import-from-dist/no-import-from-dist.ts
|
|
1092
|
+
// src/rules/no-import-from-dist/no-import-from-dist.ts
|
|
1102
1093
|
const DIST_CHECK = /\/dist(?:\/|$)/u;
|
|
1103
1094
|
const isDist = (path) => path.startsWith(".") && DIST_CHECK.test(path) || path === "dist";
|
|
1104
1095
|
const ruleNoImportFromDist = createRule({
|
|
@@ -1131,8 +1122,7 @@ const ruleNoImportFromDist = createRule({
|
|
|
1131
1122
|
}
|
|
1132
1123
|
})
|
|
1133
1124
|
});
|
|
1134
|
-
|
|
1135
|
-
//#region src/rules/no-import-node-modules-by-path/no-import-node-modules-by-path.ts
|
|
1125
|
+
// src/rules/no-import-node-modules-by-path/no-import-node-modules-by-path.ts
|
|
1136
1126
|
const ruleNoImportNodeModulesByPath = createRule({
|
|
1137
1127
|
name: "no-import-node-modules-by-path",
|
|
1138
1128
|
meta: {
|
|
@@ -1161,8 +1151,7 @@ const ruleNoImportNodeModulesByPath = createRule({
|
|
|
1161
1151
|
}
|
|
1162
1152
|
})
|
|
1163
1153
|
});
|
|
1164
|
-
|
|
1165
|
-
//#region src/rules/no-invisible-characters/no-invisible-characters.ts
|
|
1154
|
+
// src/rules/no-invisible-characters/no-invisible-characters.ts
|
|
1166
1155
|
const combinePattern = (...patterns) => {
|
|
1167
1156
|
const source = patterns.map((pattern) => pattern.source).join("");
|
|
1168
1157
|
return new RegExp(`[${source}]`, "u");
|
|
@@ -1190,9 +1179,8 @@ const ruleNoInvisibleCharacters = createRule({
|
|
|
1190
1179
|
});
|
|
1191
1180
|
})
|
|
1192
1181
|
});
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
const isRedundantVariable = (node, exit) => node ? node.type === AST_NODE_TYPES.VariableDeclaration && node.declarations.length === 1 && node.declarations[0].init !== null && isSameIdentifier(exit.argument, node.declarations[0].id) : false;
|
|
1182
|
+
// src/rules/no-redundant-variable/no-redundant-variable.ts
|
|
1183
|
+
const isRedundantVariable = (node, exit) => node?.type === AST_NODE_TYPES.VariableDeclaration && node.declarations.length === 1 && node.declarations[0].init !== null && isSameIdentifier(exit.argument, node.declarations[0].id);
|
|
1196
1184
|
const isRedundantVariableFixer = (source, variable, id, init, exit) => (fixer) => {
|
|
1197
1185
|
const replaced = getReturnExpression(init);
|
|
1198
1186
|
const modified = wrap(source.getText(replaced), (input) => {
|
|
@@ -1236,8 +1224,7 @@ const ruleNoRedundantVariables = createRule({
|
|
|
1236
1224
|
}
|
|
1237
1225
|
} })
|
|
1238
1226
|
});
|
|
1239
|
-
|
|
1240
|
-
//#region src/rules/no-string-interpolation/no-string-interpolation.ts
|
|
1227
|
+
// src/rules/no-string-interpolation/no-string-interpolation.ts
|
|
1241
1228
|
const isMultiline = ({ loc }) => loc.start.line !== loc.end.line;
|
|
1242
1229
|
const ruleNoStringInterpolation = createRule({
|
|
1243
1230
|
name: "no-string-interpolation",
|
|
@@ -1258,8 +1245,7 @@ const ruleNoStringInterpolation = createRule({
|
|
|
1258
1245
|
});
|
|
1259
1246
|
} })
|
|
1260
1247
|
});
|
|
1261
|
-
|
|
1262
|
-
//#region src/rules/no-top-level-await/no-top-level-await.ts
|
|
1248
|
+
// src/rules/no-top-level-await/no-top-level-await.ts
|
|
1263
1249
|
const ruleNoTopLevelAwait = createRule({
|
|
1264
1250
|
name: "no-top-level-await",
|
|
1265
1251
|
meta: {
|
|
@@ -1308,8 +1294,7 @@ const ruleNoTopLevelAwait = createRule({
|
|
|
1308
1294
|
};
|
|
1309
1295
|
}
|
|
1310
1296
|
});
|
|
1311
|
-
|
|
1312
|
-
//#region src/rules/no-unneeded-array-flat-map/no-unneeded-array-flat-map.ts
|
|
1297
|
+
// src/rules/no-unneeded-array-flat-map/no-unneeded-array-flat-map.ts
|
|
1313
1298
|
const ruleNoUnneededArrayFlatMap = createRule({
|
|
1314
1299
|
name: "no-unneeded-array-flat-map",
|
|
1315
1300
|
meta: {
|
|
@@ -1334,11 +1319,9 @@ const ruleNoUnneededArrayFlatMap = createRule({
|
|
|
1334
1319
|
});
|
|
1335
1320
|
} })
|
|
1336
1321
|
});
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
//#endregion
|
|
1341
|
-
//#region src/rules/prefer-early-return/prefer-early-return.ts
|
|
1322
|
+
// src/rules/package.json
|
|
1323
|
+
var version = "3.6.0";
|
|
1324
|
+
// src/rules/prefer-early-return/prefer-early-return.ts
|
|
1342
1325
|
const isTriggering = (node, maximumStatements) => {
|
|
1343
1326
|
if (node.type !== AST_NODE_TYPES.IfStatement || node.alternate !== null) return false;
|
|
1344
1327
|
const { consequent } = node;
|
|
@@ -1372,9 +1355,9 @@ const rulePreferEarlyReturns = createRule({
|
|
|
1372
1355
|
} },
|
|
1373
1356
|
additionalProperties: false
|
|
1374
1357
|
}],
|
|
1375
|
-
messages: { preferEarlyReturn: "Prefer an early return to a conditionally-wrapped function body." }
|
|
1358
|
+
messages: { preferEarlyReturn: "Prefer an early return to a conditionally-wrapped function body." },
|
|
1359
|
+
defaultOptions: [{ maximumStatements: 1 }]
|
|
1376
1360
|
},
|
|
1377
|
-
defaultOptions: [{ maximumStatements: 1 }],
|
|
1378
1361
|
create: (context, [{ maximumStatements }]) => ({ BlockStatement: ({ body, parent }) => {
|
|
1379
1362
|
if (!isFunctionLike(parent)) return;
|
|
1380
1363
|
const statement = body.at(0);
|
|
@@ -1386,8 +1369,7 @@ const rulePreferEarlyReturns = createRule({
|
|
|
1386
1369
|
});
|
|
1387
1370
|
} })
|
|
1388
1371
|
});
|
|
1389
|
-
|
|
1390
|
-
//#region src/rules/prefer-fetch/prefer-fetch.ts
|
|
1372
|
+
// src/rules/prefer-fetch/prefer-fetch.ts
|
|
1391
1373
|
const ACTIVEX_OBJECT = /xmlhttp/iu;
|
|
1392
1374
|
const HTTP_SYMBOL = "$http";
|
|
1393
1375
|
const JQUERY_SYMBOLS = ["$", "jQuery"];
|
|
@@ -1443,8 +1425,7 @@ const rulePreferFetch = createRule({
|
|
|
1443
1425
|
}
|
|
1444
1426
|
})
|
|
1445
1427
|
});
|
|
1446
|
-
|
|
1447
|
-
//#region src/rules/prefer-reduce-over-chaining/prefer-reduce-over-chaining.ts
|
|
1428
|
+
// src/rules/prefer-reduce-over-chaining/prefer-reduce-over-chaining.ts
|
|
1448
1429
|
const arrayHighOrderFunctions = /* @__PURE__ */ new Set([
|
|
1449
1430
|
"filter",
|
|
1450
1431
|
"flatMap",
|
|
@@ -1477,8 +1458,7 @@ const rulePreferReduceOverChaining = createRule({
|
|
|
1477
1458
|
});
|
|
1478
1459
|
} })
|
|
1479
1460
|
});
|
|
1480
|
-
|
|
1481
|
-
//#region src/rules/prefer-strict-number-guards/prefer-strict-number-guards.ts
|
|
1461
|
+
// src/rules/prefer-strict-number-guards/prefer-strict-number-guards.ts
|
|
1482
1462
|
const allGuards = [
|
|
1483
1463
|
"check-parse-result",
|
|
1484
1464
|
"encode-input-rule",
|
|
@@ -1581,9 +1561,9 @@ const rulePreferStrictNumberGuards = createRule({
|
|
|
1581
1561
|
guardDerivedValue: "Dividing by a calculation hides whether that calculation can be zero. Name it in a `const`, check that name for zero, then divide.",
|
|
1582
1562
|
useDirectOperands: "A nested division introduces a ratio that can round to zero. Use the direct operands instead - `a / (b / c)` is `(a * c) / b`.",
|
|
1583
1563
|
writeExplicitCondition: "`0` is falsy, so a `||` fallback silently replaces a legitimate zero. Write `value === 0 ? fallback : value` instead."
|
|
1584
|
-
}
|
|
1564
|
+
},
|
|
1565
|
+
defaultOptions: [{ guards: [...defaultGuards] }]
|
|
1585
1566
|
},
|
|
1586
|
-
defaultOptions: [{ guards: [...defaultGuards] }],
|
|
1587
1567
|
create: (context, [{ guards }]) => {
|
|
1588
1568
|
const enabled = new Set(guards);
|
|
1589
1569
|
const mut_scopes = [];
|
|
@@ -1661,8 +1641,7 @@ const rulePreferStrictNumberGuards = createRule({
|
|
|
1661
1641
|
};
|
|
1662
1642
|
}
|
|
1663
1643
|
});
|
|
1664
|
-
|
|
1665
|
-
//#region src/rules/index.ts
|
|
1644
|
+
// src/rules/index.ts
|
|
1666
1645
|
const plugin = {
|
|
1667
1646
|
meta: {
|
|
1668
1647
|
name: "@moso/eslint-plugin",
|
|
@@ -1704,8 +1683,7 @@ var rules_default = {
|
|
|
1704
1683
|
...plugin,
|
|
1705
1684
|
configs
|
|
1706
1685
|
};
|
|
1707
|
-
|
|
1708
|
-
//#region src/configs/imports.ts
|
|
1686
|
+
// src/configs/imports.ts
|
|
1709
1687
|
const imports = async (options) => {
|
|
1710
1688
|
const { files, overrides, stylistic, typescript } = options;
|
|
1711
1689
|
const [importLite] = await loadPackages(["eslint-plugin-import-lite"]);
|
|
@@ -1741,8 +1719,7 @@ const imports = async (options) => {
|
|
|
1741
1719
|
}
|
|
1742
1720
|
}] : []];
|
|
1743
1721
|
};
|
|
1744
|
-
|
|
1745
|
-
//#region src/configs/javascript.ts
|
|
1722
|
+
// src/configs/javascript.ts
|
|
1746
1723
|
const useNumberIsFinite = "Please use `Number.isFinite` instead.";
|
|
1747
1724
|
const useNumberIsNan = "Please use `Number.isNaN` instead.";
|
|
1748
1725
|
const useObjectDefineProperty = "Please use `Object.defineProperty` instead.";
|
|
@@ -2058,8 +2035,7 @@ const javascript = async (options) => {
|
|
|
2058
2035
|
}
|
|
2059
2036
|
}]];
|
|
2060
2037
|
};
|
|
2061
|
-
|
|
2062
|
-
//#region src/configs/jsdoc.ts
|
|
2038
|
+
// src/configs/jsdoc.ts
|
|
2063
2039
|
const jsdoc = async (options) => {
|
|
2064
2040
|
const { files, lessOpinionated, overrides, stylistic, typescript } = options;
|
|
2065
2041
|
const [jsdocPlugin] = await loadPackages(["eslint-plugin-jsdoc"]);
|
|
@@ -2120,7 +2096,7 @@ const jsdoc = async (options) => {
|
|
|
2120
2096
|
],
|
|
2121
2097
|
"jsdoc/valid-types": "error",
|
|
2122
2098
|
...!lessOpinionated && {
|
|
2123
|
-
"jsdoc/check-indentation": "warn",
|
|
2099
|
+
"jsdoc/check-indentation": ["warn", { allowNoSpaceAfterAsterisk: true }],
|
|
2124
2100
|
"jsdoc/no-bad-blocks": ["warn", { ignore: [
|
|
2125
2101
|
"ts-check",
|
|
2126
2102
|
"ts-expect-error",
|
|
@@ -2141,8 +2117,7 @@ const jsdoc = async (options) => {
|
|
|
2141
2117
|
}
|
|
2142
2118
|
}];
|
|
2143
2119
|
};
|
|
2144
|
-
|
|
2145
|
-
//#region src/configs/jsonc.ts
|
|
2120
|
+
// src/configs/jsonc.ts
|
|
2146
2121
|
const jsonc = async (options) => {
|
|
2147
2122
|
const { files, overrides, stylistic } = options;
|
|
2148
2123
|
const { indent = 4 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
@@ -2202,8 +2177,7 @@ const jsonc = async (options) => {
|
|
|
2202
2177
|
}
|
|
2203
2178
|
}];
|
|
2204
2179
|
};
|
|
2205
|
-
|
|
2206
|
-
//#region src/configs/jsx.ts
|
|
2180
|
+
// src/configs/jsx.ts
|
|
2207
2181
|
const jsx = async (options) => {
|
|
2208
2182
|
const { a11y, files, lessOpinionated, overrides, overridesA11y, stylistic } = options;
|
|
2209
2183
|
const [jsxA11yPlugin] = a11y ? await loadPackages(["eslint-plugin-jsx-a11y"]) : [void 0];
|
|
@@ -2266,8 +2240,7 @@ const jsx = async (options) => {
|
|
|
2266
2240
|
}
|
|
2267
2241
|
}];
|
|
2268
2242
|
};
|
|
2269
|
-
|
|
2270
|
-
//#region src/configs/nextjs.ts
|
|
2243
|
+
// src/configs/nextjs.ts
|
|
2271
2244
|
const nextjs = async (options) => {
|
|
2272
2245
|
const { files, mode, overrides, rootDir } = options;
|
|
2273
2246
|
const [nextjsPlugin] = await loadPackages(["@next/eslint-plugin-next"]);
|
|
@@ -2293,8 +2266,7 @@ const nextjs = async (options) => {
|
|
|
2293
2266
|
}
|
|
2294
2267
|
}];
|
|
2295
2268
|
};
|
|
2296
|
-
|
|
2297
|
-
//#region src/configs/node.ts
|
|
2269
|
+
// src/configs/node.ts
|
|
2298
2270
|
const npmx = (packageName) => `https://npmx.dev/package/${packageName}`;
|
|
2299
2271
|
const restricedImports = [
|
|
2300
2272
|
{
|
|
@@ -2424,8 +2396,7 @@ const node = async (options) => {
|
|
|
2424
2396
|
}] : []
|
|
2425
2397
|
];
|
|
2426
2398
|
};
|
|
2427
|
-
|
|
2428
|
-
//#region src/configs/perfectionist.ts
|
|
2399
|
+
// src/configs/perfectionist.ts
|
|
2429
2400
|
const commonOptions = {
|
|
2430
2401
|
fallbackSort: {
|
|
2431
2402
|
order: "asc",
|
|
@@ -2669,8 +2640,127 @@ const perfectionist = async (options) => {
|
|
|
2669
2640
|
}
|
|
2670
2641
|
}];
|
|
2671
2642
|
};
|
|
2672
|
-
|
|
2673
|
-
|
|
2643
|
+
// src/configs/preact.ts
|
|
2644
|
+
const preact = async (options) => {
|
|
2645
|
+
const { a11y, files, filesTypeAware, ignoresTypeAware, lessOpinionated, overrides, overridesA11y, overridesTypeAware, parserOptions, projectRoot, stylistic, typescript } = options;
|
|
2646
|
+
const [reactPlugin, reactHooksPlugin, reactRefreshPlugin] = await loadPackages([
|
|
2647
|
+
"@eslint-react/eslint-plugin",
|
|
2648
|
+
"eslint-plugin-react-hooks",
|
|
2649
|
+
"eslint-plugin-react-refresh"
|
|
2650
|
+
]);
|
|
2651
|
+
const isTypeAware = typescript && typeof projectRoot === "string" && parserOptions?.projectService !== false;
|
|
2652
|
+
const [jsxA11yPlugin] = a11y ? await loadPackages(["eslint-plugin-jsx-a11y"]) : [void 0];
|
|
2653
|
+
const stylisticEnabled = stylistic !== false;
|
|
2654
|
+
const [typescriptParser] = typescript ? await loadPackages(["@typescript-eslint/parser"]) : [void 0];
|
|
2655
|
+
return [
|
|
2656
|
+
{
|
|
2657
|
+
name: "moso/preact/setup",
|
|
2658
|
+
plugins: {
|
|
2659
|
+
"@eslint-react": memoize(reactPlugin, "@eslint-react"),
|
|
2660
|
+
"react-hooks": memoize(reactHooksPlugin, "eslint-plugin-react-hooks"),
|
|
2661
|
+
"react-refresh": memoize(reactRefreshPlugin, "eslint-plugin-react-refresh"),
|
|
2662
|
+
...jsxA11yPlugin && { "jsx-a11y": memoize(jsxA11yPlugin, "eslint-plugin-jsx-a11y") }
|
|
2663
|
+
}
|
|
2664
|
+
},
|
|
2665
|
+
{
|
|
2666
|
+
name: "moso/preact/rules",
|
|
2667
|
+
files,
|
|
2668
|
+
languageOptions: {
|
|
2669
|
+
parser: typescript ? typescriptParser : void 0,
|
|
2670
|
+
parserOptions: {
|
|
2671
|
+
ecmaFeatures: { jsx: true },
|
|
2672
|
+
...typescript && parserOptions
|
|
2673
|
+
},
|
|
2674
|
+
sourceType: "module"
|
|
2675
|
+
},
|
|
2676
|
+
rules: {
|
|
2677
|
+
...lessOpinionated ? { ...(assert.ok(!Array.isArray(reactPlugin.configs.recommended)), reactPlugin.configs.recommended.rules) } : {
|
|
2678
|
+
...(assert.ok(!Array.isArray(reactPlugin.configs.strict)), reactPlugin.configs.strict.rules),
|
|
2679
|
+
...stylisticEnabled && {
|
|
2680
|
+
"@stylistic/jsx-closing-bracket-location": ["error", "line-aligned"],
|
|
2681
|
+
"@stylistic/jsx-curly-brace-presence": ["error", {
|
|
2682
|
+
props: "never",
|
|
2683
|
+
children: "never"
|
|
2684
|
+
}],
|
|
2685
|
+
"@stylistic/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
|
2686
|
+
"@stylistic/jsx-pascal-case": ["error", {
|
|
2687
|
+
allowAllCaps: true,
|
|
2688
|
+
ignore: []
|
|
2689
|
+
}],
|
|
2690
|
+
"@stylistic/jsx-self-closing-comp": "error",
|
|
2691
|
+
"@stylistic/jsx-tag-spacing": ["error", {
|
|
2692
|
+
afterOpening: "never",
|
|
2693
|
+
closingSlash: "never",
|
|
2694
|
+
beforeClosing: "never",
|
|
2695
|
+
beforeSelfClosing: "always"
|
|
2696
|
+
}],
|
|
2697
|
+
"@stylistic/jsx-wrap-multilines": ["error", {
|
|
2698
|
+
arrow: "parens-new-line",
|
|
2699
|
+
assignment: "parens-new-line",
|
|
2700
|
+
condition: "ignore",
|
|
2701
|
+
declaration: "parens-new-line",
|
|
2702
|
+
logical: "ignore",
|
|
2703
|
+
prop: "ignore",
|
|
2704
|
+
return: "parens-new-line"
|
|
2705
|
+
}],
|
|
2706
|
+
"@stylistic/no-multi-spaces": "error"
|
|
2707
|
+
}
|
|
2708
|
+
},
|
|
2709
|
+
...(assert.ok(!Array.isArray(reactHooksPlugin.configs?.["recommended-latest"])), reactHooksPlugin.configs?.["recommended-latest"].rules),
|
|
2710
|
+
"react-refresh/only-export-components": ["error", {
|
|
2711
|
+
allowCompoundComponents: true,
|
|
2712
|
+
allowConstantExport: true
|
|
2713
|
+
}],
|
|
2714
|
+
...jsxA11yPlugin && {
|
|
2715
|
+
"jsx-a11y/alt-text": ["warn", {
|
|
2716
|
+
elements: ["img"],
|
|
2717
|
+
img: ["Image"]
|
|
2718
|
+
}],
|
|
2719
|
+
"jsx-a11y/aria-props": "warn",
|
|
2720
|
+
"jsx-a11y/aria-proptypes": "warn",
|
|
2721
|
+
"jsx-a11y/aria-role": "warn",
|
|
2722
|
+
"jsx-a11y/aria-unsupported-elements": "warn",
|
|
2723
|
+
"jsx-a11y/iframe-has-title": "warn",
|
|
2724
|
+
"jsx-a11y/no-access-key": "warn",
|
|
2725
|
+
"jsx-a11y/no-static-element-interactions": "warn",
|
|
2726
|
+
"jsx-a11y/role-has-required-aria-props": "warn",
|
|
2727
|
+
"jsx-a11y/role-supports-aria-props": "warn",
|
|
2728
|
+
"jsx-a11y/tabindex-no-positive": "warn",
|
|
2729
|
+
"jsx-a11y/anchor-ambiguous-text": "off",
|
|
2730
|
+
"jsx-a11y/interactive-supports-focus": ["error", { tabbable: [
|
|
2731
|
+
"button",
|
|
2732
|
+
"checkbox",
|
|
2733
|
+
"link",
|
|
2734
|
+
"progressbar",
|
|
2735
|
+
"searchbox",
|
|
2736
|
+
"slider",
|
|
2737
|
+
"spinbutton",
|
|
2738
|
+
"switch",
|
|
2739
|
+
"textbox"
|
|
2740
|
+
] }],
|
|
2741
|
+
"jsx-a11y/label-has-for": "off",
|
|
2742
|
+
"jsx-a11y/no-noninteractive-element-interactions": ["error", {
|
|
2743
|
+
body: ["onError", "onLoad"],
|
|
2744
|
+
iframe: ["onError", "onLoad"],
|
|
2745
|
+
img: ["onError", "onLoad"]
|
|
2746
|
+
}],
|
|
2747
|
+
...overridesA11y
|
|
2748
|
+
},
|
|
2749
|
+
...overrides
|
|
2750
|
+
}
|
|
2751
|
+
},
|
|
2752
|
+
...isTypeAware ? [{
|
|
2753
|
+
name: "moso/preact/typescript/type-aware-rules",
|
|
2754
|
+
files: filesTypeAware,
|
|
2755
|
+
ignores: ignoresTypeAware,
|
|
2756
|
+
rules: {
|
|
2757
|
+
...lessOpinionated ? { ...(assert.ok(!Array.isArray(reactPlugin.configs["recommended-type-checked"])), reactPlugin.configs["recommended-type-checked"].rules) } : { ...(assert.ok(!Array.isArray(reactPlugin.configs["strict-type-checked"])), reactPlugin.configs["strict-type-checked"].rules) },
|
|
2758
|
+
...overridesTypeAware
|
|
2759
|
+
}
|
|
2760
|
+
}] : []
|
|
2761
|
+
];
|
|
2762
|
+
};
|
|
2763
|
+
// src/configs/promise.ts
|
|
2674
2764
|
const promise = async (options) => {
|
|
2675
2765
|
const { lessOpinionated, overrides, typescript } = options;
|
|
2676
2766
|
const [promisePlugin] = await loadPackages(["eslint-plugin-promise"]);
|
|
@@ -2703,8 +2793,7 @@ const promise = async (options) => {
|
|
|
2703
2793
|
}
|
|
2704
2794
|
}];
|
|
2705
2795
|
};
|
|
2706
|
-
|
|
2707
|
-
//#region src/configs/react.ts
|
|
2796
|
+
// src/configs/react.ts
|
|
2708
2797
|
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
2709
2798
|
const ReactRouterPackages = [
|
|
2710
2799
|
"@react-router/dev",
|
|
@@ -2757,7 +2846,6 @@ const react = async (options) => {
|
|
|
2757
2846
|
},
|
|
2758
2847
|
sourceType: "module"
|
|
2759
2848
|
},
|
|
2760
|
-
settings: { "@eslint-react": { version: "detect" } },
|
|
2761
2849
|
rules: {
|
|
2762
2850
|
...lessOpinionated ? {
|
|
2763
2851
|
...(assert.ok(!Array.isArray(reactPlugin.configs.recommended)), reactPlugin.configs.recommended.rules),
|
|
@@ -2921,8 +3009,7 @@ const react = async (options) => {
|
|
|
2921
3009
|
}] : []
|
|
2922
3010
|
];
|
|
2923
3011
|
};
|
|
2924
|
-
|
|
2925
|
-
//#region src/configs/regexp.ts
|
|
3012
|
+
// src/configs/regexp.ts
|
|
2926
3013
|
const regexp = async (options) => {
|
|
2927
3014
|
const { overrides } = options;
|
|
2928
3015
|
const [regexpPlugin] = await loadPackages(["eslint-plugin-regexp"]);
|
|
@@ -2934,13 +3021,34 @@ const regexp = async (options) => {
|
|
|
2934
3021
|
"no-invalid-regexp": "off",
|
|
2935
3022
|
"no-useless-backreference": "off",
|
|
2936
3023
|
...(assert.ok(!Array.isArray(regexpPlugin.configs["flat/recommended"])), regexpPlugin.configs["flat/recommended"].rules),
|
|
3024
|
+
"regexp/no-super-linear-backtracking": "error",
|
|
2937
3025
|
"regexp/strict": "off",
|
|
2938
3026
|
...overrides
|
|
2939
3027
|
}
|
|
2940
3028
|
}];
|
|
2941
3029
|
};
|
|
2942
|
-
|
|
2943
|
-
|
|
3030
|
+
// src/configs/security.ts
|
|
3031
|
+
const security = async (options) => {
|
|
3032
|
+
const { overrides, severity } = options;
|
|
3033
|
+
const [securityPlugin] = await loadPackages(["eslint-plugin-security"]);
|
|
3034
|
+
const recommended = securityPlugin.configs?.["recommended"];
|
|
3035
|
+
const baseRules = severity === "lite" ? recommended?.rules : Object.fromEntries(Object.keys(recommended?.rules ?? {}).map((key) => [key, "error"]));
|
|
3036
|
+
return [{
|
|
3037
|
+
name: "moso/security",
|
|
3038
|
+
plugins: { security: memoize(securityPlugin, "eslint-plugin-security") },
|
|
3039
|
+
rules: {
|
|
3040
|
+
...baseRules,
|
|
3041
|
+
"security/detect-unsafe-regex": "off",
|
|
3042
|
+
...severity !== "strict" && {
|
|
3043
|
+
"security/detect-non-literal-fs-filename": "off",
|
|
3044
|
+
"security/detect-non-literal-regexp": "off",
|
|
3045
|
+
"security/detect-object-injection": "off"
|
|
3046
|
+
},
|
|
3047
|
+
...overrides
|
|
3048
|
+
}
|
|
3049
|
+
}];
|
|
3050
|
+
};
|
|
3051
|
+
// src/configs/sort.ts
|
|
2944
3052
|
/**
|
|
2945
3053
|
* Sort package.json
|
|
2946
3054
|
*
|
|
@@ -3177,8 +3285,7 @@ const sortTsconfig = (options = {}) => {
|
|
|
3177
3285
|
}
|
|
3178
3286
|
}];
|
|
3179
3287
|
};
|
|
3180
|
-
|
|
3181
|
-
//#region src/configs/stylistic.ts
|
|
3288
|
+
// src/configs/stylistic.ts
|
|
3182
3289
|
const StylisticConfigDefaults = {
|
|
3183
3290
|
braceStyle: "1tbs",
|
|
3184
3291
|
experimental: false,
|
|
@@ -3429,8 +3536,85 @@ const stylistic = async (options) => {
|
|
|
3429
3536
|
}
|
|
3430
3537
|
}];
|
|
3431
3538
|
};
|
|
3432
|
-
|
|
3433
|
-
|
|
3539
|
+
// src/configs/svelte.ts
|
|
3540
|
+
const svelte = async (options) => {
|
|
3541
|
+
const { files, lessOpinionated, parserOptions, overrides, stylistic, typescript } = options;
|
|
3542
|
+
const { indent = 4 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
3543
|
+
const stylisticEnabled = stylistic !== false;
|
|
3544
|
+
const [svelteParser, sveltePlugin] = await loadPackages(["svelte-eslint-parser", "eslint-plugin-svelte"]);
|
|
3545
|
+
const [typescriptParser] = typescript ? await loadPackages(["@typescript-eslint/parser"]) : [void 0];
|
|
3546
|
+
return [
|
|
3547
|
+
{
|
|
3548
|
+
name: "moso/svelte/setup",
|
|
3549
|
+
plugins: { "svelte": memoize(sveltePlugin, "eslint-plugin-svelte") }
|
|
3550
|
+
},
|
|
3551
|
+
{
|
|
3552
|
+
name: "moso/svelte/rules",
|
|
3553
|
+
files,
|
|
3554
|
+
languageOptions: {
|
|
3555
|
+
parser: memoize(svelteParser, "svelte-eslint-parser"),
|
|
3556
|
+
parserOptions: {
|
|
3557
|
+
extraFileExtensions: [".svelte"],
|
|
3558
|
+
parser: typescript ? typescriptParser : void 0,
|
|
3559
|
+
...typescript && parserOptions
|
|
3560
|
+
}
|
|
3561
|
+
},
|
|
3562
|
+
processor: sveltePlugin.processors[".svelte"],
|
|
3563
|
+
rules: {
|
|
3564
|
+
"functional/no-let": "off",
|
|
3565
|
+
"import-lite/no-mutable-exports": "off",
|
|
3566
|
+
"no-undef": "off",
|
|
3567
|
+
"no-unused-vars": typescript ? "off" : ["error", {
|
|
3568
|
+
args: "none",
|
|
3569
|
+
caughtErrors: "none",
|
|
3570
|
+
ignoreRestSiblings: true,
|
|
3571
|
+
vars: "all",
|
|
3572
|
+
varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
3573
|
+
}],
|
|
3574
|
+
"unused-imports/no-unused-vars": ["error", {
|
|
3575
|
+
args: "after-used",
|
|
3576
|
+
argsIgnorePattern: "^_",
|
|
3577
|
+
ignoreRestSiblings: true,
|
|
3578
|
+
vars: "all",
|
|
3579
|
+
varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
3580
|
+
}],
|
|
3581
|
+
"prefer-const": "off",
|
|
3582
|
+
"svelte/prefer-const": ["error", {
|
|
3583
|
+
destructuring: "all",
|
|
3584
|
+
ignoreReadBeforeAssign: true
|
|
3585
|
+
}],
|
|
3586
|
+
...flattenRules(sveltePlugin.configs.recommended),
|
|
3587
|
+
...stylisticEnabled && {
|
|
3588
|
+
"@stylistic/indent": "off",
|
|
3589
|
+
"@stylistic/no-trailing-spaces": "off",
|
|
3590
|
+
"svelte/derived-has-same-inputs-outputs": "error",
|
|
3591
|
+
"svelte/html-closing-bracket-spacing": "error",
|
|
3592
|
+
"svelte/html-quotes": ["error", { prefer: "double" }],
|
|
3593
|
+
"svelte/indent": ["error", {
|
|
3594
|
+
alignAttributesVertically: true,
|
|
3595
|
+
indent
|
|
3596
|
+
}],
|
|
3597
|
+
"svelte/mustache-spacing": "error",
|
|
3598
|
+
"svelte/no-spaces-around-equal-signs-in-attribute": "error",
|
|
3599
|
+
"svelte/no-trailing-spaces": "error",
|
|
3600
|
+
"svelte/spaced-html-comment": "error"
|
|
3601
|
+
},
|
|
3602
|
+
...!lessOpinionated && {
|
|
3603
|
+
"svelte/block-lang": ["error", { script: typescript ? "ts" : null }],
|
|
3604
|
+
"svelte/button-has-type": "error",
|
|
3605
|
+
"svelte/no-at-const-tags": "error",
|
|
3606
|
+
"svelte/no-ignored-unsubscribe": "error"
|
|
3607
|
+
},
|
|
3608
|
+
...overrides
|
|
3609
|
+
}
|
|
3610
|
+
},
|
|
3611
|
+
{
|
|
3612
|
+
name: "moso/svelte/ignores",
|
|
3613
|
+
ignores: ["!**/src/lib"]
|
|
3614
|
+
}
|
|
3615
|
+
];
|
|
3616
|
+
};
|
|
3617
|
+
// src/configs/tailwind.ts
|
|
3434
3618
|
const tailwind = async (options) => {
|
|
3435
3619
|
const { config, entryPoint, overrides, stylistic, version } = options;
|
|
3436
3620
|
const [tailwindPlugin] = await loadPackages(["eslint-plugin-better-tailwindcss"]);
|
|
@@ -3472,8 +3656,7 @@ const tailwind = async (options) => {
|
|
|
3472
3656
|
}
|
|
3473
3657
|
}];
|
|
3474
3658
|
};
|
|
3475
|
-
|
|
3476
|
-
//#region src/configs/test.ts
|
|
3659
|
+
// src/configs/test.ts
|
|
3477
3660
|
const test = async (options) => {
|
|
3478
3661
|
const { functionalEnforcement, isInEditor, files, overrides } = options;
|
|
3479
3662
|
const [functionalPlugin] = functionalEnforcement === "none" ? [void 0] : await loadPackages(["eslint-plugin-functional"]);
|
|
@@ -3506,8 +3689,7 @@ const test = async (options) => {
|
|
|
3506
3689
|
}
|
|
3507
3690
|
}];
|
|
3508
3691
|
};
|
|
3509
|
-
|
|
3510
|
-
//#region src/configs/toml.ts
|
|
3692
|
+
// src/configs/toml.ts
|
|
3511
3693
|
const toml = async (options) => {
|
|
3512
3694
|
const { files, overrides, stylistic } = options;
|
|
3513
3695
|
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
@@ -3553,14 +3735,115 @@ const toml = async (options) => {
|
|
|
3553
3735
|
}
|
|
3554
3736
|
}];
|
|
3555
3737
|
};
|
|
3556
|
-
|
|
3557
|
-
//#region src/configs/typescript.ts
|
|
3738
|
+
// src/configs/typescript.ts
|
|
3558
3739
|
const typescript = async (options) => {
|
|
3559
|
-
const { componentExts, disableTypeAwareRules, erasableOnly, files, filesTypeAware, functionalEnforcement, lessOpinionated, mode, overrides, overridesTypeAware, parserOptions, projectRoot, stylistic, unsafe } = options;
|
|
3740
|
+
const { componentExts, disableTypeAwareRules, erasableOnly, files, filesTypeAware, functionalEnforcement, hasSvelte, lessOpinionated, mode, overrides, overridesTypeAware, parserOptions, projectRoot, stylistic, unsafe } = options;
|
|
3560
3741
|
const [tsEslintPlugin, tsEslintParser] = await loadPackages(["@typescript-eslint/eslint-plugin", "@typescript-eslint/parser"]);
|
|
3561
|
-
const [erasableSyntaxPlugin] = erasableOnly
|
|
3742
|
+
const [erasableSyntaxPlugin] = erasableOnly === false || lessOpinionated ? [void 0] : await loadPackages(["eslint-plugin-erasable-syntax-only"]);
|
|
3562
3743
|
const isTypeAware = typeof projectRoot === "string" && parserOptions.projectService !== false;
|
|
3563
3744
|
const stylisticEnabled = stylistic !== false;
|
|
3745
|
+
const namingConventionRules = { "@typescript-eslint/naming-convention": [
|
|
3746
|
+
"error",
|
|
3747
|
+
{
|
|
3748
|
+
selector: "default",
|
|
3749
|
+
format: ["camelCase", "PascalCase"],
|
|
3750
|
+
leadingUnderscore: "allow",
|
|
3751
|
+
trailingUnderscore: "forbid"
|
|
3752
|
+
},
|
|
3753
|
+
{
|
|
3754
|
+
selector: "variableLike",
|
|
3755
|
+
format: ["camelCase", "PascalCase"],
|
|
3756
|
+
leadingUnderscore: "allow",
|
|
3757
|
+
trailingUnderscore: "forbid"
|
|
3758
|
+
},
|
|
3759
|
+
{
|
|
3760
|
+
selector: "variable",
|
|
3761
|
+
filter: {
|
|
3762
|
+
regex: "^[A-Z0-9_]+$",
|
|
3763
|
+
match: true
|
|
3764
|
+
},
|
|
3765
|
+
format: ["UPPER_CASE"],
|
|
3766
|
+
modifiers: ["const"],
|
|
3767
|
+
leadingUnderscore: "forbid",
|
|
3768
|
+
trailingUnderscore: "forbid"
|
|
3769
|
+
},
|
|
3770
|
+
{
|
|
3771
|
+
selector: "variable",
|
|
3772
|
+
format: [
|
|
3773
|
+
"camelCase",
|
|
3774
|
+
"PascalCase",
|
|
3775
|
+
"UPPER_CASE"
|
|
3776
|
+
],
|
|
3777
|
+
modifiers: ["const"],
|
|
3778
|
+
leadingUnderscore: "allow",
|
|
3779
|
+
trailingUnderscore: "forbid"
|
|
3780
|
+
},
|
|
3781
|
+
{
|
|
3782
|
+
selector: "variable",
|
|
3783
|
+
format: null,
|
|
3784
|
+
modifiers: ["destructured"]
|
|
3785
|
+
},
|
|
3786
|
+
{
|
|
3787
|
+
selector: [
|
|
3788
|
+
"autoAccessor",
|
|
3789
|
+
"parameterProperty",
|
|
3790
|
+
"property"
|
|
3791
|
+
],
|
|
3792
|
+
filter: {
|
|
3793
|
+
regex: "^[A-Z0-9_]+$",
|
|
3794
|
+
match: true
|
|
3795
|
+
},
|
|
3796
|
+
format: ["UPPER_CASE"],
|
|
3797
|
+
leadingUnderscore: "forbid",
|
|
3798
|
+
trailingUnderscore: "forbid"
|
|
3799
|
+
},
|
|
3800
|
+
{
|
|
3801
|
+
selector: [
|
|
3802
|
+
"autoAccessor",
|
|
3803
|
+
"parameterProperty",
|
|
3804
|
+
"property"
|
|
3805
|
+
],
|
|
3806
|
+
format: [
|
|
3807
|
+
"camelCase",
|
|
3808
|
+
"PascalCase",
|
|
3809
|
+
"UPPER_CASE"
|
|
3810
|
+
],
|
|
3811
|
+
modifiers: ["readonly"],
|
|
3812
|
+
leadingUnderscore: "allow",
|
|
3813
|
+
trailingUnderscore: "forbid"
|
|
3814
|
+
},
|
|
3815
|
+
{
|
|
3816
|
+
selector: [
|
|
3817
|
+
"accessor",
|
|
3818
|
+
"classMethod",
|
|
3819
|
+
"typeMethod",
|
|
3820
|
+
"typeProperty"
|
|
3821
|
+
],
|
|
3822
|
+
format: [
|
|
3823
|
+
"camelCase",
|
|
3824
|
+
"PascalCase",
|
|
3825
|
+
"UPPER_CASE"
|
|
3826
|
+
],
|
|
3827
|
+
leadingUnderscore: "allow",
|
|
3828
|
+
trailingUnderscore: "forbid"
|
|
3829
|
+
},
|
|
3830
|
+
{
|
|
3831
|
+
selector: "enumMember",
|
|
3832
|
+
format: ["PascalCase", "UPPER_CASE"],
|
|
3833
|
+
leadingUnderscore: "allow",
|
|
3834
|
+
trailingUnderscore: "forbid"
|
|
3835
|
+
},
|
|
3836
|
+
{
|
|
3837
|
+
selector: "typeLike",
|
|
3838
|
+
format: ["PascalCase"],
|
|
3839
|
+
leadingUnderscore: "allow",
|
|
3840
|
+
trailingUnderscore: "forbid"
|
|
3841
|
+
},
|
|
3842
|
+
{
|
|
3843
|
+
selector: ["objectLiteralProperty", "objectLiteralMethod"],
|
|
3844
|
+
format: null
|
|
3845
|
+
}
|
|
3846
|
+
] };
|
|
3564
3847
|
return [
|
|
3565
3848
|
{
|
|
3566
3849
|
name: "moso/typescript/setup",
|
|
@@ -3660,45 +3943,47 @@ const typescript = async (options) => {
|
|
|
3660
3943
|
"@typescript-eslint/no-useless-constructor": "error",
|
|
3661
3944
|
"@typescript-eslint/parameter-properties": "off",
|
|
3662
3945
|
...functionalEnforcement !== "none" && mode !== "library" && {
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
{
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3946
|
+
...isTypeAware && {
|
|
3947
|
+
"functional/no-mixed-types": "error",
|
|
3948
|
+
"functional/prefer-property-signatures": "error",
|
|
3949
|
+
"functional/readonly-type": "error",
|
|
3950
|
+
"functional/type-declaration-immutability": ["error", { rules: [
|
|
3951
|
+
{
|
|
3952
|
+
identifiers: "I?Immutable.+",
|
|
3953
|
+
immutability: "Immutable",
|
|
3954
|
+
comparator: "AtLeast"
|
|
3955
|
+
},
|
|
3956
|
+
{
|
|
3957
|
+
identifiers: "I?ReadonlyDeep.+",
|
|
3958
|
+
immutability: "ReadonlyDeep",
|
|
3959
|
+
comparator: "AtLeast"
|
|
3960
|
+
},
|
|
3961
|
+
{
|
|
3962
|
+
identifiers: "I?Readonly.+",
|
|
3963
|
+
immutability: "ReadonlyShallow",
|
|
3964
|
+
comparator: "AtLeast",
|
|
3965
|
+
fixer: [{
|
|
3966
|
+
pattern: "^(Array|Map|Set)<(.+)>$",
|
|
3967
|
+
replace: "Readonly$1<$2>"
|
|
3968
|
+
}, {
|
|
3969
|
+
pattern: "^(.+)$",
|
|
3970
|
+
replace: "Readonly<$1>"
|
|
3971
|
+
}]
|
|
3972
|
+
},
|
|
3973
|
+
{
|
|
3974
|
+
identifiers: "I?Mutable.+",
|
|
3975
|
+
immutability: "Mutable",
|
|
3976
|
+
comparator: "AtMost",
|
|
3977
|
+
fixer: [{
|
|
3978
|
+
pattern: "^Readonly(Array|Map|Set)<(.+)>$",
|
|
3979
|
+
replace: "$1<$2>"
|
|
3980
|
+
}, {
|
|
3981
|
+
pattern: "^Readonly<(.+)>$",
|
|
3982
|
+
replace: "$1"
|
|
3983
|
+
}]
|
|
3984
|
+
}
|
|
3985
|
+
] }]
|
|
3986
|
+
},
|
|
3702
3987
|
"@typescript-eslint/naming-convention": [
|
|
3703
3988
|
"error",
|
|
3704
3989
|
{
|
|
@@ -3885,108 +4170,7 @@ const typescript = async (options) => {
|
|
|
3885
4170
|
"require-await": "off",
|
|
3886
4171
|
"@typescript-eslint/consistent-return": "error",
|
|
3887
4172
|
"@typescript-eslint/consistent-type-exports": "error",
|
|
3888
|
-
...functionalEnforcement === "none" && {
|
|
3889
|
-
"error",
|
|
3890
|
-
{
|
|
3891
|
-
selector: "default",
|
|
3892
|
-
format: ["camelCase", "PascalCase"],
|
|
3893
|
-
leadingUnderscore: "allow",
|
|
3894
|
-
trailingUnderscore: "forbid"
|
|
3895
|
-
},
|
|
3896
|
-
{
|
|
3897
|
-
selector: "variableLike",
|
|
3898
|
-
format: ["camelCase", "PascalCase"],
|
|
3899
|
-
leadingUnderscore: "allow",
|
|
3900
|
-
trailingUnderscore: "forbid"
|
|
3901
|
-
},
|
|
3902
|
-
{
|
|
3903
|
-
selector: "variable",
|
|
3904
|
-
filter: {
|
|
3905
|
-
regex: "^[A-Z0-9_]+$",
|
|
3906
|
-
match: true
|
|
3907
|
-
},
|
|
3908
|
-
format: ["UPPER_CASE"],
|
|
3909
|
-
modifiers: ["const"],
|
|
3910
|
-
leadingUnderscore: "forbid",
|
|
3911
|
-
trailingUnderscore: "forbid"
|
|
3912
|
-
},
|
|
3913
|
-
{
|
|
3914
|
-
selector: "variable",
|
|
3915
|
-
format: [
|
|
3916
|
-
"camelCase",
|
|
3917
|
-
"PascalCase",
|
|
3918
|
-
"UPPER_CASE"
|
|
3919
|
-
],
|
|
3920
|
-
modifiers: ["const"],
|
|
3921
|
-
leadingUnderscore: "allow",
|
|
3922
|
-
trailingUnderscore: "forbid"
|
|
3923
|
-
},
|
|
3924
|
-
{
|
|
3925
|
-
selector: "variable",
|
|
3926
|
-
format: null,
|
|
3927
|
-
modifiers: ["destructured"]
|
|
3928
|
-
},
|
|
3929
|
-
{
|
|
3930
|
-
selector: [
|
|
3931
|
-
"autoAccessor",
|
|
3932
|
-
"parameterProperty",
|
|
3933
|
-
"property"
|
|
3934
|
-
],
|
|
3935
|
-
filter: {
|
|
3936
|
-
regex: "^[A-Z0-9_]+$",
|
|
3937
|
-
match: true
|
|
3938
|
-
},
|
|
3939
|
-
format: ["UPPER_CASE"],
|
|
3940
|
-
leadingUnderscore: "forbid",
|
|
3941
|
-
trailingUnderscore: "forbid"
|
|
3942
|
-
},
|
|
3943
|
-
{
|
|
3944
|
-
selector: [
|
|
3945
|
-
"autoAccessor",
|
|
3946
|
-
"parameterProperty",
|
|
3947
|
-
"property"
|
|
3948
|
-
],
|
|
3949
|
-
format: [
|
|
3950
|
-
"camelCase",
|
|
3951
|
-
"PascalCase",
|
|
3952
|
-
"UPPER_CASE"
|
|
3953
|
-
],
|
|
3954
|
-
modifiers: ["readonly"],
|
|
3955
|
-
leadingUnderscore: "allow",
|
|
3956
|
-
trailingUnderscore: "forbid"
|
|
3957
|
-
},
|
|
3958
|
-
{
|
|
3959
|
-
selector: [
|
|
3960
|
-
"accessor",
|
|
3961
|
-
"classMethod",
|
|
3962
|
-
"typeMethod",
|
|
3963
|
-
"typeProperty"
|
|
3964
|
-
],
|
|
3965
|
-
format: [
|
|
3966
|
-
"camelCase",
|
|
3967
|
-
"PascalCase",
|
|
3968
|
-
"UPPER_CASE"
|
|
3969
|
-
],
|
|
3970
|
-
leadingUnderscore: "allow",
|
|
3971
|
-
trailingUnderscore: "forbid"
|
|
3972
|
-
},
|
|
3973
|
-
{
|
|
3974
|
-
selector: "enumMember",
|
|
3975
|
-
format: ["PascalCase", "UPPER_CASE"],
|
|
3976
|
-
leadingUnderscore: "allow",
|
|
3977
|
-
trailingUnderscore: "forbid"
|
|
3978
|
-
},
|
|
3979
|
-
{
|
|
3980
|
-
selector: "typeLike",
|
|
3981
|
-
format: ["PascalCase"],
|
|
3982
|
-
leadingUnderscore: "allow",
|
|
3983
|
-
trailingUnderscore: "forbid"
|
|
3984
|
-
},
|
|
3985
|
-
{
|
|
3986
|
-
selector: ["objectLiteralProperty", "objectLiteralMethod"],
|
|
3987
|
-
format: null
|
|
3988
|
-
}
|
|
3989
|
-
] },
|
|
4173
|
+
...functionalEnforcement === "none" && { ...namingConventionRules },
|
|
3990
4174
|
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
3991
4175
|
"@typescript-eslint/no-unnecessary-type-conversion": "error",
|
|
3992
4176
|
"@typescript-eslint/prefer-promise-reject-errors": "error",
|
|
@@ -4079,6 +4263,11 @@ const typescript = async (options) => {
|
|
|
4079
4263
|
name: "moso/typescript/application-mode",
|
|
4080
4264
|
rules: { "@typescript-eslint/no-empty-object-type": ["error", { allowInterfaces: "with-single-extends" }] }
|
|
4081
4265
|
}] : [],
|
|
4266
|
+
...hasSvelte && functionalEnforcement !== "none" && mode !== "library" ? [{
|
|
4267
|
+
name: "moso/typescript/svelte-overrides",
|
|
4268
|
+
files: [GLOB_SVELTE_MODULE],
|
|
4269
|
+
rules: { ...namingConventionRules }
|
|
4270
|
+
}] : [],
|
|
4082
4271
|
{
|
|
4083
4272
|
name: "moso/typescript/dts-overrides",
|
|
4084
4273
|
files: [GLOB_DTS],
|
|
@@ -4110,8 +4299,7 @@ const typescript = async (options) => {
|
|
|
4110
4299
|
}
|
|
4111
4300
|
];
|
|
4112
4301
|
};
|
|
4113
|
-
|
|
4114
|
-
//#region src/configs/unicorn.ts
|
|
4302
|
+
// src/configs/unicorn.ts
|
|
4115
4303
|
const DOMRules = [
|
|
4116
4304
|
"unicorn/better-dom-traversing",
|
|
4117
4305
|
"unicorn/dom-node-dataset",
|
|
@@ -4163,6 +4351,7 @@ const unicorn = async (options) => {
|
|
|
4163
4351
|
"unicorn/try-complexity": ["error", { max: 3 }],
|
|
4164
4352
|
"unicorn/consistent-boolean-name": "off",
|
|
4165
4353
|
"unicorn/consistent-compound-words": "off",
|
|
4354
|
+
"unicorn/consistent-conditional-object-spread": "off",
|
|
4166
4355
|
"unicorn/consistent-export-decorator-position": "off",
|
|
4167
4356
|
"unicorn/default-export-style": "off",
|
|
4168
4357
|
"unicorn/empty-brace-spaces": "off",
|
|
@@ -4175,6 +4364,7 @@ const unicorn = async (options) => {
|
|
|
4175
4364
|
"unicorn/logical-assignment-operators": "off",
|
|
4176
4365
|
"unicorn/max-nested-calls": "off",
|
|
4177
4366
|
"unicorn/name-replacements": "off",
|
|
4367
|
+
"unicorn/no-asterisk-prefix-in-documentation-comments": "off",
|
|
4178
4368
|
"unicorn/no-array-concat-in-loop": "off",
|
|
4179
4369
|
"unicorn/no-array-fill-with-reference-type": "off",
|
|
4180
4370
|
"unicorn/no-array-reduce": "off",
|
|
@@ -4191,6 +4381,7 @@ const unicorn = async (options) => {
|
|
|
4191
4381
|
"unicorn/no-invalid-well-known-symbol-methods": "off",
|
|
4192
4382
|
"unicorn/no-late-current-target-access": "off",
|
|
4193
4383
|
"unicorn/no-late-event-control": "off",
|
|
4384
|
+
"unicorn/no-leading-empty-lines": "off",
|
|
4194
4385
|
"unicorn/no-lonely-if": "off",
|
|
4195
4386
|
"unicorn/no-mismatched-map-key": "off",
|
|
4196
4387
|
"unicorn/no-named-default": "off",
|
|
@@ -4225,6 +4416,7 @@ const unicorn = async (options) => {
|
|
|
4225
4416
|
"unicorn/prefer-promise-try": "off",
|
|
4226
4417
|
"unicorn/prefer-promise-with-resolvers": "off",
|
|
4227
4418
|
"unicorn/prefer-prototype-methods": "off",
|
|
4419
|
+
"unicorn/prefer-short-escape-sequences": "off",
|
|
4228
4420
|
"unicorn/prefer-single-replace": "off",
|
|
4229
4421
|
"unicorn/prefer-split-limit": "off",
|
|
4230
4422
|
"unicorn/prefer-string-raw": "off",
|
|
@@ -4245,8 +4437,7 @@ const unicorn = async (options) => {
|
|
|
4245
4437
|
}
|
|
4246
4438
|
}];
|
|
4247
4439
|
};
|
|
4248
|
-
|
|
4249
|
-
//#region src/configs/vue.ts
|
|
4440
|
+
// src/configs/vue.ts
|
|
4250
4441
|
const NuxtPackages = ["nuxt"];
|
|
4251
4442
|
const vue = async (options) => {
|
|
4252
4443
|
const { a11y, files, overrides, overridesA11y, parserOptions, stylistic, typescript } = options;
|
|
@@ -4477,8 +4668,7 @@ const vue = async (options) => {
|
|
|
4477
4668
|
] : []
|
|
4478
4669
|
];
|
|
4479
4670
|
};
|
|
4480
|
-
|
|
4481
|
-
//#region src/configs/yaml.ts
|
|
4671
|
+
// src/configs/yaml.ts
|
|
4482
4672
|
const yaml = async (options) => {
|
|
4483
4673
|
const { files, overrides, stylistic } = options;
|
|
4484
4674
|
const { quotes = "single" } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
@@ -4520,8 +4710,7 @@ const yaml = async (options) => {
|
|
|
4520
4710
|
}
|
|
4521
4711
|
}];
|
|
4522
4712
|
};
|
|
4523
|
-
|
|
4524
|
-
//#region src/factory.ts
|
|
4713
|
+
// src/factory.ts
|
|
4525
4714
|
const AstroPackages = [
|
|
4526
4715
|
"astro",
|
|
4527
4716
|
"@astrojs/preact",
|
|
@@ -4529,6 +4718,7 @@ const AstroPackages = [
|
|
|
4529
4718
|
"@astrojs/vue"
|
|
4530
4719
|
];
|
|
4531
4720
|
const NextJSPackages = ["next"];
|
|
4721
|
+
const PreactPackages = ["@astrojs/preact", "preact"];
|
|
4532
4722
|
const ReactPackages = [
|
|
4533
4723
|
"@astrojs/react",
|
|
4534
4724
|
"gatsby",
|
|
@@ -4537,6 +4727,7 @@ const ReactPackages = [
|
|
|
4537
4727
|
"react",
|
|
4538
4728
|
"remix"
|
|
4539
4729
|
];
|
|
4730
|
+
const SveltePackages = ["@sveltejs/kit", "svelte"];
|
|
4540
4731
|
const VuePackages = [
|
|
4541
4732
|
"@astrojs/vue",
|
|
4542
4733
|
"nuxt",
|
|
@@ -4573,7 +4764,9 @@ async function moso(options = {}, ...userConfigs) {
|
|
|
4573
4764
|
const typescriptOptions = !typescriptUnsupported && typescriptRequested;
|
|
4574
4765
|
const astroOptions = options.astro ?? anyPackageExists(AstroPackages);
|
|
4575
4766
|
const nextjsOptions = options.nextjs ?? anyPackageExists(NextJSPackages);
|
|
4767
|
+
const preactOptions = options.preact ?? anyPackageExists(PreactPackages);
|
|
4576
4768
|
const reactOptions = options.react ?? anyPackageExists(ReactPackages);
|
|
4769
|
+
const svelteOptions = options.svelte ?? anyPackageExists(SveltePackages);
|
|
4577
4770
|
const tailwindOptions = options.tailwind ?? packageExists("tailwindcss");
|
|
4578
4771
|
const vueOptions = options.vue ?? anyPackageExists(VuePackages);
|
|
4579
4772
|
const componentExts = vueOptions === false ? [...componentExtsOption] : [.../* @__PURE__ */ new Set([...componentExtsOption, "vue"])];
|
|
@@ -4581,16 +4774,17 @@ async function moso(options = {}, ...userConfigs) {
|
|
|
4581
4774
|
const e18eOptions = options.e18e !== false && (typeof options.e18e === "object" ? options.e18e : (options.e18e === true || options.lessOpinionated !== true) && {});
|
|
4582
4775
|
const functionalEnforcement = typeof options.functional === "string" ? options.functional : typeof options.functional === "object" ? options.functional.functionalEnforcement ?? "lite" : options.functional ? "recommended" : options.functional === false || options.lessOpinionated === true ? "none" : "lite";
|
|
4583
4776
|
const hasTypeScript = Boolean(typescriptOptions);
|
|
4584
|
-
const hasDOM = options.mode !== "library" || Boolean(astroOptions) || Boolean(nextjsOptions) || Boolean(reactOptions) || Boolean(vueOptions);
|
|
4777
|
+
const hasDOM = options.mode !== "library" || Boolean(astroOptions) || Boolean(nextjsOptions) || Boolean(preactOptions) || Boolean(reactOptions) || Boolean(svelteOptions) || Boolean(vueOptions);
|
|
4585
4778
|
const ignoreOptions = typeof options.ignores === "object" ? options.ignores : {};
|
|
4586
4779
|
const modeOptions = typeof options.mode === "string" ? options.mode : "none";
|
|
4587
4780
|
const perfectionistOptions = typeof options.perfectionist === "boolean" ? options.perfectionist : options.lessOpinionated !== true;
|
|
4781
|
+
const securityOptions = typeof options.security === "string" ? options.security : typeof options.security === "object" ? options.security.severity ?? "moderate" : options.security === false ? "none" : "moderate";
|
|
4588
4782
|
const stylisticOptions = options.stylistic !== false && {
|
|
4589
4783
|
...StylisticConfigDefaults,
|
|
4590
4784
|
jsx: jsxOptions !== false,
|
|
4591
4785
|
...typeof options.stylistic === "object" && options.stylistic
|
|
4592
4786
|
};
|
|
4593
|
-
const { filesTypeAware, ignoresTypeAware, parserOptions, projectRoot: typescriptProjectRoot, unsafe: typescriptUnsafe, useDefaultDefaultProject, ...typescriptSubOptions } = resolveSubOptions(options, "typescript");
|
|
4787
|
+
const { filesTypeAware, ignoresTypeAware, parserOptions, projectRoot: typescriptProjectRoot, unsafe: typescriptUnsafe = "warn", useDefaultDefaultProject, ...typescriptSubOptions } = resolveSubOptions(options, "typescript");
|
|
4594
4788
|
const deprecatedProjectRoot = options.projectRoot;
|
|
4595
4789
|
if (deprecatedProjectRoot !== void 0) console.warn("[@moso/eslint-config] The top-level `projectRoot` option is deprecated. Move it inside the `typescript` options instead: `typescript: { projectRoot: import.meta.dirname }`.");
|
|
4596
4790
|
const projectRootOptions = typeof typescriptProjectRoot === "string" ? checkFilePath(typescriptProjectRoot) : typeof deprecatedProjectRoot === "string" ? checkFilePath(deprecatedProjectRoot) : void 0;
|
|
@@ -4639,6 +4833,11 @@ async function moso(options = {}, ...userConfigs) {
|
|
|
4639
4833
|
stylistic: stylisticOptions,
|
|
4640
4834
|
typescript: hasTypeScript
|
|
4641
4835
|
}));
|
|
4836
|
+
if (securityOptions !== "none") mut_configs.push(security({
|
|
4837
|
+
...resolveSubOptions(options, "security"),
|
|
4838
|
+
overrides: getOverrides(options, "security"),
|
|
4839
|
+
severity: securityOptions
|
|
4840
|
+
}));
|
|
4642
4841
|
mut_configs.push(javascript({
|
|
4643
4842
|
...functionalConfigOptions,
|
|
4644
4843
|
isInEditor,
|
|
@@ -4648,7 +4847,7 @@ async function moso(options = {}, ...userConfigs) {
|
|
|
4648
4847
|
}));
|
|
4649
4848
|
if (options.node !== false) mut_configs.push(node({
|
|
4650
4849
|
files: [GLOB_SRC],
|
|
4651
|
-
hasReact: Boolean(reactOptions),
|
|
4850
|
+
hasReact: Boolean(reactOptions) || Boolean(preactOptions),
|
|
4652
4851
|
lessOpinionated: options.lessOpinionated,
|
|
4653
4852
|
overrides: getOverrides(options, "node"),
|
|
4654
4853
|
typescript: hasTypeScript,
|
|
@@ -4740,6 +4939,18 @@ async function moso(options = {}, ...userConfigs) {
|
|
|
4740
4939
|
...resolveSubOptions(options, "nextjs")
|
|
4741
4940
|
}));
|
|
4742
4941
|
if (perfectionistOptions) mut_configs.push(perfectionist({ overrides: getOverrides(options, "perfectionist") }));
|
|
4942
|
+
if (preactOptions !== false) mut_configs.push(preact({
|
|
4943
|
+
...typescriptConfigOptions,
|
|
4944
|
+
files: [GLOB_SRC],
|
|
4945
|
+
filesTypeAware: defaultFilesTypesAware,
|
|
4946
|
+
ignoresTypeAware: [GLOB_ASTRO_TS, `${GLOB_MARKDOWN}/**`],
|
|
4947
|
+
lessOpinionated: options.lessOpinionated,
|
|
4948
|
+
projectRoot: projectRootOptions,
|
|
4949
|
+
overrides: getOverrides(options, "preact"),
|
|
4950
|
+
stylistic: stylisticOptions,
|
|
4951
|
+
typescript: hasTypeScript,
|
|
4952
|
+
...resolveSubOptions(options, "preact")
|
|
4953
|
+
}));
|
|
4743
4954
|
if (reactOptions !== false) mut_configs.push(react({
|
|
4744
4955
|
...typescriptConfigOptions,
|
|
4745
4956
|
files: [GLOB_SRC],
|
|
@@ -4769,12 +4980,22 @@ async function moso(options = {}, ...userConfigs) {
|
|
|
4769
4980
|
...typescriptConfigOptions,
|
|
4770
4981
|
componentExts,
|
|
4771
4982
|
files: [GLOB_SRC, ...componentExts.map((ext) => `**/*.${ext}`)],
|
|
4983
|
+
hasSvelte: Boolean(svelteOptions),
|
|
4772
4984
|
lessOpinionated: options.lessOpinionated,
|
|
4773
4985
|
mode: modeOptions,
|
|
4774
4986
|
overrides: getOverrides(options, "typescript"),
|
|
4775
4987
|
projectRoot: projectRootOptions,
|
|
4776
4988
|
stylistic: stylisticOptions,
|
|
4777
|
-
unsafe: typescriptUnsafe
|
|
4989
|
+
unsafe: typescriptUnsafe
|
|
4990
|
+
}));
|
|
4991
|
+
if (svelteOptions !== false) mut_configs.push(svelte({
|
|
4992
|
+
...typescriptConfigOptions,
|
|
4993
|
+
files: [GLOB_SVELTE],
|
|
4994
|
+
lessOpinionated: options.lessOpinionated,
|
|
4995
|
+
overrides: getOverrides(options, "svelte"),
|
|
4996
|
+
stylistic: stylisticOptions,
|
|
4997
|
+
typescript: hasTypeScript,
|
|
4998
|
+
...resolveSubOptions(options, "svelte")
|
|
4778
4999
|
}));
|
|
4779
5000
|
if (vueOptions !== false) mut_configs.push(vue({
|
|
4780
5001
|
...typescriptConfigOptions,
|
|
@@ -4812,12 +5033,12 @@ async function moso(options = {}, ...userConfigs) {
|
|
|
4812
5033
|
if (isInEditor) mut_composer = mut_composer.disableRulesFix([
|
|
4813
5034
|
"unused-imports/no-unused-imports",
|
|
4814
5035
|
"no-only-tests/no-only-tests",
|
|
4815
|
-
"prefer-const"
|
|
5036
|
+
"prefer-const",
|
|
5037
|
+
"svelte/prefer-const"
|
|
4816
5038
|
], { builtinRules: async () => import("eslint/use-at-your-own-risk").then((r) => r.builtinRules) });
|
|
4817
5039
|
return mut_composer.toConfigs();
|
|
4818
5040
|
}
|
|
4819
|
-
|
|
4820
|
-
//#region src/presets.ts
|
|
5041
|
+
// src/presets.ts
|
|
4821
5042
|
const full = {
|
|
4822
5043
|
astro: { a11y: true },
|
|
4823
5044
|
baseline: true,
|
|
@@ -4832,13 +5053,16 @@ const full = {
|
|
|
4832
5053
|
nextjs: true,
|
|
4833
5054
|
node: true,
|
|
4834
5055
|
perfectionist: true,
|
|
5056
|
+
preact: { a11y: true },
|
|
4835
5057
|
promise: true,
|
|
4836
5058
|
react: {
|
|
4837
5059
|
a11y: true,
|
|
4838
5060
|
reactRefresh: { allowConstantExport: true }
|
|
4839
5061
|
},
|
|
4840
5062
|
regexp: true,
|
|
5063
|
+
security: true,
|
|
4841
5064
|
stylistic: true,
|
|
5065
|
+
svelte: true,
|
|
4842
5066
|
tailwind: {
|
|
4843
5067
|
entryPoint: "src/styles/app.css",
|
|
4844
5068
|
version: 4
|
|
@@ -4868,10 +5092,13 @@ const off = {
|
|
|
4868
5092
|
nextjs: false,
|
|
4869
5093
|
node: false,
|
|
4870
5094
|
perfectionist: false,
|
|
5095
|
+
preact: false,
|
|
4871
5096
|
promise: false,
|
|
4872
5097
|
react: false,
|
|
4873
5098
|
regexp: false,
|
|
5099
|
+
security: false,
|
|
4874
5100
|
stylistic: false,
|
|
5101
|
+
svelte: false,
|
|
4875
5102
|
tailwind: false,
|
|
4876
5103
|
test: false,
|
|
4877
5104
|
toml: false,
|
|
@@ -4880,5 +5107,4 @@ const off = {
|
|
|
4880
5107
|
vue: false,
|
|
4881
5108
|
yaml: false
|
|
4882
5109
|
};
|
|
4883
|
-
|
|
4884
|
-
export { GLOB_AI, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CJS, GLOB_CSS_IN_JS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MJS, GLOB_NODE_MODULES, GLOB_ROOT_DTS, GLOB_ROOT_JS, GLOB_ROOT_JSX, GLOB_ROOT_TS, GLOB_ROOT_TSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPINGS, GLOB_VUE, GLOB_YAML, StylisticConfigDefaults, astro, baseline, checkFilePath, combine, comments, moso as default, moso, disables, e18e, flattenRules, full, functional, getOverrides, globalIgnores, ignores, imports, interopDefault, isInEditorEnv, javascript, jsdoc, jsonc, jsx, memoize, nextjs, node, off, perfectionist, promise, react, regexp, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, tailwind, test, toml, typescript, unicorn, vue, vueInlineElements, yaml };
|
|
5110
|
+
export { GLOB_AI, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CJS, GLOB_CSS_IN_JS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MJS, GLOB_NODE_MODULES, GLOB_ROOT_DTS, GLOB_ROOT_JS, GLOB_ROOT_JSX, GLOB_ROOT_TS, GLOB_ROOT_TSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_SVELTE_MODULE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPINGS, GLOB_VUE, GLOB_YAML, StylisticConfigDefaults, astro, baseline, checkFilePath, combine, comments, moso as default, moso, disables, e18e, flattenRules, full, functional, getOverrides, globalIgnores, ignores, imports, interopDefault, isInEditorEnv, javascript, jsdoc, jsonc, jsx, memoize, nextjs, node, off, perfectionist, preact, promise, react, regexp, resolveSubOptions, security, sortPackageJson, sortTsconfig, stylistic, svelte, tailwind, test, toml, typescript, unicorn, vue, vueInlineElements, yaml };
|