@zayne-labs/eslint-config 0.11.4 → 0.11.6
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 +4 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +1068 -614
- package/dist/index.js +151 -45
- package/dist/index.js.map +1 -1
- package/dist/src-BncWNtPe.js +671 -0
- package/dist/src-BncWNtPe.js.map +1 -0
- package/package.json +41 -40
- package/dist/src-MgbFTVE-.js +0 -1802
- package/dist/src-MgbFTVE-.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { assert, defineEnum, isFunction, isObject as isObject$1, isObjectAndNotArray } from "@zayne-labs/toolkit-type-helpers";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
2
|
import { isPackageExists } from "local-pkg";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { globalIgnores } from "eslint/config";
|
|
5
5
|
import globals from "globals";
|
|
6
6
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
7
|
+
import process$1 from "node:process";
|
|
8
|
+
import fsp from "node:fs/promises";
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
7
11
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
8
12
|
|
|
9
13
|
//#region src/globs.ts
|
|
@@ -21,8 +25,8 @@ const GLOB_SCSS = "**/*.scss";
|
|
|
21
25
|
const GLOB_JSON = "**/*.json";
|
|
22
26
|
const GLOB_JSON5 = "**/*.json5";
|
|
23
27
|
const GLOB_JSONC = "**/*.jsonc";
|
|
24
|
-
const GLOB_MARKDOWN = "**/*.md";
|
|
25
|
-
const GLOB_MARKDOWN_IN_MARKDOWN =
|
|
28
|
+
const GLOB_MARKDOWN = "**/*.md?(x)";
|
|
29
|
+
const GLOB_MARKDOWN_IN_MARKDOWN = `${GLOB_MARKDOWN}/*.md?(x)`;
|
|
26
30
|
const GLOB_SVELTE = "**/*.svelte?(.{js,ts})";
|
|
27
31
|
const GLOB_VUE = "**/*.vue";
|
|
28
32
|
const GLOB_YAML = "**/*.y?(a)ml";
|
|
@@ -239,7 +243,9 @@ const ensurePackages = async (packages) => {
|
|
|
239
243
|
if (nonExistingPackages.length === 0) return;
|
|
240
244
|
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
245
|
};
|
|
242
|
-
const resolveOptions = (option) =>
|
|
246
|
+
const resolveOptions = (option) => {
|
|
247
|
+
return isObject(option) ? option : {};
|
|
248
|
+
};
|
|
243
249
|
const parserPlain = {
|
|
244
250
|
meta: { name: "parser-plain" },
|
|
245
251
|
parseForESLint: (code) => ({
|
|
@@ -375,7 +381,9 @@ const expo = async (options = {}) => {
|
|
|
375
381
|
//#endregion
|
|
376
382
|
//#region src/configs/ignores.ts
|
|
377
383
|
const ignores = (userIgnores = []) => {
|
|
378
|
-
|
|
384
|
+
const initIgnores = [...GLOB_EXCLUDE];
|
|
385
|
+
const resolvedUserIgnores = isFunction(userIgnores) ? userIgnores(initIgnores) : userIgnores;
|
|
386
|
+
return [globalIgnores([...initIgnores, ...resolvedUserIgnores], "zayne/defaults/ignores")];
|
|
379
387
|
};
|
|
380
388
|
const gitIgnores = async (options) => {
|
|
381
389
|
return [(await interopDefault(import("eslint-config-flat-gitignore")))({
|
|
@@ -914,11 +922,6 @@ const markdown = async (options = {}) => {
|
|
|
914
922
|
name: "zayne/markdown/recommended",
|
|
915
923
|
rules: recommendedRules
|
|
916
924
|
},
|
|
917
|
-
{
|
|
918
|
-
files,
|
|
919
|
-
name: "zayne/markdown/rules",
|
|
920
|
-
rules: { ...overrides }
|
|
921
|
-
},
|
|
922
925
|
{
|
|
923
926
|
files: [
|
|
924
927
|
...files,
|
|
@@ -952,7 +955,8 @@ const markdown = async (options = {}) => {
|
|
|
952
955
|
"ts-eslint/no-use-before-define": "off",
|
|
953
956
|
"unicode-bom": "off",
|
|
954
957
|
"unicorn/filename-case": "off",
|
|
955
|
-
"unicorn/prefer-export-from": "off"
|
|
958
|
+
"unicorn/prefer-export-from": "off",
|
|
959
|
+
...overrides
|
|
956
960
|
}
|
|
957
961
|
}
|
|
958
962
|
];
|
|
@@ -1080,43 +1084,145 @@ const perfectionist = async (options = {}) => {
|
|
|
1080
1084
|
}];
|
|
1081
1085
|
};
|
|
1082
1086
|
|
|
1087
|
+
//#endregion
|
|
1088
|
+
//#region ../../node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
|
|
1089
|
+
const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
1090
|
+
async function findUp(name, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
|
|
1091
|
+
let directory = path.resolve(toPath(cwd) ?? "");
|
|
1092
|
+
const { root } = path.parse(directory);
|
|
1093
|
+
stopAt = path.resolve(directory, toPath(stopAt ?? root));
|
|
1094
|
+
const isAbsoluteName = path.isAbsolute(name);
|
|
1095
|
+
while (directory) {
|
|
1096
|
+
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
1097
|
+
try {
|
|
1098
|
+
const stats = await fsp.stat(filePath);
|
|
1099
|
+
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
|
|
1100
|
+
} catch {}
|
|
1101
|
+
if (directory === stopAt || directory === root) break;
|
|
1102
|
+
directory = path.dirname(directory);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1083
1106
|
//#endregion
|
|
1084
1107
|
//#region src/configs/pnpm.ts
|
|
1108
|
+
const detectCatalogUsage = async () => {
|
|
1109
|
+
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1110
|
+
if (!workspaceFile) return false;
|
|
1111
|
+
const yaml$1 = await fsp.readFile(workspaceFile, "utf8");
|
|
1112
|
+
return yaml$1.includes("catalog:") || yaml$1.includes("catalogs:");
|
|
1113
|
+
};
|
|
1085
1114
|
async function pnpm(options = {}) {
|
|
1086
|
-
const { overrides } = options;
|
|
1115
|
+
const { catalogs = detectCatalogUsage(), json = true, overrides, sort = true, yaml: yaml$1 = true } = options;
|
|
1087
1116
|
await ensurePackages(["eslint-plugin-pnpm"]);
|
|
1088
|
-
const [eslintPluginPnpm, yamlParser, jsoncParser] = await Promise.all([
|
|
1117
|
+
const [eslintPluginPnpm, yamlParser, eslintPluginYaml, jsoncParser] = await Promise.all([
|
|
1089
1118
|
interopDefault(import("eslint-plugin-pnpm")),
|
|
1090
1119
|
interopDefault(import("yaml-eslint-parser")),
|
|
1120
|
+
interopDefault(import("eslint-plugin-yml")),
|
|
1091
1121
|
interopDefault(import("jsonc-eslint-parser"))
|
|
1092
1122
|
]);
|
|
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
|
-
}
|
|
1123
|
+
const configs = [];
|
|
1124
|
+
if (json) configs.push({
|
|
1125
|
+
files: ["package.json", "**/package.json"],
|
|
1126
|
+
languageOptions: { parser: jsoncParser },
|
|
1127
|
+
name: "zayne/pnpm/package-json/rules",
|
|
1128
|
+
plugins: { pnpm: eslintPluginPnpm },
|
|
1129
|
+
rules: {
|
|
1130
|
+
...catalogs && { "pnpm/json-enforce-catalog": ["error", { ignores: ["@types/vscode"] }] },
|
|
1131
|
+
"pnpm/json-prefer-workspace-settings": "error",
|
|
1132
|
+
"pnpm/json-valid-catalog": "error",
|
|
1133
|
+
...overrides?.json
|
|
1118
1134
|
}
|
|
1119
|
-
|
|
1135
|
+
});
|
|
1136
|
+
if (yaml$1) configs.push({
|
|
1137
|
+
files: ["pnpm-workspace.yaml"],
|
|
1138
|
+
languageOptions: { parser: yamlParser },
|
|
1139
|
+
name: "zayne/pnpm/pnpm-workspace-yaml/rules",
|
|
1140
|
+
plugins: { pnpm: eslintPluginPnpm },
|
|
1141
|
+
rules: {
|
|
1142
|
+
"pnpm/yaml-enforce-settings": ["error", { settings: {
|
|
1143
|
+
shellEmulator: true,
|
|
1144
|
+
trustPolicy: "no-downgrade"
|
|
1145
|
+
} }],
|
|
1146
|
+
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
1147
|
+
"pnpm/yaml-no-unused-catalog-item": "error",
|
|
1148
|
+
...overrides?.yaml
|
|
1149
|
+
}
|
|
1150
|
+
});
|
|
1151
|
+
if (yaml$1 && sort) configs.push({
|
|
1152
|
+
files: ["pnpm-workspace.yaml"],
|
|
1153
|
+
languageOptions: { parser: yamlParser },
|
|
1154
|
+
name: "zayne/pnpm/sort/pnpm-workspace-yaml",
|
|
1155
|
+
plugins: { yaml: eslintPluginYaml },
|
|
1156
|
+
rules: { "yaml/sort-keys": [
|
|
1157
|
+
"error",
|
|
1158
|
+
{
|
|
1159
|
+
order: [
|
|
1160
|
+
"cacheDir",
|
|
1161
|
+
"catalogMode",
|
|
1162
|
+
"cleanupUnusedCatalogs",
|
|
1163
|
+
"dedupeDirectDeps",
|
|
1164
|
+
"deployAllFiles",
|
|
1165
|
+
"enablePrePostScripts",
|
|
1166
|
+
"engineStrict",
|
|
1167
|
+
"extendNodePath",
|
|
1168
|
+
"hoist",
|
|
1169
|
+
"hoistPattern",
|
|
1170
|
+
"hoistWorkspacePackages",
|
|
1171
|
+
"ignoreCompatibilityDb",
|
|
1172
|
+
"ignoreDepScripts",
|
|
1173
|
+
"ignoreScripts",
|
|
1174
|
+
"ignoreWorkspaceRootCheck",
|
|
1175
|
+
"managePackageManagerVersions",
|
|
1176
|
+
"minimumReleaseAge",
|
|
1177
|
+
"minimumReleaseAgeExclude",
|
|
1178
|
+
"modulesDir",
|
|
1179
|
+
"nodeLinker",
|
|
1180
|
+
"nodeVersion",
|
|
1181
|
+
"optimisticRepeatInstall",
|
|
1182
|
+
"packageManagerStrict",
|
|
1183
|
+
"packageManagerStrictVersion",
|
|
1184
|
+
"preferSymlinkedExecutables",
|
|
1185
|
+
"preferWorkspacePackages",
|
|
1186
|
+
"publicHoistPattern",
|
|
1187
|
+
"registrySupportsTimeField",
|
|
1188
|
+
"requiredScripts",
|
|
1189
|
+
"resolutionMode",
|
|
1190
|
+
"savePrefix",
|
|
1191
|
+
"scriptShell",
|
|
1192
|
+
"shamefullyHoist",
|
|
1193
|
+
"shellEmulator",
|
|
1194
|
+
"stateDir",
|
|
1195
|
+
"supportedArchitectures",
|
|
1196
|
+
"symlink",
|
|
1197
|
+
"tag",
|
|
1198
|
+
"trustPolicy",
|
|
1199
|
+
"trustPolicyExclude",
|
|
1200
|
+
"updateNotifier",
|
|
1201
|
+
"packages",
|
|
1202
|
+
"overrides",
|
|
1203
|
+
"patchedDependencies",
|
|
1204
|
+
"catalog",
|
|
1205
|
+
"catalogs",
|
|
1206
|
+
"allowedDeprecatedVersions",
|
|
1207
|
+
"allowNonAppliedPatches",
|
|
1208
|
+
"configDependencies",
|
|
1209
|
+
"ignoredBuiltDependencies",
|
|
1210
|
+
"ignoredOptionalDependencies",
|
|
1211
|
+
"neverBuiltDependencies",
|
|
1212
|
+
"onlyBuiltDependencies",
|
|
1213
|
+
"onlyBuiltDependenciesFile",
|
|
1214
|
+
"packageExtensions",
|
|
1215
|
+
"peerDependencyRules"
|
|
1216
|
+
],
|
|
1217
|
+
pathPattern: "^$"
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
order: { type: "asc" },
|
|
1221
|
+
pathPattern: ".*"
|
|
1222
|
+
}
|
|
1223
|
+
] }
|
|
1224
|
+
});
|
|
1225
|
+
return configs;
|
|
1120
1226
|
}
|
|
1121
1227
|
|
|
1122
1228
|
//#endregion
|
|
@@ -1190,7 +1296,7 @@ const react = async (options = {}) => {
|
|
|
1190
1296
|
enableReact ? interopDefault(import("@eslint-react/eslint-plugin")) : void 0,
|
|
1191
1297
|
enableReact ? interopDefault(import("eslint-plugin-react-hooks")) : void 0,
|
|
1192
1298
|
refresh ? interopDefault(import("eslint-plugin-react-refresh")) : void 0,
|
|
1193
|
-
youMightNotNeedAnEffect ? interopDefault(import("./src-
|
|
1299
|
+
youMightNotNeedAnEffect ? interopDefault(import("./src-BncWNtPe.js")) : void 0,
|
|
1194
1300
|
nextjs ? interopDefault(import("@next/eslint-plugin-next")) : void 0
|
|
1195
1301
|
]);
|
|
1196
1302
|
const strictConfigKey = typescript$1 ? "strict-type-checked" : "strict";
|
|
@@ -1868,6 +1974,7 @@ const unicorn = async (options = {}) => {
|
|
|
1868
1974
|
"unicorn/no-useless-undefined": ["error", { checkArguments: true }],
|
|
1869
1975
|
"unicorn/numeric-separators-style": "off",
|
|
1870
1976
|
"unicorn/prefer-global-this": type === "lib" || type === "lib-strict" ? "warn" : "off",
|
|
1977
|
+
"unicorn/prefer-native-coercion-functions": "off",
|
|
1871
1978
|
"unicorn/prevent-abbreviations": "off",
|
|
1872
1979
|
...overrides
|
|
1873
1980
|
}
|
|
@@ -2063,11 +2170,11 @@ const vue = async (options = {}) => {
|
|
|
2063
2170
|
//#region src/configs/yaml.ts
|
|
2064
2171
|
const yaml = async (options = {}) => {
|
|
2065
2172
|
const { files = [GLOB_YAML], overrides, stylistic: stylistic$1 = true } = options;
|
|
2066
|
-
const [
|
|
2173
|
+
const [eslintPluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
2067
2174
|
return [
|
|
2068
2175
|
{
|
|
2069
2176
|
name: "zayne/yaml/setup",
|
|
2070
|
-
plugins: { yaml:
|
|
2177
|
+
plugins: { yaml: eslintPluginYaml }
|
|
2071
2178
|
},
|
|
2072
2179
|
{
|
|
2073
2180
|
files,
|
|
@@ -2120,7 +2227,7 @@ const ReactPackages = ["react", "react-dom"];
|
|
|
2120
2227
|
* The merged ESLint configurations.
|
|
2121
2228
|
*/
|
|
2122
2229
|
const zayne = (options = {}, ...userConfigs) => {
|
|
2123
|
-
const { autoRenamePlugins = true, componentExts = [], componentExtsTypeAware = [], type = "app", withDefaults = true
|
|
2230
|
+
const { autoRenamePlugins = true, componentExts = [], componentExtsTypeAware = [], ignores: userIgnores, type = "app", withDefaults = true, ...restOfOptions } = options;
|
|
2124
2231
|
const enableGitignore = restOfOptions.gitignore ?? true;
|
|
2125
2232
|
const enableJsx = restOfOptions.jsx ?? true;
|
|
2126
2233
|
const enableComments = restOfOptions.comments ?? withDefaults;
|
|
@@ -2140,8 +2247,7 @@ const zayne = (options = {}, ...userConfigs) => {
|
|
|
2140
2247
|
const isStylistic = Boolean(enableStylistic);
|
|
2141
2248
|
const tsconfigPath = isObject(enableTypeScript) && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : enableTypeScript === true ? enableTypeScript : null;
|
|
2142
2249
|
const isTypeAware = Boolean(tsconfigPath);
|
|
2143
|
-
const configs = [];
|
|
2144
|
-
configs.push(ignores(restOfOptions.ignores), javascript(restOfOptions.javascript));
|
|
2250
|
+
const configs = [ignores(userIgnores), javascript(restOfOptions.javascript)];
|
|
2145
2251
|
if (enableGitignore) configs.push(gitIgnores(resolveOptions(enableGitignore)));
|
|
2146
2252
|
if (enableJsx) configs.push(jsx(resolveOptions(enableJsx)));
|
|
2147
2253
|
if (restOfOptions.vue) {
|