@zayne-labs/eslint-config 0.11.7 → 0.11.8
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/dist/cli/index.js +1 -1
- package/dist/constants/defaults.js +1 -1
- package/dist/{defaults-Ddo61INE.js → defaults-B3n8wABC.js} +1 -1
- package/dist/{defaults-Ddo61INE.js.map → defaults-B3n8wABC.js.map} +1 -1
- package/dist/index-B9wn5XKH.d.ts +18641 -0
- package/dist/index.d.ts +3 -18773
- package/dist/index.js +15 -188
- package/dist/index.js.map +1 -1
- package/dist/{src-nCsOdMZJ.js → src-BqZFkya2.js} +1 -1
- package/dist/{src-nCsOdMZJ.js.map → src-BqZFkya2.js.map} +1 -1
- package/dist/utils-DPFNmhr6.js +180 -0
- package/dist/utils-DPFNmhr6.js.map +1 -0
- package/dist/utils.d.ts +139 -0
- package/dist/utils.js +3 -0
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { d as resolveOptions, i as isObject$1, l as renamePlugins, n as ensurePackages, o as overrideConfigs, r as interopDefault, s as parserPlain, u as renameRules } from "./utils-DPFNmhr6.js";
|
|
2
|
+
import { a as getDefaultTailwindcssBetterSettings, i as getDefaultPluginRenameMap, n as getDefaultAllowedNextJsExportNames, r as getDefaultAllowedReactRouterExportNames, t as getDefaultAllowedDependencies } from "./defaults-B3n8wABC.js";
|
|
3
|
+
import { assert, defineEnum, isFunction, isObject } from "@zayne-labs/toolkit-type-helpers";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import { isPackageExists } from "local-pkg";
|
|
5
6
|
import { globalIgnores } from "eslint/config";
|
|
@@ -93,180 +94,6 @@ const GLOB_EXCLUDE = defineEnum([
|
|
|
93
94
|
"**/components.d.ts"
|
|
94
95
|
]);
|
|
95
96
|
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/utils.ts
|
|
98
|
-
const isObject = (value) => {
|
|
99
|
-
return isObjectAndNotArray(value);
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* @description - Combine array and non-array configs into a single array.
|
|
103
|
-
*/
|
|
104
|
-
const combine = async (...configs) => {
|
|
105
|
-
return (await Promise.all(configs)).flat();
|
|
106
|
-
};
|
|
107
|
-
const interopDefault = async (module) => {
|
|
108
|
-
const resolved = await module;
|
|
109
|
-
return resolved.default ?? resolved;
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* @description - Rename plugin prefixes in a rule object.
|
|
113
|
-
* Accepts a map of prefixes to rename.
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```ts
|
|
117
|
-
* import { renameRules } from '@zayne-labs/eslint-config'
|
|
118
|
-
*
|
|
119
|
-
* export default [{
|
|
120
|
-
* rules: renameRules(
|
|
121
|
-
* {
|
|
122
|
-
* '@typescript-eslint/indent': 'error'
|
|
123
|
-
* },
|
|
124
|
-
* { '@typescript-eslint': 'ts' }
|
|
125
|
-
* )
|
|
126
|
-
* }]
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
const renameRules = (rules, renameMap) => {
|
|
130
|
-
if (!rules) return;
|
|
131
|
-
const renamedRulesEntries = Object.entries(rules).map(([ruleKey, ruleValue]) => {
|
|
132
|
-
for (const [oldRuleName, newRuleName] of Object.entries(renameMap)) if (ruleKey.startsWith(`${oldRuleName}/`)) return [`${newRuleName}${ruleKey.slice(oldRuleName.length)}`, ruleValue];
|
|
133
|
-
return [ruleKey, ruleValue];
|
|
134
|
-
});
|
|
135
|
-
return Object.fromEntries(renamedRulesEntries);
|
|
136
|
-
};
|
|
137
|
-
const renamePlugins = (plugins, renameMap) => {
|
|
138
|
-
if (!plugins) return;
|
|
139
|
-
const renamedPluginEntries = Object.entries(plugins).map(([pluginKey, pluginValue]) => {
|
|
140
|
-
if (pluginKey in renameMap) return [renameMap[pluginKey], pluginValue];
|
|
141
|
-
return [pluginKey, pluginValue];
|
|
142
|
-
});
|
|
143
|
-
return Object.fromEntries(renamedPluginEntries);
|
|
144
|
-
};
|
|
145
|
-
const getResolvedOverrides = (options) => {
|
|
146
|
-
const { configItem, overrides } = options;
|
|
147
|
-
return isFunction(overrides) ? overrides(configItem) : overrides;
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* @description - Override configurations in a flat configs array with either a static config object or a function that returns a config object
|
|
151
|
-
* @param options - Configuration options
|
|
152
|
-
* @param options.configs - Array of flat config items to override
|
|
153
|
-
* @param options.overrides - Either a config object to merge or a function that takes a config and returns overrides
|
|
154
|
-
* @returns Array of merged config items with overrides applied
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* ```ts
|
|
158
|
-
* import { overrideConfigs } from '@zayne-labs/eslint-config'
|
|
159
|
-
*
|
|
160
|
-
* // Override with static config
|
|
161
|
-
* overrideConfigs({
|
|
162
|
-
* configArray: existingConfigs,
|
|
163
|
-
* overrides: {
|
|
164
|
-
* rules: {
|
|
165
|
-
* 'no-console': 'error'
|
|
166
|
-
* }
|
|
167
|
-
* }
|
|
168
|
-
* })
|
|
169
|
-
*
|
|
170
|
-
* // Override with function
|
|
171
|
-
* overrideConfigs({
|
|
172
|
-
* configArray: existingConfigs,
|
|
173
|
-
* overrides: (config) => ({
|
|
174
|
-
* ...config,
|
|
175
|
-
* rules: {
|
|
176
|
-
* ...config.rules,
|
|
177
|
-
* 'no-console': 'error'
|
|
178
|
-
* }
|
|
179
|
-
* })
|
|
180
|
-
* })
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
|
-
const overrideConfigs = (options) => {
|
|
184
|
-
const { configArray, overrides } = options;
|
|
185
|
-
return configArray.map((configItem) => ({
|
|
186
|
-
...configItem,
|
|
187
|
-
...getResolvedOverrides({
|
|
188
|
-
configItem,
|
|
189
|
-
overrides
|
|
190
|
-
})
|
|
191
|
-
}));
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* @description - Rename plugin names and rules in a flat configs array
|
|
195
|
-
*
|
|
196
|
-
* @param options - Configuration options
|
|
197
|
-
* @param options.configArray - Array of flat config items to process
|
|
198
|
-
* @param options.overrides - Optional config overrides to apply
|
|
199
|
-
* @param options.renameMap - Map of old plugin names to new names
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* ```ts
|
|
203
|
-
* import { renamePluginInConfigs } from '@zayne-labs/eslint-config'
|
|
204
|
-
* import someConfigs from './some-configs'
|
|
205
|
-
*
|
|
206
|
-
* renamePluginInConfigs({
|
|
207
|
-
* configArray: someConfigs,
|
|
208
|
-
* renameMap: {
|
|
209
|
-
* '@typescript-eslint': 'ts',
|
|
210
|
-
* 'import-x': 'import',
|
|
211
|
-
* }
|
|
212
|
-
* })
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
const renamePluginInConfigs = (options) => {
|
|
216
|
-
const { configArray, overrides, renameMap } = options;
|
|
217
|
-
return overrideConfigs({
|
|
218
|
-
configArray,
|
|
219
|
-
overrides: (configItem) => ({
|
|
220
|
-
...getResolvedOverrides({
|
|
221
|
-
configItem,
|
|
222
|
-
overrides
|
|
223
|
-
}),
|
|
224
|
-
...isObject(configItem.plugins) && { plugins: renamePlugins(configItem.plugins, renameMap) },
|
|
225
|
-
...isObject(configItem.rules) && { rules: renameRules(configItem.rules, renameMap) }
|
|
226
|
-
})
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
230
|
-
const isCwdInScope = isPackageExists("@zayne-labs/eslint-config");
|
|
231
|
-
const isPackageInScope = (name) => isPackageExists(name, { paths: [scopeUrl] });
|
|
232
|
-
/**
|
|
233
|
-
* @description
|
|
234
|
-
* - Ensures that packages are installed in the current scope.
|
|
235
|
-
* - If they are not installed, and the user is in a TTY, and the user is not in a CI environment,
|
|
236
|
-
* and the user is in the same scope as this package, then prompt the user to
|
|
237
|
-
* install the packages.
|
|
238
|
-
*
|
|
239
|
-
* @param packages - The packages to ensure are installed.
|
|
240
|
-
*/
|
|
241
|
-
const ensurePackages = async (packages) => {
|
|
242
|
-
if (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;
|
|
243
|
-
const nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));
|
|
244
|
-
if (nonExistingPackages.length === 0) return;
|
|
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 });
|
|
246
|
-
};
|
|
247
|
-
const resolveOptions = (option) => {
|
|
248
|
-
return isObject(option) ? option : {};
|
|
249
|
-
};
|
|
250
|
-
const parserPlain = {
|
|
251
|
-
meta: { name: "parser-plain" },
|
|
252
|
-
parseForESLint: (code) => ({
|
|
253
|
-
ast: {
|
|
254
|
-
body: [],
|
|
255
|
-
comments: [],
|
|
256
|
-
loc: {
|
|
257
|
-
end: code.length,
|
|
258
|
-
start: 0
|
|
259
|
-
},
|
|
260
|
-
range: [0, code.length],
|
|
261
|
-
tokens: [],
|
|
262
|
-
type: "Program"
|
|
263
|
-
},
|
|
264
|
-
scopeManager: null,
|
|
265
|
-
services: { isPlain: true },
|
|
266
|
-
visitorKeys: { Program: [] }
|
|
267
|
-
})
|
|
268
|
-
};
|
|
269
|
-
|
|
270
97
|
//#endregion
|
|
271
98
|
//#region src/configs/astro.ts
|
|
272
99
|
const astro = async (options = {}) => {
|
|
@@ -858,7 +685,7 @@ const jsx = async (options = {}) => {
|
|
|
858
685
|
name: "zayne/jsx/a11y/rules",
|
|
859
686
|
rules: {
|
|
860
687
|
...overrides,
|
|
861
|
-
...isObject(a11y) && a11y.overrides
|
|
688
|
+
...isObject$1(a11y) && a11y.overrides
|
|
862
689
|
}
|
|
863
690
|
});
|
|
864
691
|
return config;
|
|
@@ -969,7 +796,7 @@ const node = async (options = {}) => {
|
|
|
969
796
|
rules: {
|
|
970
797
|
...eslintPluginSecurity.configs.recommended.rules,
|
|
971
798
|
...overrides,
|
|
972
|
-
...isObject(security) && security.overrides
|
|
799
|
+
...isObject$1(security) && security.overrides
|
|
973
800
|
}
|
|
974
801
|
});
|
|
975
802
|
return config;
|
|
@@ -1194,7 +1021,7 @@ const react = async (options = {}) => {
|
|
|
1194
1021
|
enableReact ? interopDefault(import("@eslint-react/eslint-plugin")) : void 0,
|
|
1195
1022
|
enableReact ? interopDefault(import("eslint-plugin-react-hooks")) : void 0,
|
|
1196
1023
|
refresh ? interopDefault(import("eslint-plugin-react-refresh")) : void 0,
|
|
1197
|
-
youMightNotNeedAnEffect ? interopDefault(import("./src-
|
|
1024
|
+
youMightNotNeedAnEffect ? interopDefault(import("./src-BqZFkya2.js")) : void 0,
|
|
1198
1025
|
nextjs ? interopDefault(import("@next/eslint-plugin-next")) : void 0
|
|
1199
1026
|
]);
|
|
1200
1027
|
const strictConfigKey = typescript$1 ? "strict-type-checked" : "strict";
|
|
@@ -1239,7 +1066,7 @@ const react = async (options = {}) => {
|
|
|
1239
1066
|
"react-x/no-missing-component-display-name": "warn",
|
|
1240
1067
|
"react-x/prefer-read-only-props": "off",
|
|
1241
1068
|
...overrides,
|
|
1242
|
-
...isObject
|
|
1069
|
+
...isObject(enableReact) && enableReact.overrides
|
|
1243
1070
|
}
|
|
1244
1071
|
});
|
|
1245
1072
|
if (compiler && eslintPluginReact) config.push({
|
|
@@ -1261,7 +1088,7 @@ const react = async (options = {}) => {
|
|
|
1261
1088
|
"react-hooks/unsupported-syntax": "error",
|
|
1262
1089
|
"react-hooks/use-memo": "warn",
|
|
1263
1090
|
...overrides,
|
|
1264
|
-
...isObject
|
|
1091
|
+
...isObject(compiler) && compiler.overrides
|
|
1265
1092
|
}
|
|
1266
1093
|
});
|
|
1267
1094
|
if (refresh && eslintPluginReactRefresh) config.push({
|
|
@@ -1274,7 +1101,7 @@ const react = async (options = {}) => {
|
|
|
1274
1101
|
allowExportNames: [...nextjs ? getDefaultAllowedNextJsExportNames() : [], ...isUsingReactRouter ? getDefaultAllowedReactRouterExportNames() : []]
|
|
1275
1102
|
}],
|
|
1276
1103
|
...overrides,
|
|
1277
|
-
...isObject
|
|
1104
|
+
...isObject(refresh) && refresh.overrides
|
|
1278
1105
|
}
|
|
1279
1106
|
});
|
|
1280
1107
|
if (youMightNotNeedAnEffect && eslintPluginReactYouMightNotNeedAnEffect) config.push({
|
|
@@ -1287,7 +1114,7 @@ const react = async (options = {}) => {
|
|
|
1287
1114
|
name: "zayne/react/you-might-not-need-an-effect/rules",
|
|
1288
1115
|
rules: {
|
|
1289
1116
|
...overrides,
|
|
1290
|
-
...isObject
|
|
1117
|
+
...isObject(youMightNotNeedAnEffect) && youMightNotNeedAnEffect.overrides
|
|
1291
1118
|
}
|
|
1292
1119
|
});
|
|
1293
1120
|
if (nextjs && eslintPluginNextjs) config.push({
|
|
@@ -1303,7 +1130,7 @@ const react = async (options = {}) => {
|
|
|
1303
1130
|
name: "zayne/react/nextjs/rules",
|
|
1304
1131
|
rules: {
|
|
1305
1132
|
...overrides,
|
|
1306
|
-
...isObject
|
|
1133
|
+
...isObject(nextjs) && nextjs.overrides
|
|
1307
1134
|
}
|
|
1308
1135
|
});
|
|
1309
1136
|
return config;
|
|
@@ -1664,7 +1491,7 @@ const tanstack = async (options = {}) => {
|
|
|
1664
1491
|
name: "zayne/tanstack-query/rules",
|
|
1665
1492
|
rules: {
|
|
1666
1493
|
...overrides,
|
|
1667
|
-
...isObject(query) && query.overrides
|
|
1494
|
+
...isObject$1(query) && query.overrides
|
|
1668
1495
|
}
|
|
1669
1496
|
});
|
|
1670
1497
|
if (router && eslintPluginTanstackRouter) config.push({
|
|
@@ -1675,7 +1502,7 @@ const tanstack = async (options = {}) => {
|
|
|
1675
1502
|
name: "zayne/tanstack-router/rules",
|
|
1676
1503
|
rules: {
|
|
1677
1504
|
...overrides,
|
|
1678
|
-
...isObject(router) && router.overrides
|
|
1505
|
+
...isObject$1(router) && router.overrides
|
|
1679
1506
|
}
|
|
1680
1507
|
});
|
|
1681
1508
|
return config;
|
|
@@ -2162,7 +1989,7 @@ const zayne = (options = {}, ...userConfigs) => {
|
|
|
2162
1989
|
const enableMarkdown = restOfOptions.markdown ?? withDefaults;
|
|
2163
1990
|
const enablePnpmCatalogs = restOfOptions.pnpm ?? (withDefaults && Boolean(findUpSync("pnpm-workspace.yaml")));
|
|
2164
1991
|
const isStylistic = Boolean(enableStylistic);
|
|
2165
|
-
const tsconfigPath = isObject(enableTypeScript) && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : enableTypeScript === true ? enableTypeScript : null;
|
|
1992
|
+
const tsconfigPath = isObject$1(enableTypeScript) && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : enableTypeScript === true ? enableTypeScript : null;
|
|
2166
1993
|
const isTypeAware = Boolean(tsconfigPath);
|
|
2167
1994
|
const configs = [ignores(userIgnores), javascript(restOfOptions.javascript)];
|
|
2168
1995
|
if (enableGitignore) configs.push(gitIgnores(resolveOptions(enableGitignore)));
|
|
@@ -2249,5 +2076,5 @@ const zayne = (options = {}, ...userConfigs) => {
|
|
|
2249
2076
|
};
|
|
2250
2077
|
|
|
2251
2078
|
//#endregion
|
|
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,
|
|
2079
|
+
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, comments, depend, expo, gitIgnores, ignores, imports, javascript, jsdoc, jsonc, jsx, markdown, node, perfectionist, pnpm, react, solid, sortPackageJson, sortTsconfig, stylistic, tailwindcssBetter, tanstack, toml, typescript, unicorn, vue, yaml, zayne };
|
|
2253
2080
|
//# sourceMappingURL=index.js.map
|