@zayne-labs/eslint-config 0.11.5 → 0.11.7
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 +204 -189
- package/dist/cli/index.js +14 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/constants/defaults.d.ts +37 -0
- package/dist/constants/defaults.js +3 -0
- package/dist/defaults-Ddo61INE.js +64 -0
- package/dist/defaults-Ddo61INE.js.map +1 -0
- package/dist/index.d.ts +973 -508
- package/dist/index.js +187 -167
- package/dist/index.js.map +1 -1
- package/dist/src-nCsOdMZJ.js +671 -0
- package/dist/src-nCsOdMZJ.js.map +1 -0
- package/package.json +36 -39
- package/dist/src-Cr2NVJeY.js +0 -1852
- package/dist/src-Cr2NVJeY.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { a as getDefaultTailwindcssBetterSettings, i as getDefaultPluginRenameMap, n as getDefaultAllowedNextJsExportNames, r as getDefaultAllowedReactRouterExportNames, t as getDefaultAllowedDependencies } from "./defaults-Ddo61INE.js";
|
|
1
2
|
import { assert, defineEnum, isFunction, isObject as isObject$1, isObjectAndNotArray } from "@zayne-labs/toolkit-type-helpers";
|
|
2
3
|
import { fileURLToPath } from "node:url";
|
|
3
4
|
import { isPackageExists } from "local-pkg";
|
|
@@ -5,6 +6,10 @@ import { globalIgnores } from "eslint/config";
|
|
|
5
6
|
import globals from "globals";
|
|
6
7
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
7
8
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
9
|
+
import process$1 from "node:process";
|
|
10
|
+
import fsp from "node:fs/promises";
|
|
11
|
+
import fs from "node:fs";
|
|
12
|
+
import path from "node:path";
|
|
8
13
|
|
|
9
14
|
//#region src/globs.ts
|
|
10
15
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -21,8 +26,8 @@ const GLOB_SCSS = "**/*.scss";
|
|
|
21
26
|
const GLOB_JSON = "**/*.json";
|
|
22
27
|
const GLOB_JSON5 = "**/*.json5";
|
|
23
28
|
const GLOB_JSONC = "**/*.jsonc";
|
|
24
|
-
const GLOB_MARKDOWN = "**/*.md";
|
|
25
|
-
const GLOB_MARKDOWN_IN_MARKDOWN =
|
|
29
|
+
const GLOB_MARKDOWN = "**/*.md?(x)";
|
|
30
|
+
const GLOB_MARKDOWN_IN_MARKDOWN = `${GLOB_MARKDOWN}/*.md?(x)`;
|
|
26
31
|
const GLOB_SVELTE = "**/*.svelte?(.{js,ts})";
|
|
27
32
|
const GLOB_VUE = "**/*.vue";
|
|
28
33
|
const GLOB_YAML = "**/*.y?(a)ml";
|
|
@@ -239,7 +244,9 @@ const ensurePackages = async (packages) => {
|
|
|
239
244
|
if (nonExistingPackages.length === 0) return;
|
|
240
245
|
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 (await import("@antfu/install-pkg")).installPackage(nonExistingPackages, { dev: true });
|
|
241
246
|
};
|
|
242
|
-
const resolveOptions = (option) =>
|
|
247
|
+
const resolveOptions = (option) => {
|
|
248
|
+
return isObject(option) ? option : {};
|
|
249
|
+
};
|
|
243
250
|
const parserPlain = {
|
|
244
251
|
meta: { name: "parser-plain" },
|
|
245
252
|
parseForESLint: (code) => ({
|
|
@@ -332,6 +339,7 @@ const depend = async (options = {}) => {
|
|
|
332
339
|
const { files = [GLOB_SRC], overrides } = options;
|
|
333
340
|
await ensurePackages(["eslint-plugin-depend"]);
|
|
334
341
|
const [eslintPluginDepend, jsoncParser] = await Promise.all([interopDefault(import("eslint-plugin-depend")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
342
|
+
const dependRules = { "depend/ban-dependencies": ["error", { allowed: getDefaultAllowedDependencies() }] };
|
|
335
343
|
return [
|
|
336
344
|
{
|
|
337
345
|
name: "zayne/depend/setup",
|
|
@@ -339,9 +347,9 @@ const depend = async (options = {}) => {
|
|
|
339
347
|
},
|
|
340
348
|
{
|
|
341
349
|
files,
|
|
342
|
-
name: "zayne/depend/
|
|
350
|
+
name: "zayne/depend/rules",
|
|
343
351
|
rules: {
|
|
344
|
-
...
|
|
352
|
+
...dependRules,
|
|
345
353
|
...overrides
|
|
346
354
|
}
|
|
347
355
|
},
|
|
@@ -351,7 +359,7 @@ const depend = async (options = {}) => {
|
|
|
351
359
|
name: "zayne/depend/recommended/package-json",
|
|
352
360
|
plugins: { depend: eslintPluginDepend },
|
|
353
361
|
rules: {
|
|
354
|
-
...
|
|
362
|
+
...dependRules,
|
|
355
363
|
...overrides
|
|
356
364
|
}
|
|
357
365
|
}
|
|
@@ -375,7 +383,9 @@ const expo = async (options = {}) => {
|
|
|
375
383
|
//#endregion
|
|
376
384
|
//#region src/configs/ignores.ts
|
|
377
385
|
const ignores = (userIgnores = []) => {
|
|
378
|
-
|
|
386
|
+
const initIgnores = [...GLOB_EXCLUDE];
|
|
387
|
+
const resolvedUserIgnores = isFunction(userIgnores) ? userIgnores(initIgnores) : userIgnores;
|
|
388
|
+
return [globalIgnores([...initIgnores, ...resolvedUserIgnores], "zayne/defaults/ignores")];
|
|
379
389
|
};
|
|
380
390
|
const gitIgnores = async (options) => {
|
|
381
391
|
return [(await interopDefault(import("eslint-config-flat-gitignore")))({
|
|
@@ -788,8 +798,13 @@ const jsonc = async (options = {}) => {
|
|
|
788
798
|
GLOB_JSON,
|
|
789
799
|
GLOB_JSON5,
|
|
790
800
|
GLOB_JSONC
|
|
791
|
-
], overrides
|
|
801
|
+
], overrides } = options;
|
|
792
802
|
const [eslintPluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
803
|
+
const recommendedRules = eslintPluginJsonc.configs["flat/recommended-with-jsonc"].map((config) => config.rules).reduce((accumulator, rules) => ({
|
|
804
|
+
...accumulator,
|
|
805
|
+
...rules
|
|
806
|
+
}), {});
|
|
807
|
+
const disablePrettierRules = eslintPluginJsonc.configs["flat/prettier"].at(-1)?.rules;
|
|
793
808
|
return [
|
|
794
809
|
{
|
|
795
810
|
name: "zayne/jsonc/setup",
|
|
@@ -800,55 +815,20 @@ const jsonc = async (options = {}) => {
|
|
|
800
815
|
languageOptions: { parser: parserJsonc },
|
|
801
816
|
name: "zayne/jsonc/parser"
|
|
802
817
|
},
|
|
818
|
+
{
|
|
819
|
+
files,
|
|
820
|
+
name: "zayne/jsonc/recommended",
|
|
821
|
+
rules: recommendedRules
|
|
822
|
+
},
|
|
803
823
|
{
|
|
804
824
|
files,
|
|
805
825
|
name: "zayne/jsonc/rules",
|
|
806
|
-
rules: {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
"jsonc/no-floating-decimal": "error",
|
|
813
|
-
"jsonc/no-hexadecimal-numeric-literals": "error",
|
|
814
|
-
"jsonc/no-infinity": "error",
|
|
815
|
-
"jsonc/no-multi-str": "error",
|
|
816
|
-
"jsonc/no-nan": "error",
|
|
817
|
-
"jsonc/no-number-props": "error",
|
|
818
|
-
"jsonc/no-numeric-separators": "error",
|
|
819
|
-
"jsonc/no-octal": "error",
|
|
820
|
-
"jsonc/no-octal-escape": "error",
|
|
821
|
-
"jsonc/no-octal-numeric-literals": "error",
|
|
822
|
-
"jsonc/no-parenthesized": "error",
|
|
823
|
-
"jsonc/no-plus-sign": "error",
|
|
824
|
-
"jsonc/no-regexp-literals": "error",
|
|
825
|
-
"jsonc/no-sparse-arrays": "error",
|
|
826
|
-
"jsonc/no-template-literals": "error",
|
|
827
|
-
"jsonc/no-undefined-value": "error",
|
|
828
|
-
"jsonc/no-unicode-codepoint-escapes": "error",
|
|
829
|
-
"jsonc/no-useless-escape": "error",
|
|
830
|
-
"jsonc/space-unary-ops": "error",
|
|
831
|
-
"jsonc/valid-json-number": "error",
|
|
832
|
-
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
833
|
-
...stylistic$1 && {
|
|
834
|
-
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
835
|
-
"jsonc/comma-dangle": ["error", "never"],
|
|
836
|
-
"jsonc/comma-style": ["error", "last"],
|
|
837
|
-
"jsonc/key-spacing": ["error", {
|
|
838
|
-
afterColon: true,
|
|
839
|
-
beforeColon: false
|
|
840
|
-
}],
|
|
841
|
-
"jsonc/object-curly-newline": ["error", {
|
|
842
|
-
consistent: true,
|
|
843
|
-
multiline: true
|
|
844
|
-
}],
|
|
845
|
-
"jsonc/object-curly-spacing": ["error", "always"],
|
|
846
|
-
"jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
847
|
-
"jsonc/quote-props": "error",
|
|
848
|
-
"jsonc/quotes": "error"
|
|
849
|
-
},
|
|
850
|
-
...overrides
|
|
851
|
-
}
|
|
826
|
+
rules: { ...overrides }
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
files,
|
|
830
|
+
name: "zayne/jsonc/disables-prettier",
|
|
831
|
+
rules: disablePrettierRules
|
|
852
832
|
}
|
|
853
833
|
];
|
|
854
834
|
};
|
|
@@ -914,11 +894,6 @@ const markdown = async (options = {}) => {
|
|
|
914
894
|
name: "zayne/markdown/recommended",
|
|
915
895
|
rules: recommendedRules
|
|
916
896
|
},
|
|
917
|
-
{
|
|
918
|
-
files,
|
|
919
|
-
name: "zayne/markdown/rules",
|
|
920
|
-
rules: { ...overrides }
|
|
921
|
-
},
|
|
922
897
|
{
|
|
923
898
|
files: [
|
|
924
899
|
...files,
|
|
@@ -952,7 +927,8 @@ const markdown = async (options = {}) => {
|
|
|
952
927
|
"ts-eslint/no-use-before-define": "off",
|
|
953
928
|
"unicode-bom": "off",
|
|
954
929
|
"unicorn/filename-case": "off",
|
|
955
|
-
"unicorn/prefer-export-from": "off"
|
|
930
|
+
"unicorn/prefer-export-from": "off",
|
|
931
|
+
...overrides
|
|
956
932
|
}
|
|
957
933
|
}
|
|
958
934
|
];
|
|
@@ -1083,87 +1059,115 @@ const perfectionist = async (options = {}) => {
|
|
|
1083
1059
|
//#endregion
|
|
1084
1060
|
//#region src/configs/pnpm.ts
|
|
1085
1061
|
async function pnpm(options = {}) {
|
|
1086
|
-
const { overrides } = options;
|
|
1062
|
+
const { catalogs = false, json = true, overrides, sort = true, yaml: yaml$1 = true } = options;
|
|
1087
1063
|
await ensurePackages(["eslint-plugin-pnpm"]);
|
|
1088
|
-
const [eslintPluginPnpm, yamlParser, jsoncParser] = await Promise.all([
|
|
1064
|
+
const [eslintPluginPnpm, yamlParser, eslintPluginYaml, jsoncParser] = await Promise.all([
|
|
1089
1065
|
interopDefault(import("eslint-plugin-pnpm")),
|
|
1090
1066
|
interopDefault(import("yaml-eslint-parser")),
|
|
1067
|
+
interopDefault(import("eslint-plugin-yml")),
|
|
1091
1068
|
interopDefault(import("jsonc-eslint-parser"))
|
|
1092
1069
|
]);
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
{
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
"pnpm/json-prefer-workspace-settings": "error",
|
|
1105
|
-
"pnpm/json-valid-catalog": "error",
|
|
1106
|
-
...overrides?.json
|
|
1107
|
-
}
|
|
1108
|
-
},
|
|
1109
|
-
{
|
|
1110
|
-
files: ["pnpm-workspace.yaml"],
|
|
1111
|
-
languageOptions: { parser: yamlParser },
|
|
1112
|
-
name: "zayne/pnpm/pnpm-workspace-yaml/rules",
|
|
1113
|
-
rules: {
|
|
1114
|
-
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
1115
|
-
"pnpm/yaml-no-unused-catalog-item": "error",
|
|
1116
|
-
...overrides?.yaml
|
|
1117
|
-
}
|
|
1070
|
+
const configs = [];
|
|
1071
|
+
if (json) configs.push({
|
|
1072
|
+
files: ["package.json", "**/package.json"],
|
|
1073
|
+
languageOptions: { parser: jsoncParser },
|
|
1074
|
+
name: "zayne/pnpm/package-json/rules",
|
|
1075
|
+
plugins: { pnpm: eslintPluginPnpm },
|
|
1076
|
+
rules: {
|
|
1077
|
+
...catalogs && { "pnpm/json-enforce-catalog": ["error", { ignores: ["@types/vscode"] }] },
|
|
1078
|
+
"pnpm/json-prefer-workspace-settings": "error",
|
|
1079
|
+
"pnpm/json-valid-catalog": "error",
|
|
1080
|
+
...overrides?.json
|
|
1118
1081
|
}
|
|
1119
|
-
|
|
1082
|
+
});
|
|
1083
|
+
if (yaml$1) configs.push({
|
|
1084
|
+
files: ["pnpm-workspace.yaml"],
|
|
1085
|
+
languageOptions: { parser: yamlParser },
|
|
1086
|
+
name: "zayne/pnpm/pnpm-workspace-yaml/rules",
|
|
1087
|
+
plugins: { pnpm: eslintPluginPnpm },
|
|
1088
|
+
rules: {
|
|
1089
|
+
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
1090
|
+
"pnpm/yaml-no-unused-catalog-item": "error",
|
|
1091
|
+
...overrides?.yaml
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
1094
|
+
if (yaml$1 && sort) configs.push({
|
|
1095
|
+
files: ["pnpm-workspace.yaml"],
|
|
1096
|
+
languageOptions: { parser: yamlParser },
|
|
1097
|
+
name: "zayne/pnpm/sort/pnpm-workspace-yaml",
|
|
1098
|
+
plugins: { yaml: eslintPluginYaml },
|
|
1099
|
+
rules: { "yaml/sort-keys": [
|
|
1100
|
+
"error",
|
|
1101
|
+
{
|
|
1102
|
+
order: [
|
|
1103
|
+
"cacheDir",
|
|
1104
|
+
"catalogMode",
|
|
1105
|
+
"cleanupUnusedCatalogs",
|
|
1106
|
+
"dedupeDirectDeps",
|
|
1107
|
+
"deployAllFiles",
|
|
1108
|
+
"enablePrePostScripts",
|
|
1109
|
+
"engineStrict",
|
|
1110
|
+
"extendNodePath",
|
|
1111
|
+
"hoist",
|
|
1112
|
+
"hoistPattern",
|
|
1113
|
+
"hoistWorkspacePackages",
|
|
1114
|
+
"ignoreCompatibilityDb",
|
|
1115
|
+
"ignoreDepScripts",
|
|
1116
|
+
"ignoreScripts",
|
|
1117
|
+
"ignoreWorkspaceRootCheck",
|
|
1118
|
+
"managePackageManagerVersions",
|
|
1119
|
+
"minimumReleaseAge",
|
|
1120
|
+
"minimumReleaseAgeExclude",
|
|
1121
|
+
"modulesDir",
|
|
1122
|
+
"nodeLinker",
|
|
1123
|
+
"nodeVersion",
|
|
1124
|
+
"optimisticRepeatInstall",
|
|
1125
|
+
"packageManagerStrict",
|
|
1126
|
+
"packageManagerStrictVersion",
|
|
1127
|
+
"preferSymlinkedExecutables",
|
|
1128
|
+
"preferWorkspacePackages",
|
|
1129
|
+
"publicHoistPattern",
|
|
1130
|
+
"registrySupportsTimeField",
|
|
1131
|
+
"requiredScripts",
|
|
1132
|
+
"resolutionMode",
|
|
1133
|
+
"savePrefix",
|
|
1134
|
+
"scriptShell",
|
|
1135
|
+
"shamefullyHoist",
|
|
1136
|
+
"shellEmulator",
|
|
1137
|
+
"stateDir",
|
|
1138
|
+
"supportedArchitectures",
|
|
1139
|
+
"symlink",
|
|
1140
|
+
"tag",
|
|
1141
|
+
"trustPolicy",
|
|
1142
|
+
"trustPolicyExclude",
|
|
1143
|
+
"updateNotifier",
|
|
1144
|
+
"packages",
|
|
1145
|
+
"overrides",
|
|
1146
|
+
"patchedDependencies",
|
|
1147
|
+
"catalog",
|
|
1148
|
+
"catalogs",
|
|
1149
|
+
"allowedDeprecatedVersions",
|
|
1150
|
+
"allowNonAppliedPatches",
|
|
1151
|
+
"configDependencies",
|
|
1152
|
+
"ignoredBuiltDependencies",
|
|
1153
|
+
"ignoredOptionalDependencies",
|
|
1154
|
+
"neverBuiltDependencies",
|
|
1155
|
+
"onlyBuiltDependencies",
|
|
1156
|
+
"onlyBuiltDependenciesFile",
|
|
1157
|
+
"packageExtensions",
|
|
1158
|
+
"peerDependencyRules"
|
|
1159
|
+
],
|
|
1160
|
+
pathPattern: "^$"
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
order: { type: "asc" },
|
|
1164
|
+
pathPattern: ".*"
|
|
1165
|
+
}
|
|
1166
|
+
] }
|
|
1167
|
+
});
|
|
1168
|
+
return configs;
|
|
1120
1169
|
}
|
|
1121
1170
|
|
|
1122
|
-
//#endregion
|
|
1123
|
-
//#region src/constants.ts
|
|
1124
|
-
const defaultPluginRenameMap = defineEnum({
|
|
1125
|
-
"@eslint-react/debug": "react-debug",
|
|
1126
|
-
"@eslint-react/dom": "react-dom",
|
|
1127
|
-
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
1128
|
-
"@eslint-react/naming-convention": "react-naming-convention",
|
|
1129
|
-
"@eslint-react/web-api": "react-web-api",
|
|
1130
|
-
"@eslint-react": "react-x",
|
|
1131
|
-
"@next/next": "nextjs",
|
|
1132
|
-
"@stylistic": "stylistic",
|
|
1133
|
-
"@tanstack/query": "tanstack-query",
|
|
1134
|
-
"@tanstack/router": "tanstack-router",
|
|
1135
|
-
"@typescript-eslint": "ts-eslint",
|
|
1136
|
-
"better-tailwindcss": "tailwindcss-better",
|
|
1137
|
-
"import-x": "import",
|
|
1138
|
-
n: "node"
|
|
1139
|
-
});
|
|
1140
|
-
const allowedNextJsExportNames = [
|
|
1141
|
-
"dynamic",
|
|
1142
|
-
"dynamicParams",
|
|
1143
|
-
"revalidate",
|
|
1144
|
-
"fetchCache",
|
|
1145
|
-
"runtime",
|
|
1146
|
-
"preferredRegion",
|
|
1147
|
-
"maxDuration",
|
|
1148
|
-
"config",
|
|
1149
|
-
"generateStaticParams",
|
|
1150
|
-
"metadata",
|
|
1151
|
-
"generateMetadata",
|
|
1152
|
-
"viewport",
|
|
1153
|
-
"generateViewport"
|
|
1154
|
-
];
|
|
1155
|
-
const allowedReactRouterExportNames = [
|
|
1156
|
-
"meta",
|
|
1157
|
-
"links",
|
|
1158
|
-
"headers",
|
|
1159
|
-
"loader",
|
|
1160
|
-
"action",
|
|
1161
|
-
"clientLoader",
|
|
1162
|
-
"clientAction",
|
|
1163
|
-
"handle",
|
|
1164
|
-
"shouldRevalidate"
|
|
1165
|
-
];
|
|
1166
|
-
|
|
1167
1171
|
//#endregion
|
|
1168
1172
|
//#region src/configs/react.ts
|
|
1169
1173
|
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
@@ -1190,7 +1194,7 @@ const react = async (options = {}) => {
|
|
|
1190
1194
|
enableReact ? interopDefault(import("@eslint-react/eslint-plugin")) : void 0,
|
|
1191
1195
|
enableReact ? interopDefault(import("eslint-plugin-react-hooks")) : void 0,
|
|
1192
1196
|
refresh ? interopDefault(import("eslint-plugin-react-refresh")) : void 0,
|
|
1193
|
-
youMightNotNeedAnEffect ? interopDefault(import("./src-
|
|
1197
|
+
youMightNotNeedAnEffect ? interopDefault(import("./src-nCsOdMZJ.js")) : void 0,
|
|
1194
1198
|
nextjs ? interopDefault(import("@next/eslint-plugin-next")) : void 0
|
|
1195
1199
|
]);
|
|
1196
1200
|
const strictConfigKey = typescript$1 ? "strict-type-checked" : "strict";
|
|
@@ -1203,7 +1207,7 @@ const react = async (options = {}) => {
|
|
|
1203
1207
|
} },
|
|
1204
1208
|
name: "zayne/react/setup",
|
|
1205
1209
|
plugins: {
|
|
1206
|
-
...renamePlugins(strictReactConfig.plugins,
|
|
1210
|
+
...renamePlugins(strictReactConfig.plugins, getDefaultPluginRenameMap()),
|
|
1207
1211
|
"react-hooks": eslintReactHooks,
|
|
1208
1212
|
"react-you-might-not-need-an-effect": eslintPluginReactYouMightNotNeedAnEffect
|
|
1209
1213
|
},
|
|
@@ -1219,7 +1223,7 @@ const react = async (options = {}) => {
|
|
|
1219
1223
|
files: typescript$1 ? filesTypeAware : files,
|
|
1220
1224
|
...typescript$1 && { ignores: ignoresTypeAware },
|
|
1221
1225
|
name: `zayne/react/unofficial/${strictConfigKey}`,
|
|
1222
|
-
rules: renameRules(strictReactConfig.rules,
|
|
1226
|
+
rules: renameRules(strictReactConfig.rules, getDefaultPluginRenameMap())
|
|
1223
1227
|
}, {
|
|
1224
1228
|
files,
|
|
1225
1229
|
name: "zayne/react/unofficial/rules",
|
|
@@ -1267,7 +1271,7 @@ const react = async (options = {}) => {
|
|
|
1267
1271
|
rules: {
|
|
1268
1272
|
"react-refresh/only-export-components": ["warn", {
|
|
1269
1273
|
allowConstantExport: isAllowConstantExport,
|
|
1270
|
-
allowExportNames: [...nextjs ?
|
|
1274
|
+
allowExportNames: [...nextjs ? getDefaultAllowedNextJsExportNames() : [], ...isUsingReactRouter ? getDefaultAllowedReactRouterExportNames() : []]
|
|
1271
1275
|
}],
|
|
1272
1276
|
...overrides,
|
|
1273
1277
|
...isObject$1(refresh) && refresh.overrides
|
|
@@ -1293,7 +1297,7 @@ const react = async (options = {}) => {
|
|
|
1293
1297
|
rules: renameRules({
|
|
1294
1298
|
...eslintPluginNextjs.configs?.recommended?.rules,
|
|
1295
1299
|
...eslintPluginNextjs.configs?.["core-web-vitals"]?.rules
|
|
1296
|
-
},
|
|
1300
|
+
}, getDefaultPluginRenameMap())
|
|
1297
1301
|
}, {
|
|
1298
1302
|
files,
|
|
1299
1303
|
name: "zayne/react/nextjs/rules",
|
|
@@ -1600,6 +1604,7 @@ const tailwindcssBetter = async (options = {}) => {
|
|
|
1600
1604
|
const { overrides, settings: tailwindCssBetterSettings } = options;
|
|
1601
1605
|
await ensurePackages(["eslint-plugin-better-tailwindcss"]);
|
|
1602
1606
|
const [eslintPluginBetterTailwindCss, defaults] = await Promise.all([interopDefault(import("eslint-plugin-better-tailwindcss")), interopDefault(import("eslint-plugin-better-tailwindcss/api/defaults"))]);
|
|
1607
|
+
const zayneDefaultSettings = getDefaultTailwindcssBetterSettings();
|
|
1603
1608
|
return [
|
|
1604
1609
|
{
|
|
1605
1610
|
name: "zayne/tailwindcss-better/setup",
|
|
@@ -1608,21 +1613,20 @@ const tailwindcssBetter = async (options = {}) => {
|
|
|
1608
1613
|
...tailwindCssBetterSettings,
|
|
1609
1614
|
attributes: [
|
|
1610
1615
|
...defaults.getDefaultAttributes(),
|
|
1611
|
-
|
|
1612
|
-
tailwindCssBetterSettings?.attributes
|
|
1616
|
+
...zayneDefaultSettings.attributes,
|
|
1617
|
+
...tailwindCssBetterSettings?.attributes ?? []
|
|
1613
1618
|
],
|
|
1614
1619
|
callees: [
|
|
1615
1620
|
...defaults.getDefaultCallees(),
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
tailwindCssBetterSettings?.callees
|
|
1621
|
+
...zayneDefaultSettings.callees,
|
|
1622
|
+
...tailwindCssBetterSettings?.callees ?? []
|
|
1619
1623
|
],
|
|
1620
1624
|
entryPoint: tailwindCssBetterSettings?.entryPoint ?? `${process.cwd()}/tailwind.css`
|
|
1621
1625
|
} }
|
|
1622
1626
|
},
|
|
1623
1627
|
{
|
|
1624
1628
|
name: "zayne/tailwindcss-better/recommended",
|
|
1625
|
-
rules: renameRules(eslintPluginBetterTailwindCss.configs.recommended?.rules,
|
|
1629
|
+
rules: renameRules(eslintPluginBetterTailwindCss.configs.recommended?.rules, getDefaultPluginRenameMap())
|
|
1626
1630
|
},
|
|
1627
1631
|
{
|
|
1628
1632
|
name: "zayne/tailwindcss-better/rules",
|
|
@@ -1655,7 +1659,7 @@ const tanstack = async (options = {}) => {
|
|
|
1655
1659
|
if (query && eslintPluginTanstackQuery) config.push({
|
|
1656
1660
|
name: "zayne/tanstack-query/recommended",
|
|
1657
1661
|
plugins: { "tanstack-query": eslintPluginTanstackQuery },
|
|
1658
|
-
rules: renameRules(eslintPluginTanstackQuery.configs["flat/recommended"][0]?.rules,
|
|
1662
|
+
rules: renameRules(eslintPluginTanstackQuery.configs["flat/recommended"][0]?.rules, getDefaultPluginRenameMap())
|
|
1659
1663
|
}, {
|
|
1660
1664
|
name: "zayne/tanstack-query/rules",
|
|
1661
1665
|
rules: {
|
|
@@ -1666,7 +1670,7 @@ const tanstack = async (options = {}) => {
|
|
|
1666
1670
|
if (router && eslintPluginTanstackRouter) config.push({
|
|
1667
1671
|
name: "zayne/tanstack-router/recommended",
|
|
1668
1672
|
plugins: { "tanstack-router": eslintPluginTanstackRouter },
|
|
1669
|
-
rules: renameRules(eslintPluginTanstackRouter.configs["flat/recommended"][0]?.rules,
|
|
1673
|
+
rules: renameRules(eslintPluginTanstackRouter.configs["flat/recommended"][0]?.rules, getDefaultPluginRenameMap())
|
|
1670
1674
|
}, {
|
|
1671
1675
|
name: "zayne/tanstack-router/rules",
|
|
1672
1676
|
rules: {
|
|
@@ -1759,7 +1763,7 @@ const typescript = async (options = {}) => {
|
|
|
1759
1763
|
...parserOptions
|
|
1760
1764
|
}
|
|
1761
1765
|
},
|
|
1762
|
-
name: `zayne/
|
|
1766
|
+
name: `zayne/ts-eslint/${typeAware ? "parser-type-aware" : "parser"}`
|
|
1763
1767
|
};
|
|
1764
1768
|
};
|
|
1765
1769
|
const recommendedRules = tsEslint.configs[isTypeAware ? "strictTypeChecked" : "strict"].map((config) => config.rules).reduce((accumulator, rules) => ({
|
|
@@ -1780,23 +1784,18 @@ const typescript = async (options = {}) => {
|
|
|
1780
1784
|
files: isTypeAware ? filesTypeAware : files,
|
|
1781
1785
|
ignores: isTypeAware ? ignoresTypeAware : [],
|
|
1782
1786
|
name: `zayne/ts-eslint/recommended-${isTypeAware ? "strict-type-checked" : "strict"}`,
|
|
1783
|
-
rules: renameRules(recommendedRules,
|
|
1787
|
+
rules: renameRules(recommendedRules, getDefaultPluginRenameMap())
|
|
1784
1788
|
},
|
|
1785
1789
|
...stylistic$1 ? [{
|
|
1786
1790
|
files: isTypeAware ? filesTypeAware : files,
|
|
1787
1791
|
ignores: isTypeAware ? ignoresTypeAware : [],
|
|
1788
1792
|
name: `zayne/ts-eslint/recommended-${isTypeAware ? "stylistic-type-checked" : "stylistic"}`,
|
|
1789
|
-
rules: renameRules(recommendedStylisticRules,
|
|
1790
|
-
}] : [],
|
|
1791
|
-
...erasableOnly ? [{
|
|
1792
|
-
name: "zayne/typescript/erasable-syntax-only/recommended",
|
|
1793
|
-
plugins: { "erasable-syntax-only": eslintPluginErasableOnly },
|
|
1794
|
-
rules: eslintPluginErasableOnly?.configs.recommended.rules
|
|
1793
|
+
rules: renameRules(recommendedStylisticRules, getDefaultPluginRenameMap())
|
|
1795
1794
|
}] : [],
|
|
1796
1795
|
{
|
|
1797
1796
|
files: isTypeAware ? filesTypeAware : files,
|
|
1798
1797
|
ignores: isTypeAware ? ignoresTypeAware : [],
|
|
1799
|
-
name: `zayne/ts-eslint
|
|
1798
|
+
name: `zayne/ts-eslint/rules${isTypeAware ? "-type-checked" : ""}`,
|
|
1800
1799
|
rules: {
|
|
1801
1800
|
"ts-eslint/array-type": ["error", { default: "array-simple" }],
|
|
1802
1801
|
"ts-eslint/consistent-type-definitions": ["error", "type"],
|
|
@@ -1841,7 +1840,12 @@ const typescript = async (options = {}) => {
|
|
|
1841
1840
|
},
|
|
1842
1841
|
...overrides
|
|
1843
1842
|
}
|
|
1844
|
-
}
|
|
1843
|
+
},
|
|
1844
|
+
...erasableOnly ? [{
|
|
1845
|
+
name: "zayne/ts-eslint/erasable-syntax-only/recommended",
|
|
1846
|
+
plugins: { "erasable-syntax-only": eslintPluginErasableOnly },
|
|
1847
|
+
rules: eslintPluginErasableOnly?.configs.recommended.rules
|
|
1848
|
+
}] : []
|
|
1845
1849
|
];
|
|
1846
1850
|
};
|
|
1847
1851
|
|
|
@@ -2064,11 +2068,11 @@ const vue = async (options = {}) => {
|
|
|
2064
2068
|
//#region src/configs/yaml.ts
|
|
2065
2069
|
const yaml = async (options = {}) => {
|
|
2066
2070
|
const { files = [GLOB_YAML], overrides, stylistic: stylistic$1 = true } = options;
|
|
2067
|
-
const [
|
|
2071
|
+
const [eslintPluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
2068
2072
|
return [
|
|
2069
2073
|
{
|
|
2070
2074
|
name: "zayne/yaml/setup",
|
|
2071
|
-
plugins: { yaml:
|
|
2075
|
+
plugins: { yaml: eslintPluginYaml }
|
|
2072
2076
|
},
|
|
2073
2077
|
{
|
|
2074
2078
|
files,
|
|
@@ -2108,6 +2112,25 @@ const yaml = async (options = {}) => {
|
|
|
2108
2112
|
];
|
|
2109
2113
|
};
|
|
2110
2114
|
|
|
2115
|
+
//#endregion
|
|
2116
|
+
//#region ../../node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
|
|
2117
|
+
const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
2118
|
+
function findUpSync(name, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
|
|
2119
|
+
let directory = path.resolve(toPath(cwd) ?? "");
|
|
2120
|
+
const { root } = path.parse(directory);
|
|
2121
|
+
stopAt = path.resolve(directory, toPath(stopAt) ?? root);
|
|
2122
|
+
const isAbsoluteName = path.isAbsolute(name);
|
|
2123
|
+
while (directory) {
|
|
2124
|
+
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
2125
|
+
try {
|
|
2126
|
+
const stats = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
2127
|
+
if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
|
|
2128
|
+
} catch {}
|
|
2129
|
+
if (directory === stopAt || directory === root) break;
|
|
2130
|
+
directory = path.dirname(directory);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2111
2134
|
//#endregion
|
|
2112
2135
|
//#region src/factory.ts
|
|
2113
2136
|
const ReactPackages = ["react", "react-dom"];
|
|
@@ -2121,13 +2144,12 @@ const ReactPackages = ["react", "react-dom"];
|
|
|
2121
2144
|
* The merged ESLint configurations.
|
|
2122
2145
|
*/
|
|
2123
2146
|
const zayne = (options = {}, ...userConfigs) => {
|
|
2124
|
-
const { autoRenamePlugins = true, componentExts = [], componentExtsTypeAware = [], type = "app", withDefaults = true
|
|
2147
|
+
const { autoRenamePlugins = true, componentExts = [], componentExtsTypeAware = [], ignores: userIgnores, type = "app", withDefaults = true, ...restOfOptions } = options;
|
|
2125
2148
|
const enableGitignore = restOfOptions.gitignore ?? true;
|
|
2126
2149
|
const enableJsx = restOfOptions.jsx ?? true;
|
|
2127
2150
|
const enableComments = restOfOptions.comments ?? withDefaults;
|
|
2128
2151
|
const enableImports = restOfOptions.imports ?? withDefaults;
|
|
2129
2152
|
const enableJsdoc = restOfOptions.jsdoc ?? withDefaults;
|
|
2130
|
-
const enablePnpmCatalogs = restOfOptions.pnpm;
|
|
2131
2153
|
const enableJsonc = restOfOptions.jsonc ?? withDefaults;
|
|
2132
2154
|
const enableNode = restOfOptions.node ?? withDefaults;
|
|
2133
2155
|
const enablePerfectionist = restOfOptions.perfectionist ?? withDefaults;
|
|
@@ -2138,10 +2160,11 @@ const zayne = (options = {}, ...userConfigs) => {
|
|
|
2138
2160
|
const enableUnicorn = restOfOptions.unicorn ?? withDefaults;
|
|
2139
2161
|
const enableYaml = restOfOptions.yaml ?? withDefaults;
|
|
2140
2162
|
const enableMarkdown = restOfOptions.markdown ?? withDefaults;
|
|
2163
|
+
const enablePnpmCatalogs = restOfOptions.pnpm ?? (withDefaults && Boolean(findUpSync("pnpm-workspace.yaml")));
|
|
2141
2164
|
const isStylistic = Boolean(enableStylistic);
|
|
2142
2165
|
const tsconfigPath = isObject(enableTypeScript) && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : enableTypeScript === true ? enableTypeScript : null;
|
|
2143
2166
|
const isTypeAware = Boolean(tsconfigPath);
|
|
2144
|
-
const configs = [ignores(
|
|
2167
|
+
const configs = [ignores(userIgnores), javascript(restOfOptions.javascript)];
|
|
2145
2168
|
if (enableGitignore) configs.push(gitIgnores(resolveOptions(enableGitignore)));
|
|
2146
2169
|
if (enableJsx) configs.push(jsx(resolveOptions(enableJsx)));
|
|
2147
2170
|
if (restOfOptions.vue) {
|
|
@@ -2183,10 +2206,7 @@ const zayne = (options = {}, ...userConfigs) => {
|
|
|
2183
2206
|
type,
|
|
2184
2207
|
...resolveOptions(enableUnicorn)
|
|
2185
2208
|
}));
|
|
2186
|
-
if (enableJsonc) configs.push(jsonc(
|
|
2187
|
-
stylistic: isStylistic,
|
|
2188
|
-
...resolveOptions(enableJsonc)
|
|
2189
|
-
}), sortPackageJson(), sortTsconfig());
|
|
2209
|
+
if (enableJsonc) configs.push(jsonc(resolveOptions(enableJsonc)), sortPackageJson(), sortTsconfig());
|
|
2190
2210
|
if (enableJsdoc) configs.push(jsdoc({
|
|
2191
2211
|
stylistic: isStylistic,
|
|
2192
2212
|
...resolveOptions(enableJsdoc)
|
|
@@ -2225,9 +2245,9 @@ const zayne = (options = {}, ...userConfigs) => {
|
|
|
2225
2245
|
if (restOfOptions.tanstack) configs.push(tanstack(resolveOptions(restOfOptions.tanstack)));
|
|
2226
2246
|
if (restOfOptions.depend) configs.push(depend(resolveOptions(restOfOptions.depend)));
|
|
2227
2247
|
assert(!("files" in restOfOptions), `[@zayne-labs/eslint-config]: The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second config array instead.`);
|
|
2228
|
-
return new FlatConfigComposer().append(...configs, ...userConfigs).renamePlugins(autoRenamePlugins ?
|
|
2248
|
+
return new FlatConfigComposer().append(...configs, ...userConfigs).renamePlugins(autoRenamePlugins ? getDefaultPluginRenameMap() : {});
|
|
2229
2249
|
};
|
|
2230
2250
|
|
|
2231
2251
|
//#endregion
|
|
2232
|
-
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_MARKDOWN_JSON, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLES, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML,
|
|
2252
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_MARKDOWN_JSON, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLES, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, astro, combine, comments, depend, ensurePackages, expo, gitIgnores, ignores, imports, interopDefault, isObject, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, node, overrideConfigs, parserPlain, perfectionist, pnpm, react, renamePluginInConfigs, renamePlugins, renameRules, resolveOptions, solid, sortPackageJson, sortTsconfig, stylistic, tailwindcssBetter, tanstack, toml, typescript, unicorn, vue, yaml, zayne };
|
|
2233
2253
|
//# sourceMappingURL=index.js.map
|