@storm-software/eslint 0.144.2 → 0.145.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 +1 -1
- package/dist/preset.js +789 -60
- package/dist/types.d.ts +39 -16
- package/package.json +2 -2
- package/dist/dist-JAA754SN.js +0 -415
package/dist/preset.js
CHANGED
|
@@ -350,7 +350,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
350
350
|
useTabs: indent === "tab"
|
|
351
351
|
}, options.dprintOptions ?? {});
|
|
352
352
|
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
353
|
-
const
|
|
353
|
+
const configs3 = [
|
|
354
354
|
{
|
|
355
355
|
name: "storm/formatter/setup",
|
|
356
356
|
plugins: {
|
|
@@ -359,7 +359,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
359
359
|
}
|
|
360
360
|
];
|
|
361
361
|
if (options.css) {
|
|
362
|
-
|
|
362
|
+
configs3.push({
|
|
363
363
|
files: [
|
|
364
364
|
GLOB_CSS,
|
|
365
365
|
GLOB_POSTCSS
|
|
@@ -411,7 +411,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
413
|
if (options.html) {
|
|
414
|
-
|
|
414
|
+
configs3.push({
|
|
415
415
|
files: [
|
|
416
416
|
GLOB_HTML
|
|
417
417
|
],
|
|
@@ -430,7 +430,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
430
430
|
});
|
|
431
431
|
}
|
|
432
432
|
if (options.xml) {
|
|
433
|
-
|
|
433
|
+
configs3.push({
|
|
434
434
|
files: [
|
|
435
435
|
GLOB_XML
|
|
436
436
|
],
|
|
@@ -455,7 +455,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
if (options.svg) {
|
|
458
|
-
|
|
458
|
+
configs3.push({
|
|
459
459
|
files: [
|
|
460
460
|
GLOB_SVG
|
|
461
461
|
],
|
|
@@ -481,7 +481,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
481
481
|
}
|
|
482
482
|
if (options.markdown) {
|
|
483
483
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
484
|
-
|
|
484
|
+
configs3.push({
|
|
485
485
|
files: [
|
|
486
486
|
GLOB_MARKDOWN
|
|
487
487
|
],
|
|
@@ -504,7 +504,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
504
504
|
});
|
|
505
505
|
}
|
|
506
506
|
if (options.astro) {
|
|
507
|
-
|
|
507
|
+
configs3.push({
|
|
508
508
|
files: [
|
|
509
509
|
GLOB_ASTRO
|
|
510
510
|
],
|
|
@@ -524,7 +524,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
524
524
|
]
|
|
525
525
|
}
|
|
526
526
|
});
|
|
527
|
-
|
|
527
|
+
configs3.push({
|
|
528
528
|
files: [
|
|
529
529
|
GLOB_ASTRO,
|
|
530
530
|
GLOB_ASTRO_TS
|
|
@@ -542,7 +542,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
542
542
|
});
|
|
543
543
|
}
|
|
544
544
|
if (options.graphql) {
|
|
545
|
-
|
|
545
|
+
configs3.push({
|
|
546
546
|
files: [
|
|
547
547
|
GLOB_GRAPHQL
|
|
548
548
|
],
|
|
@@ -560,7 +560,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
560
560
|
}
|
|
561
561
|
});
|
|
562
562
|
}
|
|
563
|
-
return
|
|
563
|
+
return configs3;
|
|
564
564
|
}
|
|
565
565
|
__name(formatters, "formatters");
|
|
566
566
|
|
|
@@ -810,6 +810,704 @@ import * as pluginImport from "eslint-plugin-import-x";
|
|
|
810
810
|
import { default as default4 } from "eslint-plugin-n";
|
|
811
811
|
import { default as default5 } from "eslint-plugin-no-secrets";
|
|
812
812
|
import { default as default6 } from "eslint-plugin-perfectionist";
|
|
813
|
+
|
|
814
|
+
// ../../node_modules/.pnpm/eslint-plugin-pnpm@0.3.0_patch_hash=72dcde755c336eeca3e6170de1106fd85ecb66171e060788f80_167ca0fed09ad05248614e7080eb405f/node_modules/eslint-plugin-pnpm/dist/index.mjs
|
|
815
|
+
import * as jsoncParser from "jsonc-eslint-parser";
|
|
816
|
+
import * as yamlParser from "yaml-eslint-parser";
|
|
817
|
+
import fs, { existsSync, readFileSync } from "node:fs";
|
|
818
|
+
import process from "node:process";
|
|
819
|
+
import { findUpSync } from "find-up-simple";
|
|
820
|
+
import { parsePnpmWorkspaceYaml } from "pnpm-workspace-yaml";
|
|
821
|
+
import { basename, normalize, resolve, dirname } from "pathe";
|
|
822
|
+
import { globSync } from "tinyglobby";
|
|
823
|
+
var name = "eslint-plugin-pnpm";
|
|
824
|
+
var version = "0.3.0";
|
|
825
|
+
var blobUrl = "https://github.com/antfu/eslint-plugin-pnpm/blob/main/src/rules/";
|
|
826
|
+
function RuleCreator(urlCreator) {
|
|
827
|
+
return /* @__PURE__ */ __name(function createNamedRule({
|
|
828
|
+
name: name2,
|
|
829
|
+
meta,
|
|
830
|
+
...rule
|
|
831
|
+
}) {
|
|
832
|
+
return createRule({
|
|
833
|
+
meta: {
|
|
834
|
+
...meta,
|
|
835
|
+
docs: {
|
|
836
|
+
...meta.docs,
|
|
837
|
+
url: urlCreator(name2)
|
|
838
|
+
}
|
|
839
|
+
},
|
|
840
|
+
...rule
|
|
841
|
+
});
|
|
842
|
+
}, "createNamedRule");
|
|
843
|
+
}
|
|
844
|
+
__name(RuleCreator, "RuleCreator");
|
|
845
|
+
function createRule({
|
|
846
|
+
create,
|
|
847
|
+
defaultOptions,
|
|
848
|
+
meta
|
|
849
|
+
}) {
|
|
850
|
+
return {
|
|
851
|
+
create: /* @__PURE__ */ __name((context) => {
|
|
852
|
+
const optionsWithDefault = context.options.map((options, index) => {
|
|
853
|
+
return {
|
|
854
|
+
...defaultOptions[index] || {},
|
|
855
|
+
...options || {}
|
|
856
|
+
};
|
|
857
|
+
});
|
|
858
|
+
return create(context, optionsWithDefault);
|
|
859
|
+
}, "create"),
|
|
860
|
+
defaultOptions,
|
|
861
|
+
meta
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
__name(createRule, "createRule");
|
|
865
|
+
var createEslintRule = RuleCreator(
|
|
866
|
+
(ruleName) => `${blobUrl}${ruleName}.test.ts`
|
|
867
|
+
);
|
|
868
|
+
function getPackageJsonRootNode(context) {
|
|
869
|
+
if (!context.filename.endsWith("package.json"))
|
|
870
|
+
return;
|
|
871
|
+
const ast = context.sourceCode.ast;
|
|
872
|
+
const root = ast.body[0];
|
|
873
|
+
if (root.expression.type === "JSONObjectExpression")
|
|
874
|
+
return root.expression;
|
|
875
|
+
}
|
|
876
|
+
__name(getPackageJsonRootNode, "getPackageJsonRootNode");
|
|
877
|
+
function* iterateDependencies(context, fields) {
|
|
878
|
+
const root = getPackageJsonRootNode(context);
|
|
879
|
+
if (!root)
|
|
880
|
+
return;
|
|
881
|
+
for (const fieldName of fields) {
|
|
882
|
+
const path = fieldName.split(".");
|
|
883
|
+
let node2 = root;
|
|
884
|
+
for (let i = 0; i < path.length; i++) {
|
|
885
|
+
const item = node2.properties.find((property) => property.key.type === "JSONLiteral" && property.key.value === path[i]);
|
|
886
|
+
if (!item?.value || item.value.type !== "JSONObjectExpression") {
|
|
887
|
+
node2 = void 0;
|
|
888
|
+
break;
|
|
889
|
+
}
|
|
890
|
+
node2 = item.value;
|
|
891
|
+
}
|
|
892
|
+
if (!node2 || node2 === root)
|
|
893
|
+
continue;
|
|
894
|
+
for (const property of node2.properties) {
|
|
895
|
+
if (property.value.type !== "JSONLiteral" || property.key.type !== "JSONLiteral")
|
|
896
|
+
continue;
|
|
897
|
+
if (typeof property.value.value !== "string")
|
|
898
|
+
continue;
|
|
899
|
+
const packageName = String(property.key.value);
|
|
900
|
+
const specifier = String(property.value.value);
|
|
901
|
+
yield {
|
|
902
|
+
packageName,
|
|
903
|
+
specifier,
|
|
904
|
+
property
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
__name(iterateDependencies, "iterateDependencies");
|
|
910
|
+
function readPnpmWorkspace() {
|
|
911
|
+
const filepath = findUpSync("pnpm-workspace.yaml", { cwd: process.cwd() });
|
|
912
|
+
if (!filepath)
|
|
913
|
+
throw new Error("pnpm-workspace.yaml not found");
|
|
914
|
+
const content = fs.readFileSync(filepath, "utf-8");
|
|
915
|
+
const workspace2 = parsePnpmWorkspaceYaml(content);
|
|
916
|
+
let queueTimer;
|
|
917
|
+
const queue = [];
|
|
918
|
+
const write = /* @__PURE__ */ __name(() => {
|
|
919
|
+
fs.writeFileSync(filepath, workspace2.toString());
|
|
920
|
+
}, "write");
|
|
921
|
+
const hasQueue = /* @__PURE__ */ __name(() => queueTimer != null, "hasQueue");
|
|
922
|
+
const queueChange = /* @__PURE__ */ __name((fn, order) => {
|
|
923
|
+
if (order === "pre")
|
|
924
|
+
queue.unshift(fn);
|
|
925
|
+
else
|
|
926
|
+
queue.push(fn);
|
|
927
|
+
if (queueTimer != null)
|
|
928
|
+
clearTimeout(queueTimer);
|
|
929
|
+
queueTimer = setTimeout(() => {
|
|
930
|
+
queueTimer = void 0;
|
|
931
|
+
const clone = [...queue];
|
|
932
|
+
queue.length = 0;
|
|
933
|
+
for (const fn2 of clone)
|
|
934
|
+
fn2(workspace2);
|
|
935
|
+
if (workspace2.hasChanged())
|
|
936
|
+
write();
|
|
937
|
+
}, 1e3);
|
|
938
|
+
}, "queueChange");
|
|
939
|
+
return {
|
|
940
|
+
filepath,
|
|
941
|
+
...workspace2,
|
|
942
|
+
hasQueue,
|
|
943
|
+
queueChange
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
__name(readPnpmWorkspace, "readPnpmWorkspace");
|
|
947
|
+
var WORKSPACE_CACHE_TIME = 1e4;
|
|
948
|
+
var workspaceLastRead;
|
|
949
|
+
var workspace;
|
|
950
|
+
function getPnpmWorkspace() {
|
|
951
|
+
if (workspaceLastRead && workspace && !workspace.hasQueue() && Date.now() - workspaceLastRead > WORKSPACE_CACHE_TIME) {
|
|
952
|
+
workspace = void 0;
|
|
953
|
+
}
|
|
954
|
+
if (!workspace) {
|
|
955
|
+
workspace = readPnpmWorkspace();
|
|
956
|
+
workspaceLastRead = Date.now();
|
|
957
|
+
}
|
|
958
|
+
return workspace;
|
|
959
|
+
}
|
|
960
|
+
__name(getPnpmWorkspace, "getPnpmWorkspace");
|
|
961
|
+
var RULE_NAME$4 = "json-enforce-catalog";
|
|
962
|
+
var DEFAULT_FIELDS$1 = [
|
|
963
|
+
"dependencies",
|
|
964
|
+
"devDependencies"
|
|
965
|
+
];
|
|
966
|
+
var IGNORED_DEPENDENCIES = [
|
|
967
|
+
"typescript"
|
|
968
|
+
];
|
|
969
|
+
var enforceCatalog = createEslintRule({
|
|
970
|
+
name: RULE_NAME$4,
|
|
971
|
+
meta: {
|
|
972
|
+
type: "layout",
|
|
973
|
+
docs: {
|
|
974
|
+
description: 'Enforce using "catalog:" in `package.json`'
|
|
975
|
+
},
|
|
976
|
+
fixable: "code",
|
|
977
|
+
schema: [
|
|
978
|
+
{
|
|
979
|
+
type: "object",
|
|
980
|
+
properties: {
|
|
981
|
+
allowedProtocols: {
|
|
982
|
+
type: "array",
|
|
983
|
+
description: "Allowed protocols in specifier to not be converted to catalog",
|
|
984
|
+
items: {
|
|
985
|
+
type: "string"
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
autofix: {
|
|
989
|
+
type: "boolean",
|
|
990
|
+
description: "Whether to autofix the linting error",
|
|
991
|
+
default: true
|
|
992
|
+
},
|
|
993
|
+
defaultCatalog: {
|
|
994
|
+
type: "string",
|
|
995
|
+
description: "Default catalog to use when moving version to catalog with autofix"
|
|
996
|
+
},
|
|
997
|
+
reuseExistingCatalog: {
|
|
998
|
+
type: "boolean",
|
|
999
|
+
description: "Whether to reuse existing catalog when moving version to catalog with autofix",
|
|
1000
|
+
default: true
|
|
1001
|
+
},
|
|
1002
|
+
conflicts: {
|
|
1003
|
+
type: "string",
|
|
1004
|
+
description: "Strategy to handle conflicts when adding packages to catalogs",
|
|
1005
|
+
enum: ["new-catalog", "overrides", "error"],
|
|
1006
|
+
default: "new-catalog"
|
|
1007
|
+
},
|
|
1008
|
+
fields: {
|
|
1009
|
+
type: "array",
|
|
1010
|
+
description: "Fields to check for catalog",
|
|
1011
|
+
items: { type: "string" },
|
|
1012
|
+
default: DEFAULT_FIELDS$1
|
|
1013
|
+
},
|
|
1014
|
+
ignore: {
|
|
1015
|
+
type: "array",
|
|
1016
|
+
description: "A list of dependencies to ignore",
|
|
1017
|
+
items: { type: "string" },
|
|
1018
|
+
default: IGNORED_DEPENDENCIES
|
|
1019
|
+
}
|
|
1020
|
+
},
|
|
1021
|
+
additionalProperties: false
|
|
1022
|
+
}
|
|
1023
|
+
],
|
|
1024
|
+
messages: {
|
|
1025
|
+
expectCatalog: 'Expect to use catalog instead of plain specifier, got "{{specifier}}" for package "{{packageName}}".'
|
|
1026
|
+
}
|
|
1027
|
+
},
|
|
1028
|
+
defaultOptions: [{}],
|
|
1029
|
+
create(context, [options]) {
|
|
1030
|
+
const {
|
|
1031
|
+
allowedProtocols = ["workspace", "link", "file"],
|
|
1032
|
+
defaultCatalog = "default",
|
|
1033
|
+
autofix = true,
|
|
1034
|
+
reuseExistingCatalog = true,
|
|
1035
|
+
conflicts = "new-catalog",
|
|
1036
|
+
fields = DEFAULT_FIELDS$1,
|
|
1037
|
+
ignore = IGNORED_DEPENDENCIES
|
|
1038
|
+
} = options || {};
|
|
1039
|
+
for (const { packageName, specifier, property } of iterateDependencies(context, fields)) {
|
|
1040
|
+
if (ignore?.some((i) => i === packageName))
|
|
1041
|
+
continue;
|
|
1042
|
+
if (specifier.startsWith("catalog:"))
|
|
1043
|
+
continue;
|
|
1044
|
+
if (allowedProtocols?.some((p) => specifier.startsWith(p)))
|
|
1045
|
+
continue;
|
|
1046
|
+
const workspace2 = getPnpmWorkspace();
|
|
1047
|
+
if (!workspace2)
|
|
1048
|
+
return {};
|
|
1049
|
+
let targetCatalog = reuseExistingCatalog ? workspace2.getPackageCatalogs(packageName)[0] || defaultCatalog : defaultCatalog;
|
|
1050
|
+
const resolvedConflicts = workspace2.hasSpecifierConflicts(
|
|
1051
|
+
targetCatalog,
|
|
1052
|
+
packageName,
|
|
1053
|
+
specifier
|
|
1054
|
+
);
|
|
1055
|
+
let shouldFix = autofix;
|
|
1056
|
+
if (conflicts === "error") {
|
|
1057
|
+
if (resolvedConflicts.conflicts) {
|
|
1058
|
+
shouldFix = false;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
if (conflicts === "new-catalog" && resolvedConflicts.conflicts) {
|
|
1062
|
+
targetCatalog = resolvedConflicts.newCatalogName;
|
|
1063
|
+
}
|
|
1064
|
+
context.report({
|
|
1065
|
+
node: property.value,
|
|
1066
|
+
messageId: "expectCatalog",
|
|
1067
|
+
data: {
|
|
1068
|
+
specifier,
|
|
1069
|
+
packageName
|
|
1070
|
+
},
|
|
1071
|
+
fix: shouldFix ? (fixer) => {
|
|
1072
|
+
workspace2.queueChange(() => {
|
|
1073
|
+
workspace2.setPackage(targetCatalog, packageName, specifier);
|
|
1074
|
+
});
|
|
1075
|
+
return fixer.replaceText(
|
|
1076
|
+
property.value,
|
|
1077
|
+
targetCatalog === "default" ? JSON.stringify("catalog:") : JSON.stringify(`catalog:${targetCatalog}`)
|
|
1078
|
+
);
|
|
1079
|
+
} : void 0
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
return {};
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
var RULE_NAME$3 = "json-prefer-workspace-settings";
|
|
1086
|
+
var preferWorkspaceSettings = createEslintRule({
|
|
1087
|
+
name: RULE_NAME$3,
|
|
1088
|
+
meta: {
|
|
1089
|
+
type: "layout",
|
|
1090
|
+
docs: {
|
|
1091
|
+
description: "Prefer having pnpm settings in `pnpm-workspace.yaml` instead of `package.json`. This would requires pnpm v10.6+, see https://github.com/orgs/pnpm/discussions/9037."
|
|
1092
|
+
},
|
|
1093
|
+
fixable: "code",
|
|
1094
|
+
schema: [
|
|
1095
|
+
{
|
|
1096
|
+
type: "object",
|
|
1097
|
+
properties: {
|
|
1098
|
+
autofix: {
|
|
1099
|
+
type: "boolean",
|
|
1100
|
+
description: "Whether to autofix the linting error",
|
|
1101
|
+
default: true
|
|
1102
|
+
}
|
|
1103
|
+
},
|
|
1104
|
+
additionalProperties: false
|
|
1105
|
+
}
|
|
1106
|
+
],
|
|
1107
|
+
messages: {
|
|
1108
|
+
unexpectedPnpmSettings: "Unexpected pnpm settings in package.json, should move to pnpm-workspace.yaml"
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
defaultOptions: [{}],
|
|
1112
|
+
create(context, [options = {}]) {
|
|
1113
|
+
const {
|
|
1114
|
+
autofix = true
|
|
1115
|
+
} = options || {};
|
|
1116
|
+
const root = getPackageJsonRootNode(context);
|
|
1117
|
+
if (!root)
|
|
1118
|
+
return {};
|
|
1119
|
+
const pnpmNode = root.properties.find((property) => property.key.type === "JSONLiteral" && property.key.value === "pnpm");
|
|
1120
|
+
if (!pnpmNode)
|
|
1121
|
+
return {};
|
|
1122
|
+
const workspace2 = getPnpmWorkspace();
|
|
1123
|
+
if (!workspace2)
|
|
1124
|
+
return {};
|
|
1125
|
+
context.report({
|
|
1126
|
+
node: pnpmNode,
|
|
1127
|
+
messageId: "unexpectedPnpmSettings",
|
|
1128
|
+
fix: autofix ? (fixer) => {
|
|
1129
|
+
const json = JSON.parse(context.sourceCode.text);
|
|
1130
|
+
const pnpmSettings = json.pnpm;
|
|
1131
|
+
const flatValueParis = [];
|
|
1132
|
+
function traverse(value, paths) {
|
|
1133
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
1134
|
+
for (const key in value) {
|
|
1135
|
+
traverse(value[key], [...paths, key]);
|
|
1136
|
+
}
|
|
1137
|
+
} else {
|
|
1138
|
+
flatValueParis.push([paths, value]);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
__name(traverse, "traverse");
|
|
1142
|
+
traverse(pnpmSettings, []);
|
|
1143
|
+
workspace2.queueChange(() => {
|
|
1144
|
+
for (const [paths, value] of flatValueParis) {
|
|
1145
|
+
workspace2.setPath(paths, value);
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
1148
|
+
let start = pnpmNode.range[0];
|
|
1149
|
+
let end = pnpmNode.range[1];
|
|
1150
|
+
const before = context.sourceCode.getTokenBefore(pnpmNode);
|
|
1151
|
+
if (before)
|
|
1152
|
+
start = before.range[1];
|
|
1153
|
+
const after = context.sourceCode.getTokenAfter(pnpmNode);
|
|
1154
|
+
if (after?.type === "Punctuator" && after.value === ",")
|
|
1155
|
+
end = after.range[1];
|
|
1156
|
+
return fixer.removeRange([start, end]);
|
|
1157
|
+
} : void 0
|
|
1158
|
+
});
|
|
1159
|
+
return {};
|
|
1160
|
+
}
|
|
1161
|
+
});
|
|
1162
|
+
var RULE_NAME$2 = "json-valid-catalog";
|
|
1163
|
+
var DEFAULT_FIELDS = [
|
|
1164
|
+
"dependencies",
|
|
1165
|
+
"devDependencies",
|
|
1166
|
+
"optionalDependencies",
|
|
1167
|
+
"peerDependencies",
|
|
1168
|
+
"resolutions",
|
|
1169
|
+
"overrides",
|
|
1170
|
+
"pnpm.overrides"
|
|
1171
|
+
];
|
|
1172
|
+
var validCatalog = createEslintRule({
|
|
1173
|
+
name: RULE_NAME$2,
|
|
1174
|
+
meta: {
|
|
1175
|
+
type: "layout",
|
|
1176
|
+
docs: {
|
|
1177
|
+
description: "Enforce using valid catalog in `package.json`"
|
|
1178
|
+
},
|
|
1179
|
+
fixable: "code",
|
|
1180
|
+
schema: [
|
|
1181
|
+
{
|
|
1182
|
+
type: "object",
|
|
1183
|
+
properties: {
|
|
1184
|
+
autoInsert: {
|
|
1185
|
+
type: "boolean",
|
|
1186
|
+
description: "Whether to auto insert to catalog if missing",
|
|
1187
|
+
default: true
|
|
1188
|
+
},
|
|
1189
|
+
autoInsertDefaultSpecifier: {
|
|
1190
|
+
type: "string",
|
|
1191
|
+
description: "Default specifier to use when auto inserting to catalog",
|
|
1192
|
+
default: "^0.0.0"
|
|
1193
|
+
},
|
|
1194
|
+
autofix: {
|
|
1195
|
+
type: "boolean",
|
|
1196
|
+
description: "Whether to autofix the linting error",
|
|
1197
|
+
default: true
|
|
1198
|
+
},
|
|
1199
|
+
enforceNoConflict: {
|
|
1200
|
+
type: "boolean",
|
|
1201
|
+
description: "Whether to enforce no conflicts when adding packages to catalogs (will create version-specific catalogs)",
|
|
1202
|
+
default: true
|
|
1203
|
+
},
|
|
1204
|
+
fields: {
|
|
1205
|
+
type: "array",
|
|
1206
|
+
description: "Fields to check for catalog",
|
|
1207
|
+
default: DEFAULT_FIELDS
|
|
1208
|
+
}
|
|
1209
|
+
},
|
|
1210
|
+
additionalProperties: false
|
|
1211
|
+
}
|
|
1212
|
+
],
|
|
1213
|
+
messages: {
|
|
1214
|
+
invalidCatalog: 'Catalog "{{specifier}}" for package "{{packageName}}" is not defined in `pnpm-workspace.yaml`.'
|
|
1215
|
+
}
|
|
1216
|
+
},
|
|
1217
|
+
defaultOptions: [{}],
|
|
1218
|
+
create(context, [options = {}]) {
|
|
1219
|
+
const {
|
|
1220
|
+
autoInsert = true,
|
|
1221
|
+
autofix = true,
|
|
1222
|
+
autoInsertDefaultSpecifier = "^0.0.0",
|
|
1223
|
+
fields = DEFAULT_FIELDS
|
|
1224
|
+
} = options || {};
|
|
1225
|
+
for (const { packageName, specifier, property } of iterateDependencies(context, fields)) {
|
|
1226
|
+
if (!specifier.startsWith("catalog:"))
|
|
1227
|
+
continue;
|
|
1228
|
+
const workspace2 = getPnpmWorkspace();
|
|
1229
|
+
if (!workspace2)
|
|
1230
|
+
return {};
|
|
1231
|
+
const currentCatalog = specifier.replace(/^catalog:/, "").trim() || "default";
|
|
1232
|
+
const existingCatalogs = workspace2.getPackageCatalogs(packageName);
|
|
1233
|
+
if (!existingCatalogs.includes(currentCatalog)) {
|
|
1234
|
+
context.report({
|
|
1235
|
+
node: property.value,
|
|
1236
|
+
messageId: "invalidCatalog",
|
|
1237
|
+
data: {
|
|
1238
|
+
specifier,
|
|
1239
|
+
packageName
|
|
1240
|
+
},
|
|
1241
|
+
fix: !autofix || !autoInsert && !existingCatalogs.length ? void 0 : (fixer) => {
|
|
1242
|
+
let catalog = existingCatalogs[0];
|
|
1243
|
+
if (!catalog && autoInsert) {
|
|
1244
|
+
catalog = currentCatalog;
|
|
1245
|
+
workspace2.queueChange(() => {
|
|
1246
|
+
workspace2.setPackage(catalog, packageName, autoInsertDefaultSpecifier);
|
|
1247
|
+
}, "pre");
|
|
1248
|
+
}
|
|
1249
|
+
return fixer.replaceText(
|
|
1250
|
+
property.value,
|
|
1251
|
+
catalog === "default" ? JSON.stringify("catalog:") : JSON.stringify(`catalog:${catalog}`)
|
|
1252
|
+
);
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
return {};
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
var rules$2 = {
|
|
1261
|
+
"json-enforce-catalog": enforceCatalog,
|
|
1262
|
+
"json-valid-catalog": validCatalog,
|
|
1263
|
+
"json-prefer-workspace-settings": preferWorkspaceSettings
|
|
1264
|
+
};
|
|
1265
|
+
var RULE_NAME$1 = "yaml-no-duplicate-catalog-item";
|
|
1266
|
+
var noDuplicateCatalogItem = createEslintRule({
|
|
1267
|
+
name: RULE_NAME$1,
|
|
1268
|
+
meta: {
|
|
1269
|
+
type: "problem",
|
|
1270
|
+
docs: {
|
|
1271
|
+
description: "Disallow unused catalogs in `pnpm-workspace.yaml`"
|
|
1272
|
+
},
|
|
1273
|
+
fixable: "code",
|
|
1274
|
+
schema: [
|
|
1275
|
+
{
|
|
1276
|
+
type: "object",
|
|
1277
|
+
properties: {
|
|
1278
|
+
allow: {
|
|
1279
|
+
type: "array",
|
|
1280
|
+
items: { type: "string" }
|
|
1281
|
+
}
|
|
1282
|
+
},
|
|
1283
|
+
additionalProperties: false
|
|
1284
|
+
}
|
|
1285
|
+
],
|
|
1286
|
+
messages: {
|
|
1287
|
+
duplicateCatalogItem: 'Catalog item "{{name}}" is already defined in the "{{existingCatalog}}" catalog. You may want to remove one of them.'
|
|
1288
|
+
}
|
|
1289
|
+
},
|
|
1290
|
+
defaultOptions: [{}],
|
|
1291
|
+
create(context, [options = {}]) {
|
|
1292
|
+
if (basename(context.filename) !== "pnpm-workspace.yaml")
|
|
1293
|
+
return {};
|
|
1294
|
+
const workspace2 = getPnpmWorkspace();
|
|
1295
|
+
if (!workspace2 || normalize(workspace2.filepath) !== normalize(context.filename))
|
|
1296
|
+
return {};
|
|
1297
|
+
if (workspace2.hasChanged() || workspace2.hasQueue())
|
|
1298
|
+
return {};
|
|
1299
|
+
const { allow = [] } = options;
|
|
1300
|
+
workspace2.setContent(context.sourceCode.text);
|
|
1301
|
+
const json = workspace2.toJSON() || {};
|
|
1302
|
+
const exists = /* @__PURE__ */ new Map();
|
|
1303
|
+
const catalogs = {
|
|
1304
|
+
...json.catalogs,
|
|
1305
|
+
default: json.catalog
|
|
1306
|
+
};
|
|
1307
|
+
const doc = workspace2.getDocument();
|
|
1308
|
+
for (const [catalog, object] of Object.entries(catalogs)) {
|
|
1309
|
+
if (!object)
|
|
1310
|
+
continue;
|
|
1311
|
+
for (const key of Object.keys(object)) {
|
|
1312
|
+
if (allow.includes(key))
|
|
1313
|
+
continue;
|
|
1314
|
+
if (exists.has(key)) {
|
|
1315
|
+
const existingCatalog = exists.get(key);
|
|
1316
|
+
const node2 = doc.getIn(catalog === "default" ? ["catalog", key] : ["catalogs", catalog, key], true);
|
|
1317
|
+
const start = context.sourceCode.getLocFromIndex(node2.range[0]);
|
|
1318
|
+
const end = context.sourceCode.getLocFromIndex(node2.range[1]);
|
|
1319
|
+
context.report({
|
|
1320
|
+
loc: {
|
|
1321
|
+
start,
|
|
1322
|
+
end
|
|
1323
|
+
},
|
|
1324
|
+
messageId: "duplicateCatalogItem",
|
|
1325
|
+
data: {
|
|
1326
|
+
name: key,
|
|
1327
|
+
currentCatalog: catalog,
|
|
1328
|
+
existingCatalog
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
} else {
|
|
1332
|
+
exists.set(key, catalog);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
return {};
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
var RULE_NAME = "yaml-no-unused-catalog-item";
|
|
1340
|
+
var noUnusedCatalogItem = createEslintRule({
|
|
1341
|
+
name: RULE_NAME,
|
|
1342
|
+
meta: {
|
|
1343
|
+
type: "problem",
|
|
1344
|
+
docs: {
|
|
1345
|
+
description: "Disallow unused catalogs in `pnpm-workspace.yaml`"
|
|
1346
|
+
},
|
|
1347
|
+
fixable: "code",
|
|
1348
|
+
schema: [],
|
|
1349
|
+
messages: {
|
|
1350
|
+
unusedCatalogItem: 'Catalog item "{{catalogItem}}" is not used in any package.json.'
|
|
1351
|
+
}
|
|
1352
|
+
},
|
|
1353
|
+
defaultOptions: [],
|
|
1354
|
+
create(context) {
|
|
1355
|
+
if (basename(context.filename) !== "pnpm-workspace.yaml")
|
|
1356
|
+
return {};
|
|
1357
|
+
const workspace2 = getPnpmWorkspace();
|
|
1358
|
+
if (!workspace2 || normalize(workspace2.filepath) !== normalize(context.filename))
|
|
1359
|
+
return {};
|
|
1360
|
+
if (workspace2.hasChanged() || workspace2.hasQueue())
|
|
1361
|
+
return {};
|
|
1362
|
+
workspace2.setContent(context.sourceCode.text);
|
|
1363
|
+
const parsed = workspace2.toJSON() || {};
|
|
1364
|
+
const root = resolve(dirname(context.filename));
|
|
1365
|
+
const entries = /* @__PURE__ */ new Map();
|
|
1366
|
+
const doc = workspace2.getDocument();
|
|
1367
|
+
const catalogs = {
|
|
1368
|
+
default: doc.getIn(["catalog"])
|
|
1369
|
+
};
|
|
1370
|
+
for (const item of doc.getIn(["catalogs"])?.items || [])
|
|
1371
|
+
catalogs[String(item.key)] = item.value;
|
|
1372
|
+
for (const [catalog, map] of Object.entries(catalogs)) {
|
|
1373
|
+
if (!map)
|
|
1374
|
+
continue;
|
|
1375
|
+
for (const item of map.items) {
|
|
1376
|
+
entries.set(`${String(item.key)}:${catalog}`, item);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
if (entries.size === 0)
|
|
1380
|
+
return {};
|
|
1381
|
+
const dirs = parsed.packages ? globSync(parsed.packages, {
|
|
1382
|
+
cwd: root,
|
|
1383
|
+
dot: false,
|
|
1384
|
+
ignore: [
|
|
1385
|
+
"**/node_modules/**",
|
|
1386
|
+
"**/dist/**",
|
|
1387
|
+
"**/build/**",
|
|
1388
|
+
"**/dist/**",
|
|
1389
|
+
"**/dist/**"
|
|
1390
|
+
],
|
|
1391
|
+
absolute: true,
|
|
1392
|
+
expandDirectories: false,
|
|
1393
|
+
onlyDirectories: true
|
|
1394
|
+
}) : [];
|
|
1395
|
+
dirs.push(root);
|
|
1396
|
+
const packages = dirs.map((dir) => resolve(dir, "package.json")).filter((x) => existsSync(x)).sort();
|
|
1397
|
+
const FIELDS = [
|
|
1398
|
+
"dependencies",
|
|
1399
|
+
"devDependencies",
|
|
1400
|
+
"peerDependencies",
|
|
1401
|
+
"optionalDependencies",
|
|
1402
|
+
"overrides",
|
|
1403
|
+
"resolutions",
|
|
1404
|
+
"pnpm.overrides"
|
|
1405
|
+
];
|
|
1406
|
+
for (const path of packages) {
|
|
1407
|
+
const pkg = JSON.parse(readFileSync(path, "utf-8"));
|
|
1408
|
+
for (const field of FIELDS) {
|
|
1409
|
+
const map = getObjectPath(pkg, field.split("."));
|
|
1410
|
+
if (!map)
|
|
1411
|
+
continue;
|
|
1412
|
+
for (const [name2, value] of Object.entries(map)) {
|
|
1413
|
+
if (!value.startsWith("catalog:"))
|
|
1414
|
+
continue;
|
|
1415
|
+
const catalog = value.slice(8) || "default";
|
|
1416
|
+
const key = `${name2}:${catalog}`;
|
|
1417
|
+
entries.delete(key);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
if (entries.size > 0) {
|
|
1422
|
+
for (const [key, value] of Array.from(entries.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {
|
|
1423
|
+
const start = context.sourceCode.getLocFromIndex(value.key.range[0]);
|
|
1424
|
+
const end = context.sourceCode.getLocFromIndex(value.value.range.at(-1));
|
|
1425
|
+
context.report({
|
|
1426
|
+
loc: {
|
|
1427
|
+
start,
|
|
1428
|
+
end
|
|
1429
|
+
},
|
|
1430
|
+
messageId: "unusedCatalogItem",
|
|
1431
|
+
data: { catalogItem: key }
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
return {};
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
function getObjectPath(obj, path) {
|
|
1439
|
+
let current = obj;
|
|
1440
|
+
for (const key of path) {
|
|
1441
|
+
current = current[key];
|
|
1442
|
+
if (!current)
|
|
1443
|
+
return void 0;
|
|
1444
|
+
}
|
|
1445
|
+
return current;
|
|
1446
|
+
}
|
|
1447
|
+
__name(getObjectPath, "getObjectPath");
|
|
1448
|
+
var rules$1 = {
|
|
1449
|
+
"yaml-no-unused-catalog-item": noUnusedCatalogItem,
|
|
1450
|
+
"yaml-no-duplicate-catalog-item": noDuplicateCatalogItem
|
|
1451
|
+
};
|
|
1452
|
+
var rules = {
|
|
1453
|
+
...rules$2,
|
|
1454
|
+
...rules$1
|
|
1455
|
+
};
|
|
1456
|
+
var plugin = {
|
|
1457
|
+
meta: {
|
|
1458
|
+
name,
|
|
1459
|
+
version
|
|
1460
|
+
},
|
|
1461
|
+
rules
|
|
1462
|
+
};
|
|
1463
|
+
var configsJson = [
|
|
1464
|
+
{
|
|
1465
|
+
name: "pnpm/package.json",
|
|
1466
|
+
files: [
|
|
1467
|
+
"package.json",
|
|
1468
|
+
"**/package.json"
|
|
1469
|
+
],
|
|
1470
|
+
languageOptions: {
|
|
1471
|
+
parser: jsoncParser
|
|
1472
|
+
},
|
|
1473
|
+
plugins: {
|
|
1474
|
+
pnpm: plugin
|
|
1475
|
+
},
|
|
1476
|
+
rules: {
|
|
1477
|
+
"pnpm/json-enforce-catalog": "error",
|
|
1478
|
+
"pnpm/json-valid-catalog": "error",
|
|
1479
|
+
"pnpm/json-prefer-workspace-settings": "error"
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
];
|
|
1483
|
+
var configsYaml = [
|
|
1484
|
+
{
|
|
1485
|
+
name: "pnpm/pnpm-workspace-yaml",
|
|
1486
|
+
files: ["pnpm-workspace.yaml"],
|
|
1487
|
+
languageOptions: {
|
|
1488
|
+
parser: yamlParser
|
|
1489
|
+
},
|
|
1490
|
+
plugins: {
|
|
1491
|
+
pnpm: plugin
|
|
1492
|
+
},
|
|
1493
|
+
rules: {
|
|
1494
|
+
"pnpm/yaml-no-unused-catalog-item": "error",
|
|
1495
|
+
"pnpm/yaml-no-duplicate-catalog-item": "error"
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
];
|
|
1499
|
+
var configs = {
|
|
1500
|
+
recommended: [
|
|
1501
|
+
...configsJson
|
|
1502
|
+
// Yaml support is still experimental
|
|
1503
|
+
// ...configsYaml,
|
|
1504
|
+
],
|
|
1505
|
+
json: configsJson,
|
|
1506
|
+
yaml: configsYaml
|
|
1507
|
+
};
|
|
1508
|
+
plugin.configs = configs;
|
|
1509
|
+
|
|
1510
|
+
// src/plugins.ts
|
|
813
1511
|
import { default as default7 } from "eslint-plugin-prettier";
|
|
814
1512
|
import { default as default8 } from "eslint-plugin-unicorn";
|
|
815
1513
|
import { default as default9 } from "eslint-plugin-unused-imports";
|
|
@@ -2705,19 +3403,26 @@ __name(perfectionist, "perfectionist");
|
|
|
2705
3403
|
|
|
2706
3404
|
// src/configs/pnpm.ts
|
|
2707
3405
|
async function pnpm(options = {}) {
|
|
2708
|
-
const { overrides = {},
|
|
3406
|
+
const { overrides = {}, ignore = [
|
|
2709
3407
|
"typescript"
|
|
2710
3408
|
] } = options;
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
3409
|
+
await ensurePackages([
|
|
3410
|
+
"jsonc-eslint-parser",
|
|
3411
|
+
"yaml-eslint-parser"
|
|
3412
|
+
]);
|
|
3413
|
+
const [parserJsonc, parserYaml] = await Promise.all([
|
|
3414
|
+
interopDefault(import("jsonc-eslint-parser")),
|
|
3415
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
2714
3416
|
]);
|
|
2715
3417
|
return [
|
|
2716
3418
|
{
|
|
2717
|
-
name: "storm/pnpm",
|
|
3419
|
+
name: "storm/pnpm/setup",
|
|
2718
3420
|
plugins: {
|
|
2719
|
-
pnpm:
|
|
2720
|
-
}
|
|
3421
|
+
pnpm: plugin
|
|
3422
|
+
}
|
|
3423
|
+
},
|
|
3424
|
+
{
|
|
3425
|
+
name: "storm/pnpm/package-json",
|
|
2721
3426
|
ignores: [
|
|
2722
3427
|
"**/node_modules/**",
|
|
2723
3428
|
"**/dist/**"
|
|
@@ -2730,22 +3435,46 @@ async function pnpm(options = {}) {
|
|
|
2730
3435
|
parser: parserJsonc
|
|
2731
3436
|
},
|
|
2732
3437
|
rules: {
|
|
2733
|
-
"pnpm/enforce-catalog": [
|
|
3438
|
+
"pnpm/json-enforce-catalog": [
|
|
2734
3439
|
"error",
|
|
2735
3440
|
{
|
|
2736
|
-
|
|
3441
|
+
ignore,
|
|
2737
3442
|
autofix: true,
|
|
2738
|
-
reuseExistingCatalog: true,
|
|
2739
3443
|
allowedProtocols: [
|
|
2740
3444
|
"workspace",
|
|
2741
3445
|
"link",
|
|
2742
3446
|
"file"
|
|
2743
3447
|
],
|
|
2744
|
-
defaultCatalog: "default"
|
|
3448
|
+
defaultCatalog: "default",
|
|
3449
|
+
reuseExistingCatalog: true,
|
|
3450
|
+
conflicts: "new-catalog",
|
|
3451
|
+
fields: [
|
|
3452
|
+
"dependencies",
|
|
3453
|
+
"devDependencies"
|
|
3454
|
+
]
|
|
2745
3455
|
}
|
|
2746
3456
|
],
|
|
2747
|
-
"pnpm/valid-catalog": "error",
|
|
2748
|
-
"pnpm/prefer-workspace-settings": "error",
|
|
3457
|
+
"pnpm/json-valid-catalog": "error",
|
|
3458
|
+
"pnpm/json-prefer-workspace-settings": "error",
|
|
3459
|
+
...overrides
|
|
3460
|
+
}
|
|
3461
|
+
},
|
|
3462
|
+
{
|
|
3463
|
+
name: "storm/pnpm/pnpm-workspace-yaml",
|
|
3464
|
+
ignores: [
|
|
3465
|
+
"**/node_modules/**",
|
|
3466
|
+
"**/dist/**"
|
|
3467
|
+
],
|
|
3468
|
+
files: [
|
|
3469
|
+
"pnpm-workspace.yaml",
|
|
3470
|
+
"**/pnpm-workspace.yaml"
|
|
3471
|
+
],
|
|
3472
|
+
languageOptions: {
|
|
3473
|
+
parser: parserYaml
|
|
3474
|
+
},
|
|
3475
|
+
rules: {
|
|
3476
|
+
"pnpm/yaml-no-unused-catalog-item": "error",
|
|
3477
|
+
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
2749
3478
|
...overrides
|
|
2750
3479
|
}
|
|
2751
3480
|
}
|
|
@@ -2983,15 +3712,15 @@ async function reactNative(options = {}) {
|
|
|
2983
3712
|
__name(reactNative, "reactNative");
|
|
2984
3713
|
|
|
2985
3714
|
// src/configs/regexp.ts
|
|
2986
|
-
import { configs } from "eslint-plugin-regexp";
|
|
3715
|
+
import { configs as configs2 } from "eslint-plugin-regexp";
|
|
2987
3716
|
async function regexp(options = {}) {
|
|
2988
|
-
const config2 =
|
|
2989
|
-
const
|
|
3717
|
+
const config2 = configs2["flat/recommended"];
|
|
3718
|
+
const rules2 = {
|
|
2990
3719
|
...config2.rules
|
|
2991
3720
|
};
|
|
2992
3721
|
if (options.level === "warn") {
|
|
2993
|
-
for (const key in
|
|
2994
|
-
if (
|
|
3722
|
+
for (const key in rules2) {
|
|
3723
|
+
if (rules2[key] === "error") rules2[key] = "warn";
|
|
2995
3724
|
}
|
|
2996
3725
|
}
|
|
2997
3726
|
return [
|
|
@@ -2999,7 +3728,7 @@ async function regexp(options = {}) {
|
|
|
2999
3728
|
...config2,
|
|
3000
3729
|
name: "storm/regexp/rules",
|
|
3001
3730
|
rules: {
|
|
3002
|
-
...
|
|
3731
|
+
...rules2,
|
|
3003
3732
|
"regexp/no-unused-capturing-group": [
|
|
3004
3733
|
"error",
|
|
3005
3734
|
{
|
|
@@ -3918,17 +4647,17 @@ function getStormConfig(options, ...userConfigs) {
|
|
|
3918
4647
|
}
|
|
3919
4648
|
const stylisticOptions = !options.stylistic ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
3920
4649
|
if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
|
|
3921
|
-
const
|
|
4650
|
+
const configs3 = [];
|
|
3922
4651
|
if (enableGitignore) {
|
|
3923
4652
|
if (typeof enableGitignore !== "boolean") {
|
|
3924
|
-
|
|
4653
|
+
configs3.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
|
|
3925
4654
|
r({
|
|
3926
4655
|
name: "storm/gitignore",
|
|
3927
4656
|
...enableGitignore
|
|
3928
4657
|
})
|
|
3929
4658
|
]));
|
|
3930
4659
|
} else {
|
|
3931
|
-
|
|
4660
|
+
configs3.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
|
|
3932
4661
|
r({
|
|
3933
4662
|
name: "storm/gitignore",
|
|
3934
4663
|
strict: false
|
|
@@ -3941,7 +4670,7 @@ function getStormConfig(options, ...userConfigs) {
|
|
|
3941
4670
|
if (!tsconfigPath) {
|
|
3942
4671
|
tsconfigPath = getTsConfigPath();
|
|
3943
4672
|
}
|
|
3944
|
-
|
|
4673
|
+
configs3.push(ignores(options.ignores), javascript({
|
|
3945
4674
|
repositoryName,
|
|
3946
4675
|
globals,
|
|
3947
4676
|
lineEndings,
|
|
@@ -3955,19 +4684,19 @@ function getStormConfig(options, ...userConfigs) {
|
|
|
3955
4684
|
json: options.jsonc !== false
|
|
3956
4685
|
}));
|
|
3957
4686
|
if (!stylisticOptions) {
|
|
3958
|
-
|
|
4687
|
+
configs3.push(prettier());
|
|
3959
4688
|
}
|
|
3960
4689
|
if (enableCSpell) {
|
|
3961
|
-
|
|
4690
|
+
configs3.push(cspell(resolveSubOptions(options, "cspell")));
|
|
3962
4691
|
}
|
|
3963
4692
|
if (enableUnicorn) {
|
|
3964
|
-
|
|
4693
|
+
configs3.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
3965
4694
|
}
|
|
3966
4695
|
if (enableJsx) {
|
|
3967
|
-
|
|
4696
|
+
configs3.push(jsx());
|
|
3968
4697
|
}
|
|
3969
4698
|
if (enableTypeScript) {
|
|
3970
|
-
|
|
4699
|
+
configs3.push(typescript({
|
|
3971
4700
|
...typescriptOptions,
|
|
3972
4701
|
componentExts,
|
|
3973
4702
|
overrides: getOverrides(options, "typescript"),
|
|
@@ -3975,7 +4704,7 @@ function getStormConfig(options, ...userConfigs) {
|
|
|
3975
4704
|
}));
|
|
3976
4705
|
}
|
|
3977
4706
|
if (stylisticOptions) {
|
|
3978
|
-
|
|
4707
|
+
configs3.push(stylistic({
|
|
3979
4708
|
...stylisticOptions,
|
|
3980
4709
|
lineEndings,
|
|
3981
4710
|
lessOpinionated: options.lessOpinionated,
|
|
@@ -3983,90 +4712,90 @@ function getStormConfig(options, ...userConfigs) {
|
|
|
3983
4712
|
}));
|
|
3984
4713
|
}
|
|
3985
4714
|
if (enableRegexp) {
|
|
3986
|
-
|
|
4715
|
+
configs3.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
3987
4716
|
}
|
|
3988
4717
|
if (options.test ?? true) {
|
|
3989
|
-
|
|
4718
|
+
configs3.push(test({
|
|
3990
4719
|
isInEditor,
|
|
3991
4720
|
overrides: getOverrides(options, "test")
|
|
3992
4721
|
}));
|
|
3993
4722
|
}
|
|
3994
4723
|
if (enableGraphQL) {
|
|
3995
|
-
|
|
4724
|
+
configs3.push(graphql(resolveSubOptions(options, "graphql")));
|
|
3996
4725
|
}
|
|
3997
4726
|
if (enableReact) {
|
|
3998
|
-
|
|
4727
|
+
configs3.push(react({
|
|
3999
4728
|
...typescriptOptions,
|
|
4000
4729
|
overrides: getOverrides(options, "react"),
|
|
4001
4730
|
tsconfigPath
|
|
4002
4731
|
}));
|
|
4003
4732
|
}
|
|
4004
4733
|
if (enableReactNative) {
|
|
4005
|
-
|
|
4734
|
+
configs3.push(reactNative({
|
|
4006
4735
|
...resolveSubOptions(options, "react-native"),
|
|
4007
4736
|
overrides: getOverrides(options, "react-native")
|
|
4008
4737
|
}));
|
|
4009
4738
|
}
|
|
4010
4739
|
if (enableNext) {
|
|
4011
|
-
|
|
4740
|
+
configs3.push(next(resolveSubOptions(options, "next")));
|
|
4012
4741
|
}
|
|
4013
4742
|
if (enableStorybook) {
|
|
4014
|
-
|
|
4743
|
+
configs3.push(storybook(resolveSubOptions(options, "storybook")));
|
|
4015
4744
|
}
|
|
4016
4745
|
if (enableUnoCSS) {
|
|
4017
|
-
|
|
4746
|
+
configs3.push(unocss({
|
|
4018
4747
|
...resolveSubOptions(options, "unocss"),
|
|
4019
4748
|
overrides: getOverrides(options, "unocss")
|
|
4020
4749
|
}));
|
|
4021
4750
|
}
|
|
4022
4751
|
if (enableAstro) {
|
|
4023
|
-
|
|
4752
|
+
configs3.push(astro({
|
|
4024
4753
|
overrides: getOverrides(options, "astro"),
|
|
4025
4754
|
stylistic: stylisticOptions
|
|
4026
4755
|
}));
|
|
4027
4756
|
}
|
|
4028
4757
|
if (options.pnpm ?? true) {
|
|
4029
|
-
|
|
4758
|
+
configs3.push(pnpm({
|
|
4030
4759
|
overrides: getOverrides(options, "pnpm"),
|
|
4031
|
-
|
|
4760
|
+
ignore: typeof options.pnpm !== "boolean" ? options.pnpm?.ignore : void 0
|
|
4032
4761
|
}));
|
|
4033
4762
|
}
|
|
4034
4763
|
if (options.jsonc ?? true) {
|
|
4035
|
-
|
|
4764
|
+
configs3.push(jsonc({
|
|
4036
4765
|
overrides: getOverrides(options, "jsonc"),
|
|
4037
4766
|
stylistic: stylisticOptions
|
|
4038
4767
|
}), sortTsconfig());
|
|
4039
4768
|
if (stylisticOptions) {
|
|
4040
|
-
|
|
4769
|
+
configs3.push(sortPackageJson());
|
|
4041
4770
|
}
|
|
4042
4771
|
}
|
|
4043
4772
|
if (options.yaml ?? true) {
|
|
4044
|
-
|
|
4773
|
+
configs3.push(yaml({
|
|
4045
4774
|
overrides: getOverrides(options, "yaml"),
|
|
4046
4775
|
stylistic: stylisticOptions
|
|
4047
4776
|
}));
|
|
4048
4777
|
}
|
|
4049
4778
|
if (options.toml ?? true) {
|
|
4050
|
-
|
|
4779
|
+
configs3.push(toml({
|
|
4051
4780
|
overrides: getOverrides(options, "toml"),
|
|
4052
4781
|
stylistic: stylisticOptions
|
|
4053
4782
|
}));
|
|
4054
4783
|
}
|
|
4055
4784
|
if (options.markdown ?? true) {
|
|
4056
|
-
|
|
4785
|
+
configs3.push(markdown({
|
|
4057
4786
|
componentExts,
|
|
4058
4787
|
overrides: getOverrides(options, "markdown")
|
|
4059
4788
|
}));
|
|
4060
4789
|
}
|
|
4061
4790
|
if (options.mdx ?? true) {
|
|
4062
|
-
|
|
4791
|
+
configs3.push(mdx({
|
|
4063
4792
|
overrides: getOverrides(options, "mdx")
|
|
4064
4793
|
}));
|
|
4065
4794
|
}
|
|
4066
4795
|
if (options.formatters) {
|
|
4067
|
-
|
|
4796
|
+
configs3.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
4068
4797
|
}
|
|
4069
|
-
|
|
4798
|
+
configs3.push(disables());
|
|
4070
4799
|
if ("files" in options) {
|
|
4071
4800
|
throw new Error('[@storm-software/eslint] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.');
|
|
4072
4801
|
}
|
|
@@ -4076,11 +4805,11 @@ function getStormConfig(options, ...userConfigs) {
|
|
|
4076
4805
|
}
|
|
4077
4806
|
return acc;
|
|
4078
4807
|
}, {});
|
|
4079
|
-
if (Object.keys(fusedConfig).length)
|
|
4808
|
+
if (Object.keys(fusedConfig).length) configs3.push([
|
|
4080
4809
|
fusedConfig
|
|
4081
4810
|
]);
|
|
4082
4811
|
let composer = new FlatConfigComposer();
|
|
4083
|
-
composer = composer.append(...
|
|
4812
|
+
composer = composer.append(...configs3, ...userConfigs);
|
|
4084
4813
|
if (autoRenamePlugins) {
|
|
4085
4814
|
composer = composer.renamePlugins(defaultPluginRenaming);
|
|
4086
4815
|
}
|