@fabdeh/eslint-config 0.9.0-beta.2 → 0.9.0-beta.4
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 +2 -1
- package/dist/index.d.mts +2157 -2082
- package/dist/index.mjs +119 -142
- package/package.json +20 -21
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import tseslint from "typescript-eslint";
|
|
2
2
|
import { statSync } from "node:fs";
|
|
3
|
-
import {
|
|
4
|
-
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
5
4
|
import process from "node:process";
|
|
6
5
|
import { isPackageExists } from "local-pkg";
|
|
7
6
|
import eslintComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
@@ -243,22 +242,6 @@ async function ensurePackages(packages) {
|
|
|
243
242
|
if (await (await import("@clack/prompts")).confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` })) await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
244
243
|
}
|
|
245
244
|
/**
|
|
246
|
-
* Search for the nearest package.json file and return the `name` property value.
|
|
247
|
-
*
|
|
248
|
-
* @param directoryPath - The folder to start from (default to current working directory).
|
|
249
|
-
* @returns The name of the nearest package.json
|
|
250
|
-
*/
|
|
251
|
-
async function findNearestPackageJsonName(directoryPath = resolve()) {
|
|
252
|
-
try {
|
|
253
|
-
const packageJsonPath = join(directoryPath, "package.json");
|
|
254
|
-
return JSON.parse(await readFile(packageJsonPath, "utf8")).name;
|
|
255
|
-
} catch {
|
|
256
|
-
const parentDir = dirname(directoryPath);
|
|
257
|
-
if (directoryPath === parentDir) throw new Error("No package.json file found.");
|
|
258
|
-
return findNearestPackageJsonName(parentDir);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
245
|
* Returns the object representation of the configuration or an empty object if it is a boolean.
|
|
263
246
|
*
|
|
264
247
|
* @param options - The {@link CreateConfigOptions} object to extract the sub-options from.
|
|
@@ -474,7 +457,7 @@ function mergePrettierOptions(options, overrides = {}) {
|
|
|
474
457
|
* @param hasAngularTemplateParser - Optional argument which indicates whether angular rules already registered the template parser or not.
|
|
475
458
|
* @returns A promise that resolves to a `TypedConfigArray` containing the configured formatters.
|
|
476
459
|
*/
|
|
477
|
-
async function formatters(options = {}, stylistic
|
|
460
|
+
async function formatters(options = {}, stylistic = {}, hasAngularTemplateParser = false) {
|
|
478
461
|
if (options === true) {
|
|
479
462
|
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
480
463
|
options = {
|
|
@@ -494,7 +477,7 @@ async function formatters(options = {}, stylistic$1 = {}, hasAngularTemplatePars
|
|
|
494
477
|
]);
|
|
495
478
|
const { indent, quotes, semi } = {
|
|
496
479
|
...STYLISTIC_CONFIG_DEFAULT,
|
|
497
|
-
...stylistic
|
|
480
|
+
...stylistic
|
|
498
481
|
};
|
|
499
482
|
const prettierOptions = {
|
|
500
483
|
endOfLine: "auto",
|
|
@@ -513,11 +496,11 @@ async function formatters(options = {}, stylistic$1 = {}, hasAngularTemplatePars
|
|
|
513
496
|
xmlWhitespaceSensitivity: "ignore"
|
|
514
497
|
};
|
|
515
498
|
const formatPlugin = await interopDefault(import("eslint-plugin-format"));
|
|
516
|
-
const configs
|
|
499
|
+
const configs = [{
|
|
517
500
|
name: "fabdeh/formatter/setup",
|
|
518
501
|
plugins: { format: formatPlugin }
|
|
519
502
|
}];
|
|
520
|
-
if (options.css) configs
|
|
503
|
+
if (options.css) configs.push({
|
|
521
504
|
name: "fabdeh/formatter/css",
|
|
522
505
|
languageOptions: { parser: formatPlugin.parserPlain },
|
|
523
506
|
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
@@ -533,13 +516,13 @@ async function formatters(options = {}, stylistic$1 = {}, hasAngularTemplatePars
|
|
|
533
516
|
files: [GLOB_LESS],
|
|
534
517
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "less" })] }
|
|
535
518
|
});
|
|
536
|
-
if (options.html) configs
|
|
519
|
+
if (options.html) configs.push({
|
|
537
520
|
name: "fabdeh/formatter/html",
|
|
538
521
|
...hasAngularTemplateParser ? {} : { languageOptions: { parser: formatPlugin.parserPlain } },
|
|
539
522
|
files: [GLOB_HTML],
|
|
540
523
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
|
|
541
524
|
});
|
|
542
|
-
if (options.xml) configs
|
|
525
|
+
if (options.xml) configs.push({
|
|
543
526
|
name: "fabdeh/formatter/xml",
|
|
544
527
|
languageOptions: { parser: formatPlugin.parserPlain },
|
|
545
528
|
files: [GLOB_XML],
|
|
@@ -551,7 +534,7 @@ async function formatters(options = {}, stylistic$1 = {}, hasAngularTemplatePars
|
|
|
551
534
|
plugins: ["@prettier/plugin-xml"]
|
|
552
535
|
})] }
|
|
553
536
|
});
|
|
554
|
-
if (options.svg) configs
|
|
537
|
+
if (options.svg) configs.push({
|
|
555
538
|
name: "fabdeh/formatter/svg",
|
|
556
539
|
languageOptions: { parser: formatPlugin.parserPlain },
|
|
557
540
|
files: [GLOB_SVG],
|
|
@@ -565,7 +548,7 @@ async function formatters(options = {}, stylistic$1 = {}, hasAngularTemplatePars
|
|
|
565
548
|
});
|
|
566
549
|
if (options.markdown) {
|
|
567
550
|
const GLOB_SLIDEV = options.slidev ? options.slidev === true ? ["**/.slides.md"] : options.slidev.files : [];
|
|
568
|
-
configs
|
|
551
|
+
configs.push({
|
|
569
552
|
name: "fabdeh/formatter/markdown",
|
|
570
553
|
languageOptions: { parser: formatPlugin.parserPlain },
|
|
571
554
|
files: [GLOB_MARKDOWN],
|
|
@@ -575,7 +558,7 @@ async function formatters(options = {}, stylistic$1 = {}, hasAngularTemplatePars
|
|
|
575
558
|
embeddedLanguageFormatting: "off"
|
|
576
559
|
})] }
|
|
577
560
|
});
|
|
578
|
-
if (options.slidev) configs
|
|
561
|
+
if (options.slidev) configs.push({
|
|
579
562
|
name: "fabdeh/formatter/slidev",
|
|
580
563
|
languageOptions: { parser: formatPlugin.parserPlain },
|
|
581
564
|
files: GLOB_SLIDEV,
|
|
@@ -586,13 +569,13 @@ async function formatters(options = {}, stylistic$1 = {}, hasAngularTemplatePars
|
|
|
586
569
|
})] }
|
|
587
570
|
});
|
|
588
571
|
}
|
|
589
|
-
if (options.graphql) configs
|
|
572
|
+
if (options.graphql) configs.push({
|
|
590
573
|
name: "fabdeh/formatter/graphql",
|
|
591
574
|
languageOptions: { parser: formatPlugin.parserPlain },
|
|
592
575
|
files: [GLOB_GRAPHQL],
|
|
593
576
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "graphql" })] }
|
|
594
577
|
});
|
|
595
|
-
return tseslint.config(configs
|
|
578
|
+
return tseslint.config(configs);
|
|
596
579
|
}
|
|
597
580
|
|
|
598
581
|
//#endregion
|
|
@@ -621,7 +604,7 @@ function ignores(userIgnores = [], fromFactory) {
|
|
|
621
604
|
* @returns A TypedConfigArray object with the specified import rules.
|
|
622
605
|
*/
|
|
623
606
|
function imports(options = {}) {
|
|
624
|
-
const { stylistic
|
|
607
|
+
const { stylistic = true } = options;
|
|
625
608
|
return tseslint.config({
|
|
626
609
|
name: "fabdeh/imports/rules",
|
|
627
610
|
files: [GLOB_SRC],
|
|
@@ -644,7 +627,7 @@ function imports(options = {}) {
|
|
|
644
627
|
"import-x/no-self-import": "error",
|
|
645
628
|
"import-x/no-useless-path-segments": "error",
|
|
646
629
|
"import-x/no-webpack-loader-syntax": "error",
|
|
647
|
-
...stylistic
|
|
630
|
+
...stylistic ? { "import-x/newline-after-import": ["error", {
|
|
648
631
|
considerComments: true,
|
|
649
632
|
count: 1
|
|
650
633
|
}] } : {}
|
|
@@ -831,7 +814,7 @@ function javascript(options = {}) {
|
|
|
831
814
|
* @param mode - To get on JS or TS rules or both.
|
|
832
815
|
* @returns The JSDoc eslint rules configured with the requested level.
|
|
833
816
|
*/
|
|
834
|
-
function getJsDocRules(level, stylistic
|
|
817
|
+
function getJsDocRules(level, stylistic, mode) {
|
|
835
818
|
return {
|
|
836
819
|
...mode === "both" || mode === "jsOnly" ? {
|
|
837
820
|
"jsdoc/check-access": level,
|
|
@@ -860,7 +843,7 @@ function getJsDocRules(level, stylistic$1, mode) {
|
|
|
860
843
|
"jsdoc/require-yields": level,
|
|
861
844
|
"jsdoc/require-yields-check": level,
|
|
862
845
|
"jsdoc/valid-types": level,
|
|
863
|
-
...stylistic
|
|
846
|
+
...stylistic ? {
|
|
864
847
|
"jsdoc/check-alignment": level,
|
|
865
848
|
"jsdoc/multiline-blocks": level,
|
|
866
849
|
"jsdoc/no-multi-asterisks": level,
|
|
@@ -894,16 +877,16 @@ function getJsDocRules(level, stylistic$1, mode) {
|
|
|
894
877
|
* @returns A configuration array for JSDoc rules.
|
|
895
878
|
*/
|
|
896
879
|
function jsdoc(options = {}) {
|
|
897
|
-
const { stylistic
|
|
880
|
+
const { stylistic = true } = options;
|
|
898
881
|
return tseslint.config({
|
|
899
882
|
name: "fabdeh/jsdoc/rules",
|
|
900
883
|
files: [GLOB_SRC],
|
|
901
884
|
plugins: { jsdoc: jsdocPlugin },
|
|
902
|
-
rules: getJsDocRules("warn", !!stylistic
|
|
885
|
+
rules: getJsDocRules("warn", !!stylistic, "jsOnly")
|
|
903
886
|
}, {
|
|
904
887
|
name: "fabdeh/jsdoc/ts-only/rules",
|
|
905
888
|
files: [GLOB_TS],
|
|
906
|
-
rules: getJsDocRules("warn", !!stylistic
|
|
889
|
+
rules: getJsDocRules("warn", !!stylistic, "tsOnly")
|
|
907
890
|
});
|
|
908
891
|
}
|
|
909
892
|
|
|
@@ -932,8 +915,8 @@ async function jsonc(options = {}) {
|
|
|
932
915
|
GLOB_JSON,
|
|
933
916
|
GLOB_JSON5,
|
|
934
917
|
GLOB_JSONC
|
|
935
|
-
], overrides = {}, stylistic
|
|
936
|
-
const { indent = 2 } = typeof stylistic
|
|
918
|
+
], overrides = {}, stylistic = true } = options;
|
|
919
|
+
const { indent = 2 } = typeof stylistic === "object" ? stylistic : {};
|
|
937
920
|
const [jsoncPlugin, jsoncParser] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
938
921
|
return tseslint.config({
|
|
939
922
|
name: "fabdeh/jsonc/setup",
|
|
@@ -969,7 +952,7 @@ async function jsonc(options = {}) {
|
|
|
969
952
|
"jsonc/space-unary-ops": "error",
|
|
970
953
|
"jsonc/valid-json-number": "error",
|
|
971
954
|
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
972
|
-
...stylistic
|
|
955
|
+
...stylistic ? {
|
|
973
956
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
974
957
|
"jsonc/comma-dangle": ["error", "never"],
|
|
975
958
|
"jsonc/comma-style": ["error", "last"],
|
|
@@ -1149,7 +1132,6 @@ function namingConvention(strict, allowJsx = false) {
|
|
|
1149
1132
|
},
|
|
1150
1133
|
{
|
|
1151
1134
|
selector: "import",
|
|
1152
|
-
modifiers: ["default", "namespace"],
|
|
1153
1135
|
format: [strict ? "strictCamelCase" : "camelCase", strict ? "StrictPascalCase" : "PascalCase"]
|
|
1154
1136
|
},
|
|
1155
1137
|
{
|
|
@@ -1197,14 +1179,14 @@ const DEFAULT_SIGNALS_GLOB = [`**/*.store.${GLOB_TS_EXT}`];
|
|
|
1197
1179
|
async function ngrx(options = {}) {
|
|
1198
1180
|
const ngrxPlugin = await interopDefault(import("@ngrx/eslint-plugin/v9"));
|
|
1199
1181
|
const { store = isPackageExists("@ngrx/store"), effects = isPackageExists("@ngrx/effects"), signals = isPackageExists("@ngrx/signals"), useRelaxedNamingConventionForCamelAndPascalCases = false } = options;
|
|
1200
|
-
const configs
|
|
1182
|
+
const configs = [];
|
|
1201
1183
|
let addOperatorsRules = false;
|
|
1202
1184
|
const ngrxOperatorsFiles = [];
|
|
1203
1185
|
if (store) {
|
|
1204
1186
|
const { files = DEFAULT_STORE_GLOB, enforceOperatorsRules = isPackageExists("@ngrx/operators"), overrides = {} } = typeof store === "object" ? store : {};
|
|
1205
1187
|
addOperatorsRules ||= enforceOperatorsRules;
|
|
1206
1188
|
ngrxOperatorsFiles.push(files);
|
|
1207
|
-
configs
|
|
1189
|
+
configs.push({
|
|
1208
1190
|
name: "fabdeh/ngrx-store/rules",
|
|
1209
1191
|
files,
|
|
1210
1192
|
plugins: { "@ngrx": ngrxPlugin },
|
|
@@ -1241,7 +1223,7 @@ async function ngrx(options = {}) {
|
|
|
1241
1223
|
const { files = DEFAULT_EFFECTS_GLOB, enforceOperatorsRules = isPackageExists("@ngrx/operators"), overrides = {} } = typeof effects === "object" ? effects : {};
|
|
1242
1224
|
addOperatorsRules ||= enforceOperatorsRules;
|
|
1243
1225
|
ngrxOperatorsFiles.push(files);
|
|
1244
|
-
configs
|
|
1226
|
+
configs.push({
|
|
1245
1227
|
name: "fabdeh/ngrx-effects/rules",
|
|
1246
1228
|
files,
|
|
1247
1229
|
plugins: { "@ngrx": ngrxPlugin },
|
|
@@ -1271,7 +1253,7 @@ async function ngrx(options = {}) {
|
|
|
1271
1253
|
const { files = DEFAULT_SIGNALS_GLOB, enforceOperatorsRules = isPackageExists("@ngrx/operators"), overrides = {} } = typeof signals === "object" ? signals : {};
|
|
1272
1254
|
addOperatorsRules ||= enforceOperatorsRules;
|
|
1273
1255
|
ngrxOperatorsFiles.push(files);
|
|
1274
|
-
configs
|
|
1256
|
+
configs.push({
|
|
1275
1257
|
name: "fabdeh/ngrx-signals/rules",
|
|
1276
1258
|
files,
|
|
1277
1259
|
plugins: { "@ngrx": ngrxPlugin },
|
|
@@ -1302,13 +1284,13 @@ async function ngrx(options = {}) {
|
|
|
1302
1284
|
}
|
|
1303
1285
|
});
|
|
1304
1286
|
}
|
|
1305
|
-
if (addOperatorsRules) configs
|
|
1287
|
+
if (addOperatorsRules) configs.push({
|
|
1306
1288
|
name: "fabdeh/ngrx-operators/rules",
|
|
1307
1289
|
files: [...ngrxOperatorsFiles],
|
|
1308
1290
|
plugins: { "@ngrx": ngrxPlugin },
|
|
1309
1291
|
rules: { ...ngrxPlugin.configs.operators.find((c) => c.name === "ngrx/operators")?.rules }
|
|
1310
1292
|
});
|
|
1311
|
-
return tseslint.config(configs
|
|
1293
|
+
return tseslint.config(configs);
|
|
1312
1294
|
}
|
|
1313
1295
|
|
|
1314
1296
|
//#endregion
|
|
@@ -1342,36 +1324,31 @@ function node() {
|
|
|
1342
1324
|
//#endregion
|
|
1343
1325
|
//#region src/configs/rules-configs/perfectionist-groups.ts
|
|
1344
1326
|
const SORT_IMPORT_GROUPS = [
|
|
1345
|
-
"type",
|
|
1346
|
-
|
|
1347
|
-
"
|
|
1348
|
-
|
|
1349
|
-
"
|
|
1350
|
-
|
|
1351
|
-
"
|
|
1352
|
-
{ newlinesBetween:
|
|
1353
|
-
"
|
|
1354
|
-
{ newlinesBetween:
|
|
1355
|
-
"
|
|
1356
|
-
{ newlinesBetween:
|
|
1357
|
-
"
|
|
1358
|
-
{ newlinesBetween:
|
|
1359
|
-
"
|
|
1360
|
-
{ newlinesBetween:
|
|
1361
|
-
"
|
|
1362
|
-
|
|
1363
|
-
"
|
|
1364
|
-
{ newlinesBetween:
|
|
1365
|
-
"
|
|
1366
|
-
{ newlinesBetween:
|
|
1367
|
-
"
|
|
1368
|
-
{ newlinesBetween: "never" },
|
|
1369
|
-
"index",
|
|
1370
|
-
{ newlinesBetween: "always" },
|
|
1327
|
+
"type-builtin",
|
|
1328
|
+
"type-external",
|
|
1329
|
+
"type-internal",
|
|
1330
|
+
"type-tsconfig-path",
|
|
1331
|
+
"type-parent",
|
|
1332
|
+
"type-sibling",
|
|
1333
|
+
"type-index",
|
|
1334
|
+
{ newlinesBetween: 1 },
|
|
1335
|
+
"value-builtin",
|
|
1336
|
+
{ newlinesBetween: 1 },
|
|
1337
|
+
"value-external",
|
|
1338
|
+
{ newlinesBetween: 1 },
|
|
1339
|
+
"value-internal",
|
|
1340
|
+
{ newlinesBetween: 1 },
|
|
1341
|
+
"value-tsconfig-path",
|
|
1342
|
+
{ newlinesBetween: 1 },
|
|
1343
|
+
"value-parent",
|
|
1344
|
+
"value-sibling",
|
|
1345
|
+
"value-index",
|
|
1346
|
+
{ newlinesBetween: 1 },
|
|
1347
|
+
"value-style",
|
|
1348
|
+
{ newlinesBetween: 1 },
|
|
1349
|
+
"side-effect-style",
|
|
1371
1350
|
"side-effect",
|
|
1372
|
-
{ newlinesBetween:
|
|
1373
|
-
"object",
|
|
1374
|
-
{ newlinesBetween: "always" },
|
|
1351
|
+
{ newlinesBetween: 1 },
|
|
1375
1352
|
"unknown"
|
|
1376
1353
|
];
|
|
1377
1354
|
const SORT_UNION_OR_INTERSECTION_GROUPS = [
|
|
@@ -1403,8 +1380,8 @@ const SORT_UNION_OR_INTERSECTION_GROUPS = [
|
|
|
1403
1380
|
* @returns The configuration array for the "perfectionist" plugin.
|
|
1404
1381
|
* @see https://github.com/azat-io/eslint-plugin-perfectionist
|
|
1405
1382
|
*/
|
|
1406
|
-
|
|
1407
|
-
const rootDir =
|
|
1383
|
+
function perfectionist() {
|
|
1384
|
+
const rootDir = getWorkspaceRoot(process.cwd(), process.cwd());
|
|
1408
1385
|
return tseslint.config({
|
|
1409
1386
|
name: "fabdeh/perfectionist/rules",
|
|
1410
1387
|
files: [GLOB_SRC],
|
|
@@ -1416,13 +1393,13 @@ async function perfectionist() {
|
|
|
1416
1393
|
}],
|
|
1417
1394
|
"perfectionist/sort-imports": ["error", {
|
|
1418
1395
|
groups: SORT_IMPORT_GROUPS,
|
|
1419
|
-
tsconfig:
|
|
1396
|
+
tsconfig: {
|
|
1420
1397
|
rootDir,
|
|
1421
1398
|
filename: getTsConfigFileName(rootDir)
|
|
1422
|
-
}
|
|
1399
|
+
},
|
|
1423
1400
|
order: "asc",
|
|
1424
1401
|
type: "natural",
|
|
1425
|
-
newlinesBetween:
|
|
1402
|
+
newlinesBetween: 0
|
|
1426
1403
|
}],
|
|
1427
1404
|
"perfectionist/sort-intersection-types": ["error", {
|
|
1428
1405
|
groups: SORT_UNION_OR_INTERSECTION_GROUPS,
|
|
@@ -1783,7 +1760,7 @@ async function tailwindcss(options = {}) {
|
|
|
1783
1760
|
plugins: { "better-tailwindcss": betterTailwindcssPlugin },
|
|
1784
1761
|
settings: { "better-tailwindcss": settings },
|
|
1785
1762
|
rules: {
|
|
1786
|
-
...betterTailwindcssPlugin.configs.recommended
|
|
1763
|
+
...betterTailwindcssPlugin.configs.recommended.rules,
|
|
1787
1764
|
...enableAllRules ? {
|
|
1788
1765
|
"better-tailwindcss/enforce-consistent-variable-syntax": "warn",
|
|
1789
1766
|
"better-tailwindcss/no-conflicting-classes": "error",
|
|
@@ -1806,16 +1783,16 @@ async function tailwindcss(options = {}) {
|
|
|
1806
1783
|
* @returns A promise that resolves to the ESLint configuration array.
|
|
1807
1784
|
*/
|
|
1808
1785
|
async function toml(options = {}) {
|
|
1809
|
-
const { files = [GLOB_TOML], overrides = {}, stylistic
|
|
1810
|
-
const { indent = 2 } = typeof stylistic
|
|
1811
|
-
const
|
|
1786
|
+
const { files = [GLOB_TOML], overrides = {}, stylistic = true } = options;
|
|
1787
|
+
const { indent = 2 } = typeof stylistic === "object" ? stylistic : {};
|
|
1788
|
+
const tomlPlugin = await interopDefault(import("eslint-plugin-toml"));
|
|
1812
1789
|
return tseslint.config({
|
|
1813
1790
|
name: "fabdeh/toml/setup",
|
|
1814
1791
|
plugins: { toml: tomlPlugin }
|
|
1815
1792
|
}, {
|
|
1816
1793
|
name: "fabdeh/toml/rules",
|
|
1817
|
-
languageOptions: { parser: tomlParser },
|
|
1818
1794
|
files,
|
|
1795
|
+
language: "toml/toml",
|
|
1819
1796
|
rules: {
|
|
1820
1797
|
"@stylistic/spaced-comment": "off",
|
|
1821
1798
|
"toml/comma-style": "error",
|
|
@@ -1826,11 +1803,11 @@ async function toml(options = {}) {
|
|
|
1826
1803
|
"toml/precision-of-integer": "error",
|
|
1827
1804
|
"toml/tables-order": "error",
|
|
1828
1805
|
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1829
|
-
...stylistic
|
|
1806
|
+
...stylistic ? {
|
|
1830
1807
|
"toml/array-bracket-newline": "error",
|
|
1831
1808
|
"toml/array-bracket-spacing": "error",
|
|
1832
1809
|
"toml/array-element-newline": "error",
|
|
1833
|
-
"toml/indent": ["error", indent
|
|
1810
|
+
"toml/indent": ["error", indent],
|
|
1834
1811
|
"toml/inline-table-curly-spacing": "error",
|
|
1835
1812
|
"toml/key-spacing": "error",
|
|
1836
1813
|
"toml/padding-line-between-pairs": "error",
|
|
@@ -1894,7 +1871,7 @@ const MEMBER_ORDERING_OPTIONS = { default: [
|
|
|
1894
1871
|
* @returns A TypedConfigArray containing the TypeScript ESLint configuration.
|
|
1895
1872
|
*/
|
|
1896
1873
|
async function typescript(options = {}, isWorkspaceProject = false) {
|
|
1897
|
-
const { enableErasableSyntaxOnly = false, overrides = {}, parserOptions = {}, stylistic
|
|
1874
|
+
const { enableErasableSyntaxOnly = false, overrides = {}, parserOptions = {}, stylistic = true, type = "app", useRelaxedNamingConventionForCamelAndPascalCases = false } = options;
|
|
1898
1875
|
let erasableSyntaxOnlyPlugin;
|
|
1899
1876
|
let erasableSyntaxOnlyRules;
|
|
1900
1877
|
if (enableErasableSyntaxOnly) {
|
|
@@ -1946,7 +1923,7 @@ async function typescript(options = {}, isWorkspaceProject = false) {
|
|
|
1946
1923
|
rules: {
|
|
1947
1924
|
...tseslint.configs.strictTypeChecked.find((c) => c.name === "typescript-eslint/eslint-recommended")?.rules,
|
|
1948
1925
|
...tseslint.configs.strictTypeChecked.find((c) => c.name === "typescript-eslint/strict-type-checked")?.rules,
|
|
1949
|
-
...stylistic
|
|
1926
|
+
...stylistic ? tseslint.configs.stylisticTypeChecked.find((c) => c.name === "typescript-eslint/stylistic-type-checked")?.rules : {},
|
|
1950
1927
|
"@typescript-eslint/array-type": ["error", { default: "array" }],
|
|
1951
1928
|
"@typescript-eslint/consistent-indexed-object-style": "error",
|
|
1952
1929
|
"@typescript-eslint/consistent-type-assertions": ["error", {
|
|
@@ -2213,15 +2190,15 @@ async function vitest(options = {}) {
|
|
|
2213
2190
|
* @returns A promise that resolves to a `TypedConfigArray` containing the ESLint configuration.
|
|
2214
2191
|
*/
|
|
2215
2192
|
async function yaml(options = {}) {
|
|
2216
|
-
const { files = [GLOB_YAML], overrides = {}, stylistic
|
|
2217
|
-
const { indent = 2, quotes = "single" } = typeof stylistic
|
|
2218
|
-
const
|
|
2193
|
+
const { files = [GLOB_YAML], overrides = {}, stylistic = true } = options;
|
|
2194
|
+
const { indent = 2, quotes = "single" } = typeof stylistic === "object" ? stylistic : {};
|
|
2195
|
+
const yamlPlugin = await interopDefault(import("eslint-plugin-yml"));
|
|
2219
2196
|
return tseslint.config({
|
|
2220
2197
|
name: "fabdeh/yaml/setup",
|
|
2221
2198
|
plugins: { yaml: yamlPlugin }
|
|
2222
2199
|
}, {
|
|
2223
2200
|
name: "fabdeh/yaml/rules",
|
|
2224
|
-
|
|
2201
|
+
language: "yaml/yaml",
|
|
2225
2202
|
files,
|
|
2226
2203
|
rules: {
|
|
2227
2204
|
"@stylistic/spaced-comment": "off",
|
|
@@ -2232,14 +2209,14 @@ async function yaml(options = {}) {
|
|
|
2232
2209
|
"yaml/no-irregular-whitespace": "error",
|
|
2233
2210
|
"yaml/plain-scalar": "error",
|
|
2234
2211
|
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
2235
|
-
...stylistic
|
|
2212
|
+
...stylistic ? {
|
|
2236
2213
|
"yaml/block-mapping-question-indicator-newline": "error",
|
|
2237
2214
|
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
2238
2215
|
"yaml/flow-mapping-curly-newline": "error",
|
|
2239
2216
|
"yaml/flow-mapping-curly-spacing": "error",
|
|
2240
2217
|
"yaml/flow-sequence-bracket-newline": "error",
|
|
2241
2218
|
"yaml/flow-sequence-bracket-spacing": "error",
|
|
2242
|
-
"yaml/indent": ["error", indent
|
|
2219
|
+
"yaml/indent": ["error", indent],
|
|
2243
2220
|
"yaml/key-spacing": "error",
|
|
2244
2221
|
"yaml/no-tab-indent": "error",
|
|
2245
2222
|
"yaml/quotes": ["error", {
|
|
@@ -2286,22 +2263,22 @@ async function defineProjectConfig(baseConfig, options = {}, ...userConfigs) {
|
|
|
2286
2263
|
const workspaceOptions = resolvedBaseConfig[OPTIONS_SYMBOL];
|
|
2287
2264
|
const { angular: enableAngular = isPackageExists("@angular/core"), jsdoc: enableJsdoc = options.type === "lib", ngrx: enableNgrx = NGRX_PACKAGES.some((p) => isPackageExists(p)), tailwindcss: enableTailwind = false, typescript: typescriptOptions, vitest: enableVitest = isPackageExists("vitest") } = options;
|
|
2288
2265
|
if (enableNgrx && !enableAngular) throw new Error("NgRx rules can only be enabled if Angular rules are also enabled.");
|
|
2289
|
-
const configs
|
|
2290
|
-
if (options.ignores && options.ignores.length > 0) configs
|
|
2266
|
+
const configs = [];
|
|
2267
|
+
if (options.ignores && options.ignores.length > 0) configs.push(ignores(options.ignores, "project"));
|
|
2291
2268
|
if (enableJsdoc) {
|
|
2292
2269
|
const stylisticOptions = workspaceOptions.stylistic === false ? false : typeof workspaceOptions.stylistic === "object" ? workspaceOptions.stylistic : {};
|
|
2293
|
-
configs
|
|
2270
|
+
configs.push(jsdoc({ stylistic: stylisticOptions }));
|
|
2294
2271
|
}
|
|
2295
2272
|
if (typescriptOptions) {
|
|
2296
2273
|
if (!workspaceOptions.typescript) throw new Error("Project-specific TypeScript configuration requires a base configuration with TypeScript support.");
|
|
2297
|
-
configs
|
|
2274
|
+
configs.push(typescript({
|
|
2298
2275
|
...typescriptOptions,
|
|
2299
2276
|
type: options.type
|
|
2300
2277
|
}, true));
|
|
2301
2278
|
}
|
|
2302
2279
|
if (enableAngular) {
|
|
2303
2280
|
const angularOptions = resolveSubOptions(options, "angular");
|
|
2304
|
-
configs
|
|
2281
|
+
configs.push(angular(angularOptions));
|
|
2305
2282
|
if (workspaceOptions.formatters) {
|
|
2306
2283
|
const htmlFormatters = resolvedBaseConfig.find((c) => c.name === "fabdeh/formatter/html");
|
|
2307
2284
|
if (htmlFormatters) delete htmlFormatters.languageOptions;
|
|
@@ -2309,21 +2286,21 @@ async function defineProjectConfig(baseConfig, options = {}, ...userConfigs) {
|
|
|
2309
2286
|
}
|
|
2310
2287
|
if (enableNgrx) {
|
|
2311
2288
|
const ngrxOptions = resolveSubOptions(options, "ngrx");
|
|
2312
|
-
const typescriptOptions
|
|
2313
|
-
configs
|
|
2289
|
+
const typescriptOptions = resolveSubOptions(workspaceOptions, "typescript");
|
|
2290
|
+
configs.push(ngrx({
|
|
2314
2291
|
...ngrxOptions,
|
|
2315
|
-
useRelaxedNamingConventionForCamelAndPascalCases: typescriptOptions
|
|
2292
|
+
useRelaxedNamingConventionForCamelAndPascalCases: typescriptOptions.useRelaxedNamingConventionForCamelAndPascalCases
|
|
2316
2293
|
}));
|
|
2317
2294
|
}
|
|
2318
2295
|
if (enableVitest) {
|
|
2319
2296
|
const vitestOptions = resolveSubOptions(options, "vitest");
|
|
2320
|
-
configs
|
|
2297
|
+
configs.push(vitest(vitestOptions));
|
|
2321
2298
|
}
|
|
2322
2299
|
if (enableTailwind) {
|
|
2323
2300
|
const tailwindcssOptions = resolveSubOptions(options, "tailwindcss");
|
|
2324
|
-
configs
|
|
2301
|
+
configs.push(tailwindcss(tailwindcssOptions));
|
|
2325
2302
|
}
|
|
2326
|
-
return tseslint.config(...resolvedBaseConfig, ...await Promise.all(configs
|
|
2303
|
+
return tseslint.config(...resolvedBaseConfig, ...await Promise.all(configs), ...await Promise.all(userConfigs));
|
|
2327
2304
|
}
|
|
2328
2305
|
|
|
2329
2306
|
//#endregion
|
|
@@ -2344,82 +2321,82 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2344
2321
|
const { angular: enableAngular = isPackageExists("@angular/core"), gitignore: enableGitignore = true, jsdoc: enableJsdoc = options.type === "lib", ngrx: enableNgrx = NGRX_PACKAGES.some((p) => isPackageExists(p)), pnpm: enableCatalogs = false, regexp: enableRegexp = true, tailwindcss: enableTailwind = false, typescript: enableTypescript = isPackageExists("typescript"), unicorn: enableUnicorn = true, vitest: enableVitest = isPackageExists("vitest") } = options;
|
|
2345
2322
|
if (enableNgrx && !enableAngular) throw new Error("NgRx rules can only be enabled if Angular rules are also enabled.");
|
|
2346
2323
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2347
|
-
const configs
|
|
2348
|
-
if (enableGitignore) if (typeof enableGitignore === "object") configs
|
|
2324
|
+
const configs = [];
|
|
2325
|
+
if (enableGitignore) if (typeof enableGitignore === "object") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => tseslint.config(r({
|
|
2349
2326
|
name: "fabdeh/gitignore",
|
|
2350
2327
|
...enableGitignore
|
|
2351
2328
|
}))));
|
|
2352
|
-
else configs
|
|
2329
|
+
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => tseslint.config(r({
|
|
2353
2330
|
name: "fabdeh/gitignore",
|
|
2354
2331
|
strict: true
|
|
2355
2332
|
}))));
|
|
2356
|
-
configs
|
|
2357
|
-
if (enableJsdoc) configs
|
|
2333
|
+
configs.push(ignores(options.ignores), javascript({ overrides: options.javascript?.overrides }), comments(), node(), imports({ stylistic: stylisticOptions }), perfectionist());
|
|
2334
|
+
if (enableJsdoc) configs.push(jsdoc({ stylistic: stylisticOptions }));
|
|
2358
2335
|
if (enableUnicorn) {
|
|
2359
2336
|
const unicornOptions = resolveSubOptions(options, "unicorn");
|
|
2360
|
-
configs
|
|
2337
|
+
configs.push(unicorn(unicornOptions));
|
|
2361
2338
|
}
|
|
2362
2339
|
if (enableTypescript) {
|
|
2363
2340
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2364
|
-
configs
|
|
2341
|
+
configs.push(typescript({
|
|
2365
2342
|
...typescriptOptions,
|
|
2366
2343
|
stylistic: stylisticOptions,
|
|
2367
2344
|
type: options.type
|
|
2368
2345
|
}));
|
|
2369
2346
|
}
|
|
2370
|
-
if (stylisticOptions) configs
|
|
2347
|
+
if (stylisticOptions) configs.push(stylistic({ stylistic: stylisticOptions }));
|
|
2371
2348
|
if (enableRegexp) {
|
|
2372
2349
|
const regexpOptions = resolveSubOptions(options, "regexp");
|
|
2373
|
-
configs
|
|
2350
|
+
configs.push(regexp(regexpOptions));
|
|
2374
2351
|
}
|
|
2375
2352
|
if (enableAngular) {
|
|
2376
2353
|
const angularOptions = resolveSubOptions(options, "angular");
|
|
2377
|
-
configs
|
|
2354
|
+
configs.push(angular(angularOptions));
|
|
2378
2355
|
}
|
|
2379
2356
|
if (enableNgrx) {
|
|
2380
2357
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2381
2358
|
const ngrxOptions = resolveSubOptions(options, "ngrx");
|
|
2382
|
-
configs
|
|
2359
|
+
configs.push(ngrx({
|
|
2383
2360
|
...ngrxOptions,
|
|
2384
2361
|
useRelaxedNamingConventionForCamelAndPascalCases: typescriptOptions.useRelaxedNamingConventionForCamelAndPascalCases
|
|
2385
2362
|
}));
|
|
2386
2363
|
}
|
|
2387
2364
|
if (enableVitest) {
|
|
2388
2365
|
const vitestOptions = resolveSubOptions(options, "vitest");
|
|
2389
|
-
configs
|
|
2366
|
+
configs.push(vitest(vitestOptions));
|
|
2390
2367
|
}
|
|
2391
2368
|
if (enableTailwind) {
|
|
2392
2369
|
const tailwindcssOptions = resolveSubOptions(options, "tailwindcss");
|
|
2393
|
-
configs
|
|
2370
|
+
configs.push(tailwindcss(tailwindcssOptions));
|
|
2394
2371
|
}
|
|
2395
2372
|
if (options.jsonc ?? true) {
|
|
2396
2373
|
const jsoncOptions = resolveSubOptions(options, "jsonc");
|
|
2397
|
-
configs
|
|
2374
|
+
configs.push(jsonc({
|
|
2398
2375
|
...jsoncOptions,
|
|
2399
2376
|
stylistic: stylisticOptions
|
|
2400
2377
|
}), sortPackageJson(), sortTsConfig());
|
|
2401
2378
|
}
|
|
2402
|
-
if (enableCatalogs) configs
|
|
2379
|
+
if (enableCatalogs) configs.push(pnpm());
|
|
2403
2380
|
if (options.yaml ?? true) {
|
|
2404
2381
|
const yamlOptions = resolveSubOptions(options, "yaml");
|
|
2405
|
-
configs
|
|
2382
|
+
configs.push(yaml({
|
|
2406
2383
|
...yamlOptions,
|
|
2407
2384
|
stylistic: stylisticOptions
|
|
2408
2385
|
}));
|
|
2409
2386
|
}
|
|
2410
2387
|
if (options.toml ?? true) {
|
|
2411
2388
|
const tomlOptions = resolveSubOptions(options, "toml");
|
|
2412
|
-
configs
|
|
2389
|
+
configs.push(toml({
|
|
2413
2390
|
...tomlOptions,
|
|
2414
2391
|
stylistic: stylisticOptions
|
|
2415
2392
|
}));
|
|
2416
2393
|
}
|
|
2417
2394
|
if (options.markdown ?? true) {
|
|
2418
2395
|
const markdownOptions = resolveSubOptions(options, "markdown");
|
|
2419
|
-
configs
|
|
2396
|
+
configs.push(markdown(markdownOptions));
|
|
2420
2397
|
}
|
|
2421
|
-
if (options.formatters) configs
|
|
2422
|
-
return tseslint.config(...await Promise.all(configs
|
|
2398
|
+
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions, Boolean(enableAngular)));
|
|
2399
|
+
return tseslint.config(...await Promise.all(configs), ...await Promise.all(userConfigs));
|
|
2423
2400
|
}
|
|
2424
2401
|
|
|
2425
2402
|
//#endregion
|
|
@@ -2440,64 +2417,64 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2440
2417
|
async function defineWorkspaceConfig(options = {}, ...userConfigs) {
|
|
2441
2418
|
const { gitignore: enableGitignore = true, pnpm: enableCatalogs = false, regexp: enableRegexp = true, typescript: enableTypescript = isPackageExists("typescript"), unicorn: enableUnicorn = true } = options;
|
|
2442
2419
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2443
|
-
const configs
|
|
2444
|
-
if (enableGitignore) if (typeof enableGitignore === "object") configs
|
|
2420
|
+
const configs = [];
|
|
2421
|
+
if (enableGitignore) if (typeof enableGitignore === "object") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => tseslint.config(r({
|
|
2445
2422
|
name: "fabdeh/gitignore",
|
|
2446
2423
|
...enableGitignore
|
|
2447
2424
|
}))));
|
|
2448
|
-
else configs
|
|
2425
|
+
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => tseslint.config(r({
|
|
2449
2426
|
name: "fabdeh/gitignore",
|
|
2450
2427
|
strict: true
|
|
2451
2428
|
}))));
|
|
2452
|
-
configs
|
|
2429
|
+
configs.push(ignores(options.ignores, "workspace"), javascript({ overrides: options.javascript?.overrides }), comments(), node(), imports({ stylistic: stylisticOptions }), perfectionist());
|
|
2453
2430
|
if (enableUnicorn) {
|
|
2454
2431
|
const unicornOptions = resolveSubOptions(options, "unicorn");
|
|
2455
|
-
configs
|
|
2432
|
+
configs.push(unicorn(unicornOptions));
|
|
2456
2433
|
}
|
|
2457
2434
|
if (enableTypescript) {
|
|
2458
2435
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2459
|
-
configs
|
|
2436
|
+
configs.push(typescript({
|
|
2460
2437
|
...typescriptOptions,
|
|
2461
2438
|
stylistic: stylisticOptions,
|
|
2462
2439
|
type: "workspace"
|
|
2463
2440
|
}));
|
|
2464
2441
|
}
|
|
2465
|
-
if (stylisticOptions) configs
|
|
2442
|
+
if (stylisticOptions) configs.push(stylistic({ stylistic: stylisticOptions }));
|
|
2466
2443
|
if (enableRegexp) {
|
|
2467
2444
|
const regexpOptions = resolveSubOptions(options, "regexp");
|
|
2468
|
-
configs
|
|
2445
|
+
configs.push(regexp(regexpOptions));
|
|
2469
2446
|
}
|
|
2470
2447
|
if (options.jsonc ?? true) {
|
|
2471
2448
|
const jsoncOptions = resolveSubOptions(options, "jsonc");
|
|
2472
|
-
configs
|
|
2449
|
+
configs.push(jsonc({
|
|
2473
2450
|
...jsoncOptions,
|
|
2474
2451
|
stylistic: stylisticOptions
|
|
2475
2452
|
}), sortPackageJson(), sortTsConfig());
|
|
2476
2453
|
}
|
|
2477
|
-
if (enableCatalogs) configs
|
|
2454
|
+
if (enableCatalogs) configs.push(pnpm());
|
|
2478
2455
|
if (options.yaml ?? true) {
|
|
2479
2456
|
const yamlOptions = resolveSubOptions(options, "yaml");
|
|
2480
|
-
configs
|
|
2457
|
+
configs.push(yaml({
|
|
2481
2458
|
...yamlOptions,
|
|
2482
2459
|
stylistic: stylisticOptions
|
|
2483
2460
|
}));
|
|
2484
2461
|
}
|
|
2485
2462
|
if (options.toml ?? true) {
|
|
2486
2463
|
const tomlOptions = resolveSubOptions(options, "toml");
|
|
2487
|
-
configs
|
|
2464
|
+
configs.push(toml({
|
|
2488
2465
|
...tomlOptions,
|
|
2489
2466
|
stylistic: stylisticOptions
|
|
2490
2467
|
}));
|
|
2491
2468
|
}
|
|
2492
2469
|
if (options.markdown ?? true) {
|
|
2493
2470
|
const markdownOptions = resolveSubOptions(options, "markdown");
|
|
2494
|
-
configs
|
|
2471
|
+
configs.push(markdown(markdownOptions));
|
|
2495
2472
|
}
|
|
2496
|
-
if (options.formatters) configs
|
|
2497
|
-
const eslintConfigWithOptions = tseslint.config(...await Promise.all(configs
|
|
2473
|
+
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions, false));
|
|
2474
|
+
const eslintConfigWithOptions = tseslint.config(...await Promise.all(configs), ...await Promise.all(userConfigs));
|
|
2498
2475
|
eslintConfigWithOptions[OPTIONS_SYMBOL] = options;
|
|
2499
2476
|
return eslintConfigWithOptions;
|
|
2500
2477
|
}
|
|
2501
2478
|
|
|
2502
2479
|
//#endregion
|
|
2503
|
-
export { GLOB_HTML, GLOB_JS, GLOB_SRC, GLOB_TESTS, GLOB_TS, STYLISTIC_CONFIG_DEFAULT, angular, comments, defineConfig, defineProjectConfig, defineWorkspaceConfig, ensurePackages,
|
|
2480
|
+
export { GLOB_HTML, GLOB_JS, GLOB_SRC, GLOB_TESTS, GLOB_TS, STYLISTIC_CONFIG_DEFAULT, angular, comments, defineConfig, defineProjectConfig, defineWorkspaceConfig, ensurePackages, formatters, getTsConfigFileName, getWorkspaceRoot, ignores, imports, interopDefault, isPackageInScope, javascript, jsdoc, jsonc, markdown, ngrx, node, perfectionist, pnpm, regexp, resolveSubOptions, sortPackageJson, sortTsConfig, stylistic, tailwindcss, toml, typescript, unicorn, vitest, yaml };
|