@alextheman/eslint-plugin 4.10.0 → 5.0.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/dist/index.cjs +94 -39
- package/dist/index.d.cts +51 -10
- package/dist/index.d.ts +51 -10
- package/dist/index.js +95 -41
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3479,6 +3479,67 @@ function createRuleSchemaFromZodSchema(schema$1) {
|
|
|
3479
3479
|
}
|
|
3480
3480
|
var createRuleSchemaFromZodSchema_default = createRuleSchemaFromZodSchema;
|
|
3481
3481
|
|
|
3482
|
+
//#endregion
|
|
3483
|
+
//#region src/utility/private/camelToKebab.ts
|
|
3484
|
+
function camelToKebab(string) {
|
|
3485
|
+
if (string[0] === string[0].toUpperCase()) throw new _alextheman_utility.DataError(string, "CAMEL_TO_KEBAB_CONVERSION_ERROR", "camelCase string must start with a lowercase letter.");
|
|
3486
|
+
return (0, _alextheman_utility.camelToKebab)(string, { preserveConsecutiveCapitals: false });
|
|
3487
|
+
}
|
|
3488
|
+
var camelToKebab_default = camelToKebab;
|
|
3489
|
+
|
|
3490
|
+
//#endregion
|
|
3491
|
+
//#region src/utility/private/createConfigGroup.ts
|
|
3492
|
+
function createConfigGroup(group, configs) {
|
|
3493
|
+
const newConfigs = {};
|
|
3494
|
+
for (const key in configs) newConfigs[`${camelToKebab_default(group)}/${camelToKebab_default(key)}`] = configs[key];
|
|
3495
|
+
return newConfigs;
|
|
3496
|
+
}
|
|
3497
|
+
var createConfigGroup_default = createConfigGroup;
|
|
3498
|
+
|
|
3499
|
+
//#endregion
|
|
3500
|
+
//#region src/utility/public/flattenConfigs.ts
|
|
3501
|
+
/**
|
|
3502
|
+
* Takes in a nested group of configs, and returns them flattened according to ESLint config naming conventions.
|
|
3503
|
+
*
|
|
3504
|
+
* @template ConfigObject - The type of the input config object.
|
|
3505
|
+
*
|
|
3506
|
+
* @param config - A doubly-nested config object to pass in, where the key of the top-level object is the config group name, and the key of the nested object is the name of the config within the group (e.g. `groupName.configName`).
|
|
3507
|
+
*
|
|
3508
|
+
* @returns A single-layered object with the key flattened down to be `group-name/config-name`.
|
|
3509
|
+
*
|
|
3510
|
+
* @example
|
|
3511
|
+
* flattenConfigs<AlexPluginConfigGroup>({
|
|
3512
|
+
* general: {
|
|
3513
|
+
* typeScript: generalTypeScriptConfig,
|
|
3514
|
+
* javaScript: generalJavaScriptConfig,
|
|
3515
|
+
* react: generalReactConfig,
|
|
3516
|
+
* // ...
|
|
3517
|
+
* }
|
|
3518
|
+
* plugin: {
|
|
3519
|
+
* base: pluginBaseConfig,
|
|
3520
|
+
* tests: pluginTestsConfig,
|
|
3521
|
+
* // ...
|
|
3522
|
+
* }
|
|
3523
|
+
* })
|
|
3524
|
+
*
|
|
3525
|
+
* // Returns:
|
|
3526
|
+
* {
|
|
3527
|
+
* "general/typescript": generalTypeScriptConfig,
|
|
3528
|
+
* "general/javascript": generalJavaScriptConfig,
|
|
3529
|
+
* "general/react": generalReactConfig,
|
|
3530
|
+
* // ...,
|
|
3531
|
+
* "plugin/base": pluginBaseConfig,
|
|
3532
|
+
* "plugin/tests": pluginTestsConfig
|
|
3533
|
+
* // ...
|
|
3534
|
+
* }
|
|
3535
|
+
*/
|
|
3536
|
+
function flattenConfigs(config) {
|
|
3537
|
+
const allConfigs = {};
|
|
3538
|
+
for (const configGroupEntries of Object.entries(config)) Object.assign(allConfigs, createConfigGroup_default(...configGroupEntries));
|
|
3539
|
+
return allConfigs;
|
|
3540
|
+
}
|
|
3541
|
+
var flattenConfigs_default = flattenConfigs;
|
|
3542
|
+
|
|
3482
3543
|
//#endregion
|
|
3483
3544
|
//#region src/utility/public/getImportSpecifiersAfterRemoving.ts
|
|
3484
3545
|
/**
|
|
@@ -3607,6 +3668,7 @@ var unusedVarsIgnorePatterns_default = unusedVarsIgnorePatterns;
|
|
|
3607
3668
|
const generalJavaScript = [
|
|
3608
3669
|
_eslint_js.default.configs.recommended,
|
|
3609
3670
|
eslint_config_prettier.default,
|
|
3671
|
+
eslint_plugin_n.default.configs["flat/recommended"],
|
|
3610
3672
|
{
|
|
3611
3673
|
files: [
|
|
3612
3674
|
"**/*.js",
|
|
@@ -3624,6 +3686,18 @@ const generalJavaScript = [
|
|
|
3624
3686
|
rules: {
|
|
3625
3687
|
eqeqeq: "error",
|
|
3626
3688
|
"import/no-unresolved": "error",
|
|
3689
|
+
"n/file-extension-in-import": [
|
|
3690
|
+
"error",
|
|
3691
|
+
"always",
|
|
3692
|
+
{
|
|
3693
|
+
".js": "never",
|
|
3694
|
+
".jsx": "never",
|
|
3695
|
+
".ts": "never",
|
|
3696
|
+
".tsx": "never"
|
|
3697
|
+
}
|
|
3698
|
+
],
|
|
3699
|
+
"n/no-missing-import": "off",
|
|
3700
|
+
"n/no-path-concat": "error",
|
|
3627
3701
|
"n/prefer-node-protocol": "error",
|
|
3628
3702
|
"no-cond-assign": "error",
|
|
3629
3703
|
"no-console": ["error", { allow: [
|
|
@@ -3956,8 +4030,12 @@ var typeScript_default$2 = generalTypeScript;
|
|
|
3956
4030
|
//#endregion
|
|
3957
4031
|
//#region src/configs/personal/alexCLine.ts
|
|
3958
4032
|
const personalAlexCLine = [{
|
|
3959
|
-
files: ["src
|
|
4033
|
+
files: ["src/**/*.ts"],
|
|
3960
4034
|
name: "@alextheman/personal/alex-c-line",
|
|
4035
|
+
plugins: { n: eslint_plugin_n.default },
|
|
4036
|
+
rules: { "n/hashbang": "off" }
|
|
4037
|
+
}, {
|
|
4038
|
+
files: ["src/commands/index.ts"],
|
|
3961
4039
|
plugins: { perfectionist: eslint_plugin_perfectionist.default },
|
|
3962
4040
|
rules: { "perfectionist/sort-objects": ["error", sortObjects_default] }
|
|
3963
4041
|
}];
|
|
@@ -3984,7 +4062,8 @@ const personalTypeScriptPackage = [eslint_plugin_jsdoc.default.configs["flat/rec
|
|
|
3984
4062
|
{ tags: ["template"] },
|
|
3985
4063
|
{ tags: ["param"] },
|
|
3986
4064
|
{ tags: ["throws"] },
|
|
3987
|
-
{ tags: ["returns"] }
|
|
4065
|
+
{ tags: ["returns"] },
|
|
4066
|
+
{ tags: ["example"] }
|
|
3988
4067
|
] }],
|
|
3989
4068
|
"jsdoc/tag-lines": [
|
|
3990
4069
|
"error",
|
|
@@ -4203,61 +4282,36 @@ function combinedTypeScriptReact(plugin) {
|
|
|
4203
4282
|
}
|
|
4204
4283
|
var typeScriptReact_default = combinedTypeScriptReact;
|
|
4205
4284
|
|
|
4206
|
-
//#endregion
|
|
4207
|
-
//#region src/utility/private/camelToKebab.ts
|
|
4208
|
-
function camelToKebab(string) {
|
|
4209
|
-
return (0, _alextheman_utility.camelToKebab)(string.replace(/[Tt]ypeScript/, "typescript").replace(/[Jj]avaScript/, "javascript"));
|
|
4210
|
-
}
|
|
4211
|
-
var camelToKebab_default = camelToKebab;
|
|
4212
|
-
|
|
4213
|
-
//#endregion
|
|
4214
|
-
//#region src/utility/private/createConfigGroup.ts
|
|
4215
|
-
function createConfigGroup(group, configs) {
|
|
4216
|
-
const newConfigs = {};
|
|
4217
|
-
for (const key in configs) newConfigs[`${camelToKebab_default(group)}/${camelToKebab_default(key)}`] = configs[key];
|
|
4218
|
-
return newConfigs;
|
|
4219
|
-
}
|
|
4220
|
-
var createConfigGroup_default = createConfigGroup;
|
|
4221
|
-
|
|
4222
|
-
//#endregion
|
|
4223
|
-
//#region src/utility/private/createPluginConfigs.ts
|
|
4224
|
-
function createPluginConfigs(config) {
|
|
4225
|
-
const allConfigs = {};
|
|
4226
|
-
for (const configGroupEntries of Object.entries(config)) Object.assign(allConfigs, createConfigGroup_default(...configGroupEntries));
|
|
4227
|
-
return allConfigs;
|
|
4228
|
-
}
|
|
4229
|
-
var createPluginConfigs_default = createPluginConfigs;
|
|
4230
|
-
|
|
4231
4285
|
//#endregion
|
|
4232
4286
|
//#region src/configs/index.ts
|
|
4233
4287
|
function createAlexPluginConfigs(plugin) {
|
|
4234
|
-
return
|
|
4288
|
+
return flattenConfigs_default({
|
|
4235
4289
|
combined: {
|
|
4236
|
-
|
|
4237
|
-
|
|
4290
|
+
javascript: [...javaScript_default(plugin), ...packageJson_default],
|
|
4291
|
+
javascriptReact: [...javaScriptReact_default(plugin), ...packageJson_default],
|
|
4238
4292
|
react: [...react_default, ...packageJson_default],
|
|
4239
4293
|
tests: [...tests_default(plugin), ...packageJson_default],
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4294
|
+
typescript: [...typeScript_default(plugin), ...packageJson_default],
|
|
4295
|
+
typescriptPackage: [...typeScriptPackage_default(plugin), ...packageJson_default],
|
|
4296
|
+
typescriptReact: [...typeScriptReact_default(plugin), ...packageJson_default]
|
|
4243
4297
|
},
|
|
4244
4298
|
general: {
|
|
4245
|
-
|
|
4299
|
+
javascript: javaScript_default$1,
|
|
4246
4300
|
packageJson: packageJson_default,
|
|
4247
4301
|
react: react_default$2,
|
|
4248
|
-
|
|
4302
|
+
typescript: typeScript_default$2
|
|
4249
4303
|
},
|
|
4250
4304
|
personal: {
|
|
4251
4305
|
alexCLine: alexCLine_default,
|
|
4252
4306
|
components: components_default,
|
|
4253
4307
|
eslintPlugin: eslintPlugin_default(plugin),
|
|
4254
|
-
|
|
4308
|
+
javascript: javaScriptBase_default(plugin),
|
|
4255
4309
|
neurosongsBackEnd: neurosongsBackEnd_default,
|
|
4256
4310
|
neurosongsFrontEnd: neurosongsFrontEnd_default,
|
|
4257
4311
|
react: react_default$1,
|
|
4258
4312
|
tests: tests_default$2,
|
|
4259
|
-
|
|
4260
|
-
|
|
4313
|
+
typescript: typeScript_default$1(plugin),
|
|
4314
|
+
typescriptPackage: typeScriptPackage_default$1,
|
|
4261
4315
|
utility: utility_default
|
|
4262
4316
|
},
|
|
4263
4317
|
plugin: {
|
|
@@ -4686,7 +4740,7 @@ var rules_default = {
|
|
|
4686
4740
|
//#endregion
|
|
4687
4741
|
//#region package.json
|
|
4688
4742
|
var name = "@alextheman/eslint-plugin";
|
|
4689
|
-
var version = "
|
|
4743
|
+
var version = "5.0.0";
|
|
4690
4744
|
|
|
4691
4745
|
//#endregion
|
|
4692
4746
|
//#region src/alexPlugin.ts
|
|
@@ -4712,6 +4766,7 @@ exports.combineRestrictedImports = combineRestrictedImports_default;
|
|
|
4712
4766
|
exports.createRuleSchemaFromZodSchema = createRuleSchemaFromZodSchema_default;
|
|
4713
4767
|
exports.default = src_default;
|
|
4714
4768
|
exports.fixOnCondition = fixOnCondition_default;
|
|
4769
|
+
exports.flattenConfigs = flattenConfigs_default;
|
|
4715
4770
|
exports.getImportSpecifiersAfterRemoving = getImportSpecifiersAfterRemoving_default;
|
|
4716
4771
|
exports.parseConsistentTestFunctionOptions = parseConsistentTestFunctionOptions;
|
|
4717
4772
|
exports.parseNoNamespaceImportsOptions = parseNoNamespaceImportsOptions;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Linter } from "eslint";
|
|
2
|
-
import { IgnoreCase } from "@alextheman/utility";
|
|
3
2
|
import { Config } from "prettier";
|
|
4
3
|
import * as vite0 from "vite";
|
|
5
4
|
import { VitestEnvironment } from "vitest/node";
|
|
@@ -9,24 +8,28 @@ import { TSESTree } from "@typescript-eslint/utils";
|
|
|
9
8
|
import { JSONSchema4 } from "@typescript-eslint/utils/json-schema";
|
|
10
9
|
|
|
11
10
|
//#region src/utility/private/camelToKebab.d.ts
|
|
12
|
-
type CamelToKebab<S extends string> = S extends `${
|
|
11
|
+
type CamelToKebab<S extends string> = S extends `${infer Head}${infer Tail}` ? Head extends Lowercase<Head> ? `${Head}${CamelToKebab<Tail>}` : `-${Lowercase<Head>}${CamelToKebab<Tail>}` : S;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/utility/public/GetFlattenedConfigNames.d.ts
|
|
14
|
+
type GetFlattenedConfigNames<ConfigObject extends { [K in keyof ConfigObject]: Record<string, Linter.Config[]> }> = { [Group in keyof ConfigObject & string]: `${CamelToKebab<Group>}/${CamelToKebab<keyof ConfigObject[Group] & string>}` }[keyof ConfigObject & string];
|
|
13
15
|
//#endregion
|
|
14
16
|
//#region src/configs/AlexPluginConfigGroup.d.ts
|
|
15
|
-
type GeneralConfig = "
|
|
17
|
+
type GeneralConfig = "javascript" | "typescript" | "react" | "packageJson";
|
|
16
18
|
type PluginConfig = "base" | "tests";
|
|
17
|
-
type PersonalConfig = "
|
|
18
|
-
type CombinedConfig = "
|
|
19
|
-
interface
|
|
19
|
+
type PersonalConfig = "javascript" | "typescript" | "react" | "tests" | "eslintPlugin" | "neurosongsBackEnd" | "neurosongsFrontEnd" | "utility" | "alexCLine" | "typescriptPackage" | "components";
|
|
20
|
+
type CombinedConfig = "javascript" | "typescript" | "react" | "tests" | "typescriptReact" | "javascriptReact" | "typescriptPackage";
|
|
21
|
+
interface AlexPluginConfigObject {
|
|
20
22
|
general: Record<GeneralConfig, Linter.Config[]>;
|
|
21
23
|
plugin: Record<PluginConfig, Linter.Config[]>;
|
|
22
24
|
personal: Record<PersonalConfig, Linter.Config[]>;
|
|
23
25
|
combined: Record<CombinedConfig, Linter.Config[]>;
|
|
24
26
|
}
|
|
25
|
-
type
|
|
26
|
-
type
|
|
27
|
+
type AlexConfigGroupName = keyof AlexPluginConfigObject;
|
|
28
|
+
type AlexFlattenedConfigName = GetFlattenedConfigNames<AlexPluginConfigObject>;
|
|
29
|
+
type AlexPluginConfigFlattened = Record<AlexFlattenedConfigName, Linter.Config[]>;
|
|
27
30
|
//#endregion
|
|
28
31
|
//#region src/configs/index.d.ts
|
|
29
|
-
declare function createAlexPluginConfigs(plugin: Readonly<AlexPlugin>): Record<
|
|
32
|
+
declare function createAlexPluginConfigs(plugin: Readonly<AlexPlugin>): Record<AlexFlattenedConfigName, Linter.Config[]>;
|
|
30
33
|
//#endregion
|
|
31
34
|
//#region package.d.ts
|
|
32
35
|
declare let name: string;
|
|
@@ -269,6 +272,44 @@ declare function combineRestrictedImports(...groups: NoRestrictedImportsOptions[
|
|
|
269
272
|
*/
|
|
270
273
|
declare function createRuleSchemaFromZodSchema(schema: z.ZodType): JSONSchema4[];
|
|
271
274
|
//#endregion
|
|
275
|
+
//#region src/utility/public/flattenConfigs.d.ts
|
|
276
|
+
/**
|
|
277
|
+
* Takes in a nested group of configs, and returns them flattened according to ESLint config naming conventions.
|
|
278
|
+
*
|
|
279
|
+
* @template ConfigObject - The type of the input config object.
|
|
280
|
+
*
|
|
281
|
+
* @param config - A doubly-nested config object to pass in, where the key of the top-level object is the config group name, and the key of the nested object is the name of the config within the group (e.g. `groupName.configName`).
|
|
282
|
+
*
|
|
283
|
+
* @returns A single-layered object with the key flattened down to be `group-name/config-name`.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* flattenConfigs<AlexPluginConfigGroup>({
|
|
287
|
+
* general: {
|
|
288
|
+
* typeScript: generalTypeScriptConfig,
|
|
289
|
+
* javaScript: generalJavaScriptConfig,
|
|
290
|
+
* react: generalReactConfig,
|
|
291
|
+
* // ...
|
|
292
|
+
* }
|
|
293
|
+
* plugin: {
|
|
294
|
+
* base: pluginBaseConfig,
|
|
295
|
+
* tests: pluginTestsConfig,
|
|
296
|
+
* // ...
|
|
297
|
+
* }
|
|
298
|
+
* })
|
|
299
|
+
*
|
|
300
|
+
* // Returns:
|
|
301
|
+
* {
|
|
302
|
+
* "general/typescript": generalTypeScriptConfig,
|
|
303
|
+
* "general/javascript": generalJavaScriptConfig,
|
|
304
|
+
* "general/react": generalReactConfig,
|
|
305
|
+
* // ...,
|
|
306
|
+
* "plugin/base": pluginBaseConfig,
|
|
307
|
+
* "plugin/tests": pluginTestsConfig
|
|
308
|
+
* // ...
|
|
309
|
+
* }
|
|
310
|
+
*/
|
|
311
|
+
declare function flattenConfigs<ConfigObject extends { [K in keyof ConfigObject]: Record<string, Linter.Config[]> }>(config: ConfigObject): Record<GetFlattenedConfigNames<ConfigObject>, Linter.Config[]>;
|
|
312
|
+
//#endregion
|
|
272
313
|
//#region src/utility/public/getImportSpecifiersAfterRemoving.d.ts
|
|
273
314
|
/**
|
|
274
315
|
* Returns a comma-separated string of import specifiers, excluding the specified import.
|
|
@@ -285,4 +326,4 @@ declare function createRuleSchemaFromZodSchema(schema: z.ZodType): JSONSchema4[]
|
|
|
285
326
|
*/
|
|
286
327
|
declare function getImportSpecifiersAfterRemoving<RuleOptions>(context: Readonly<RuleContext<"message", [RuleOptions]>>, specifiers: TSESTree.ImportClause[], importToRemove: string): string;
|
|
287
328
|
//#endregion
|
|
288
|
-
export { type AlexPlugin,
|
|
329
|
+
export { AlexConfigGroupName, AlexFlattenedConfigName, type AlexPlugin, AlexPluginConfigFlattened, AlexPluginConfigObject, CombinedConfig, type GetFlattenedConfigNames as ConfigKey, ConsistentTestFunctionOptions, GeneralConfig, NoNamespaceImportsOptions, NoRelativeImportsOptions, type NoRestrictedImportsOptions, PersonalConfig, PluginConfig, type RestrictedPathImport, type RestrictedPatternImport, RuleFixerFunction, StandardiseErrorMessagesOptions, TestFunction, UseNormalizedImportsOptions, checkCallExpression, combineRestrictedImports, createRuleSchemaFromZodSchema, alexPlugin as default, fixOnCondition, flattenConfigs, getImportSpecifiersAfterRemoving, parseConsistentTestFunctionOptions, parseNoNamespaceImportsOptions, parseNoRelativeImportsOptions, parseStandardiseErrorMessagesOptions, parseTestFunction, parseUseNormalizedImportsOptions, prettierRules, reactLanguageOptions, sortExports, sortImports, sortObjects, typeScriptLanguageOptions, unusedVarsIgnorePatterns, vitestConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IgnoreCase } from "@alextheman/utility";
|
|
2
1
|
import { TSESTree } from "@typescript-eslint/utils";
|
|
3
2
|
import z from "zod";
|
|
4
3
|
import { Linter } from "eslint";
|
|
@@ -9,24 +8,28 @@ import { RuleContext, RuleFix, RuleFixer } from "@typescript-eslint/utils/ts-esl
|
|
|
9
8
|
import { JSONSchema4 } from "@typescript-eslint/utils/json-schema";
|
|
10
9
|
|
|
11
10
|
//#region src/utility/private/camelToKebab.d.ts
|
|
12
|
-
type CamelToKebab<S extends string> = S extends `${
|
|
11
|
+
type CamelToKebab<S extends string> = S extends `${infer Head}${infer Tail}` ? Head extends Lowercase<Head> ? `${Head}${CamelToKebab<Tail>}` : `-${Lowercase<Head>}${CamelToKebab<Tail>}` : S;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/utility/public/GetFlattenedConfigNames.d.ts
|
|
14
|
+
type GetFlattenedConfigNames<ConfigObject extends { [K in keyof ConfigObject]: Record<string, Linter.Config[]> }> = { [Group in keyof ConfigObject & string]: `${CamelToKebab<Group>}/${CamelToKebab<keyof ConfigObject[Group] & string>}` }[keyof ConfigObject & string];
|
|
13
15
|
//#endregion
|
|
14
16
|
//#region src/configs/AlexPluginConfigGroup.d.ts
|
|
15
|
-
type GeneralConfig = "
|
|
17
|
+
type GeneralConfig = "javascript" | "typescript" | "react" | "packageJson";
|
|
16
18
|
type PluginConfig = "base" | "tests";
|
|
17
|
-
type PersonalConfig = "
|
|
18
|
-
type CombinedConfig = "
|
|
19
|
-
interface
|
|
19
|
+
type PersonalConfig = "javascript" | "typescript" | "react" | "tests" | "eslintPlugin" | "neurosongsBackEnd" | "neurosongsFrontEnd" | "utility" | "alexCLine" | "typescriptPackage" | "components";
|
|
20
|
+
type CombinedConfig = "javascript" | "typescript" | "react" | "tests" | "typescriptReact" | "javascriptReact" | "typescriptPackage";
|
|
21
|
+
interface AlexPluginConfigObject {
|
|
20
22
|
general: Record<GeneralConfig, Linter.Config[]>;
|
|
21
23
|
plugin: Record<PluginConfig, Linter.Config[]>;
|
|
22
24
|
personal: Record<PersonalConfig, Linter.Config[]>;
|
|
23
25
|
combined: Record<CombinedConfig, Linter.Config[]>;
|
|
24
26
|
}
|
|
25
|
-
type
|
|
26
|
-
type
|
|
27
|
+
type AlexConfigGroupName = keyof AlexPluginConfigObject;
|
|
28
|
+
type AlexFlattenedConfigName = GetFlattenedConfigNames<AlexPluginConfigObject>;
|
|
29
|
+
type AlexPluginConfigFlattened = Record<AlexFlattenedConfigName, Linter.Config[]>;
|
|
27
30
|
//#endregion
|
|
28
31
|
//#region src/configs/index.d.ts
|
|
29
|
-
declare function createAlexPluginConfigs(plugin: Readonly<AlexPlugin>): Record<
|
|
32
|
+
declare function createAlexPluginConfigs(plugin: Readonly<AlexPlugin>): Record<AlexFlattenedConfigName, Linter.Config[]>;
|
|
30
33
|
//#endregion
|
|
31
34
|
//#region package.d.ts
|
|
32
35
|
declare let name: string;
|
|
@@ -269,6 +272,44 @@ declare function combineRestrictedImports(...groups: NoRestrictedImportsOptions[
|
|
|
269
272
|
*/
|
|
270
273
|
declare function createRuleSchemaFromZodSchema(schema: z.ZodType): JSONSchema4[];
|
|
271
274
|
//#endregion
|
|
275
|
+
//#region src/utility/public/flattenConfigs.d.ts
|
|
276
|
+
/**
|
|
277
|
+
* Takes in a nested group of configs, and returns them flattened according to ESLint config naming conventions.
|
|
278
|
+
*
|
|
279
|
+
* @template ConfigObject - The type of the input config object.
|
|
280
|
+
*
|
|
281
|
+
* @param config - A doubly-nested config object to pass in, where the key of the top-level object is the config group name, and the key of the nested object is the name of the config within the group (e.g. `groupName.configName`).
|
|
282
|
+
*
|
|
283
|
+
* @returns A single-layered object with the key flattened down to be `group-name/config-name`.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* flattenConfigs<AlexPluginConfigGroup>({
|
|
287
|
+
* general: {
|
|
288
|
+
* typeScript: generalTypeScriptConfig,
|
|
289
|
+
* javaScript: generalJavaScriptConfig,
|
|
290
|
+
* react: generalReactConfig,
|
|
291
|
+
* // ...
|
|
292
|
+
* }
|
|
293
|
+
* plugin: {
|
|
294
|
+
* base: pluginBaseConfig,
|
|
295
|
+
* tests: pluginTestsConfig,
|
|
296
|
+
* // ...
|
|
297
|
+
* }
|
|
298
|
+
* })
|
|
299
|
+
*
|
|
300
|
+
* // Returns:
|
|
301
|
+
* {
|
|
302
|
+
* "general/typescript": generalTypeScriptConfig,
|
|
303
|
+
* "general/javascript": generalJavaScriptConfig,
|
|
304
|
+
* "general/react": generalReactConfig,
|
|
305
|
+
* // ...,
|
|
306
|
+
* "plugin/base": pluginBaseConfig,
|
|
307
|
+
* "plugin/tests": pluginTestsConfig
|
|
308
|
+
* // ...
|
|
309
|
+
* }
|
|
310
|
+
*/
|
|
311
|
+
declare function flattenConfigs<ConfigObject extends { [K in keyof ConfigObject]: Record<string, Linter.Config[]> }>(config: ConfigObject): Record<GetFlattenedConfigNames<ConfigObject>, Linter.Config[]>;
|
|
312
|
+
//#endregion
|
|
272
313
|
//#region src/utility/public/getImportSpecifiersAfterRemoving.d.ts
|
|
273
314
|
/**
|
|
274
315
|
* Returns a comma-separated string of import specifiers, excluding the specified import.
|
|
@@ -285,4 +326,4 @@ declare function createRuleSchemaFromZodSchema(schema: z.ZodType): JSONSchema4[]
|
|
|
285
326
|
*/
|
|
286
327
|
declare function getImportSpecifiersAfterRemoving<RuleOptions>(context: Readonly<RuleContext<"message", [RuleOptions]>>, specifiers: TSESTree.ImportClause[], importToRemove: string): string;
|
|
287
328
|
//#endregion
|
|
288
|
-
export { type AlexPlugin,
|
|
329
|
+
export { AlexConfigGroupName, AlexFlattenedConfigName, type AlexPlugin, AlexPluginConfigFlattened, AlexPluginConfigObject, CombinedConfig, type GetFlattenedConfigNames as ConfigKey, type ConsistentTestFunctionOptions, GeneralConfig, type NoNamespaceImportsOptions, type NoRelativeImportsOptions, type NoRestrictedImportsOptions, PersonalConfig, PluginConfig, type RestrictedPathImport, type RestrictedPatternImport, type RuleFixerFunction, type StandardiseErrorMessagesOptions, type TestFunction, type UseNormalizedImportsOptions, checkCallExpression, combineRestrictedImports, createRuleSchemaFromZodSchema, alexPlugin as default, fixOnCondition, flattenConfigs, getImportSpecifiersAfterRemoving, parseConsistentTestFunctionOptions, parseNoNamespaceImportsOptions, parseNoRelativeImportsOptions, parseStandardiseErrorMessagesOptions, parseTestFunction, parseUseNormalizedImportsOptions, prettierRules, reactLanguageOptions, sortExports, sortImports, sortObjects, typeScriptLanguageOptions, unusedVarsIgnorePatterns, vitestConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { camelToKebab, deepCopy, deepFreeze, normalizeImportPath, omitProperties } from "@alextheman/utility";
|
|
1
|
+
import { DataError, camelToKebab, deepCopy, deepFreeze, normalizeImportPath, omitProperties } from "@alextheman/utility";
|
|
2
2
|
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
3
3
|
import z from "zod";
|
|
4
4
|
import js from "@eslint/js";
|
|
@@ -3463,6 +3463,67 @@ function createRuleSchemaFromZodSchema(schema$1) {
|
|
|
3463
3463
|
}
|
|
3464
3464
|
var createRuleSchemaFromZodSchema_default = createRuleSchemaFromZodSchema;
|
|
3465
3465
|
|
|
3466
|
+
//#endregion
|
|
3467
|
+
//#region src/utility/private/camelToKebab.ts
|
|
3468
|
+
function camelToKebab$1(string) {
|
|
3469
|
+
if (string[0] === string[0].toUpperCase()) throw new DataError(string, "CAMEL_TO_KEBAB_CONVERSION_ERROR", "camelCase string must start with a lowercase letter.");
|
|
3470
|
+
return camelToKebab(string, { preserveConsecutiveCapitals: false });
|
|
3471
|
+
}
|
|
3472
|
+
var camelToKebab_default = camelToKebab$1;
|
|
3473
|
+
|
|
3474
|
+
//#endregion
|
|
3475
|
+
//#region src/utility/private/createConfigGroup.ts
|
|
3476
|
+
function createConfigGroup(group, configs) {
|
|
3477
|
+
const newConfigs = {};
|
|
3478
|
+
for (const key in configs) newConfigs[`${camelToKebab_default(group)}/${camelToKebab_default(key)}`] = configs[key];
|
|
3479
|
+
return newConfigs;
|
|
3480
|
+
}
|
|
3481
|
+
var createConfigGroup_default = createConfigGroup;
|
|
3482
|
+
|
|
3483
|
+
//#endregion
|
|
3484
|
+
//#region src/utility/public/flattenConfigs.ts
|
|
3485
|
+
/**
|
|
3486
|
+
* Takes in a nested group of configs, and returns them flattened according to ESLint config naming conventions.
|
|
3487
|
+
*
|
|
3488
|
+
* @template ConfigObject - The type of the input config object.
|
|
3489
|
+
*
|
|
3490
|
+
* @param config - A doubly-nested config object to pass in, where the key of the top-level object is the config group name, and the key of the nested object is the name of the config within the group (e.g. `groupName.configName`).
|
|
3491
|
+
*
|
|
3492
|
+
* @returns A single-layered object with the key flattened down to be `group-name/config-name`.
|
|
3493
|
+
*
|
|
3494
|
+
* @example
|
|
3495
|
+
* flattenConfigs<AlexPluginConfigGroup>({
|
|
3496
|
+
* general: {
|
|
3497
|
+
* typeScript: generalTypeScriptConfig,
|
|
3498
|
+
* javaScript: generalJavaScriptConfig,
|
|
3499
|
+
* react: generalReactConfig,
|
|
3500
|
+
* // ...
|
|
3501
|
+
* }
|
|
3502
|
+
* plugin: {
|
|
3503
|
+
* base: pluginBaseConfig,
|
|
3504
|
+
* tests: pluginTestsConfig,
|
|
3505
|
+
* // ...
|
|
3506
|
+
* }
|
|
3507
|
+
* })
|
|
3508
|
+
*
|
|
3509
|
+
* // Returns:
|
|
3510
|
+
* {
|
|
3511
|
+
* "general/typescript": generalTypeScriptConfig,
|
|
3512
|
+
* "general/javascript": generalJavaScriptConfig,
|
|
3513
|
+
* "general/react": generalReactConfig,
|
|
3514
|
+
* // ...,
|
|
3515
|
+
* "plugin/base": pluginBaseConfig,
|
|
3516
|
+
* "plugin/tests": pluginTestsConfig
|
|
3517
|
+
* // ...
|
|
3518
|
+
* }
|
|
3519
|
+
*/
|
|
3520
|
+
function flattenConfigs(config) {
|
|
3521
|
+
const allConfigs = {};
|
|
3522
|
+
for (const configGroupEntries of Object.entries(config)) Object.assign(allConfigs, createConfigGroup_default(...configGroupEntries));
|
|
3523
|
+
return allConfigs;
|
|
3524
|
+
}
|
|
3525
|
+
var flattenConfigs_default = flattenConfigs;
|
|
3526
|
+
|
|
3466
3527
|
//#endregion
|
|
3467
3528
|
//#region src/utility/public/getImportSpecifiersAfterRemoving.ts
|
|
3468
3529
|
/**
|
|
@@ -3591,6 +3652,7 @@ var unusedVarsIgnorePatterns_default = unusedVarsIgnorePatterns;
|
|
|
3591
3652
|
const generalJavaScript = [
|
|
3592
3653
|
js.configs.recommended,
|
|
3593
3654
|
prettierConfig,
|
|
3655
|
+
nodePlugin.configs["flat/recommended"],
|
|
3594
3656
|
{
|
|
3595
3657
|
files: [
|
|
3596
3658
|
"**/*.js",
|
|
@@ -3608,6 +3670,18 @@ const generalJavaScript = [
|
|
|
3608
3670
|
rules: {
|
|
3609
3671
|
eqeqeq: "error",
|
|
3610
3672
|
"import/no-unresolved": "error",
|
|
3673
|
+
"n/file-extension-in-import": [
|
|
3674
|
+
"error",
|
|
3675
|
+
"always",
|
|
3676
|
+
{
|
|
3677
|
+
".js": "never",
|
|
3678
|
+
".jsx": "never",
|
|
3679
|
+
".ts": "never",
|
|
3680
|
+
".tsx": "never"
|
|
3681
|
+
}
|
|
3682
|
+
],
|
|
3683
|
+
"n/no-missing-import": "off",
|
|
3684
|
+
"n/no-path-concat": "error",
|
|
3611
3685
|
"n/prefer-node-protocol": "error",
|
|
3612
3686
|
"no-cond-assign": "error",
|
|
3613
3687
|
"no-console": ["error", { allow: [
|
|
@@ -3940,8 +4014,12 @@ var typeScript_default$2 = generalTypeScript;
|
|
|
3940
4014
|
//#endregion
|
|
3941
4015
|
//#region src/configs/personal/alexCLine.ts
|
|
3942
4016
|
const personalAlexCLine = [{
|
|
3943
|
-
files: ["src
|
|
4017
|
+
files: ["src/**/*.ts"],
|
|
3944
4018
|
name: "@alextheman/personal/alex-c-line",
|
|
4019
|
+
plugins: { n: nodePlugin },
|
|
4020
|
+
rules: { "n/hashbang": "off" }
|
|
4021
|
+
}, {
|
|
4022
|
+
files: ["src/commands/index.ts"],
|
|
3945
4023
|
plugins: { perfectionist },
|
|
3946
4024
|
rules: { "perfectionist/sort-objects": ["error", sortObjects_default] }
|
|
3947
4025
|
}];
|
|
@@ -3968,7 +4046,8 @@ const personalTypeScriptPackage = [jsdoc.configs["flat/recommended-typescript-er
|
|
|
3968
4046
|
{ tags: ["template"] },
|
|
3969
4047
|
{ tags: ["param"] },
|
|
3970
4048
|
{ tags: ["throws"] },
|
|
3971
|
-
{ tags: ["returns"] }
|
|
4049
|
+
{ tags: ["returns"] },
|
|
4050
|
+
{ tags: ["example"] }
|
|
3972
4051
|
] }],
|
|
3973
4052
|
"jsdoc/tag-lines": [
|
|
3974
4053
|
"error",
|
|
@@ -4187,61 +4266,36 @@ function combinedTypeScriptReact(plugin) {
|
|
|
4187
4266
|
}
|
|
4188
4267
|
var typeScriptReact_default = combinedTypeScriptReact;
|
|
4189
4268
|
|
|
4190
|
-
//#endregion
|
|
4191
|
-
//#region src/utility/private/camelToKebab.ts
|
|
4192
|
-
function camelToKebab$1(string) {
|
|
4193
|
-
return camelToKebab(string.replace(/[Tt]ypeScript/, "typescript").replace(/[Jj]avaScript/, "javascript"));
|
|
4194
|
-
}
|
|
4195
|
-
var camelToKebab_default = camelToKebab$1;
|
|
4196
|
-
|
|
4197
|
-
//#endregion
|
|
4198
|
-
//#region src/utility/private/createConfigGroup.ts
|
|
4199
|
-
function createConfigGroup(group, configs) {
|
|
4200
|
-
const newConfigs = {};
|
|
4201
|
-
for (const key in configs) newConfigs[`${camelToKebab_default(group)}/${camelToKebab_default(key)}`] = configs[key];
|
|
4202
|
-
return newConfigs;
|
|
4203
|
-
}
|
|
4204
|
-
var createConfigGroup_default = createConfigGroup;
|
|
4205
|
-
|
|
4206
|
-
//#endregion
|
|
4207
|
-
//#region src/utility/private/createPluginConfigs.ts
|
|
4208
|
-
function createPluginConfigs(config) {
|
|
4209
|
-
const allConfigs = {};
|
|
4210
|
-
for (const configGroupEntries of Object.entries(config)) Object.assign(allConfigs, createConfigGroup_default(...configGroupEntries));
|
|
4211
|
-
return allConfigs;
|
|
4212
|
-
}
|
|
4213
|
-
var createPluginConfigs_default = createPluginConfigs;
|
|
4214
|
-
|
|
4215
4269
|
//#endregion
|
|
4216
4270
|
//#region src/configs/index.ts
|
|
4217
4271
|
function createAlexPluginConfigs(plugin) {
|
|
4218
|
-
return
|
|
4272
|
+
return flattenConfigs_default({
|
|
4219
4273
|
combined: {
|
|
4220
|
-
|
|
4221
|
-
|
|
4274
|
+
javascript: [...javaScript_default(plugin), ...packageJson_default],
|
|
4275
|
+
javascriptReact: [...javaScriptReact_default(plugin), ...packageJson_default],
|
|
4222
4276
|
react: [...react_default, ...packageJson_default],
|
|
4223
4277
|
tests: [...tests_default(plugin), ...packageJson_default],
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4278
|
+
typescript: [...typeScript_default(plugin), ...packageJson_default],
|
|
4279
|
+
typescriptPackage: [...typeScriptPackage_default(plugin), ...packageJson_default],
|
|
4280
|
+
typescriptReact: [...typeScriptReact_default(plugin), ...packageJson_default]
|
|
4227
4281
|
},
|
|
4228
4282
|
general: {
|
|
4229
|
-
|
|
4283
|
+
javascript: javaScript_default$1,
|
|
4230
4284
|
packageJson: packageJson_default,
|
|
4231
4285
|
react: react_default$2,
|
|
4232
|
-
|
|
4286
|
+
typescript: typeScript_default$2
|
|
4233
4287
|
},
|
|
4234
4288
|
personal: {
|
|
4235
4289
|
alexCLine: alexCLine_default,
|
|
4236
4290
|
components: components_default,
|
|
4237
4291
|
eslintPlugin: eslintPlugin_default(plugin),
|
|
4238
|
-
|
|
4292
|
+
javascript: javaScriptBase_default(plugin),
|
|
4239
4293
|
neurosongsBackEnd: neurosongsBackEnd_default,
|
|
4240
4294
|
neurosongsFrontEnd: neurosongsFrontEnd_default,
|
|
4241
4295
|
react: react_default$1,
|
|
4242
4296
|
tests: tests_default$2,
|
|
4243
|
-
|
|
4244
|
-
|
|
4297
|
+
typescript: typeScript_default$1(plugin),
|
|
4298
|
+
typescriptPackage: typeScriptPackage_default$1,
|
|
4245
4299
|
utility: utility_default
|
|
4246
4300
|
},
|
|
4247
4301
|
plugin: {
|
|
@@ -4670,7 +4724,7 @@ var rules_default = {
|
|
|
4670
4724
|
//#endregion
|
|
4671
4725
|
//#region package.json
|
|
4672
4726
|
var name = "@alextheman/eslint-plugin";
|
|
4673
|
-
var version = "
|
|
4727
|
+
var version = "5.0.0";
|
|
4674
4728
|
|
|
4675
4729
|
//#endregion
|
|
4676
4730
|
//#region src/alexPlugin.ts
|
|
@@ -4691,4 +4745,4 @@ var alexPlugin_default = alexPlugin;
|
|
|
4691
4745
|
var src_default = alexPlugin_default;
|
|
4692
4746
|
|
|
4693
4747
|
//#endregion
|
|
4694
|
-
export { checkCallExpression_default as checkCallExpression, combineRestrictedImports_default as combineRestrictedImports, createRuleSchemaFromZodSchema_default as createRuleSchemaFromZodSchema, src_default as default, fixOnCondition_default as fixOnCondition, getImportSpecifiersAfterRemoving_default as getImportSpecifiersAfterRemoving, parseConsistentTestFunctionOptions, parseNoNamespaceImportsOptions, parseNoRelativeImportsOptions, parseStandardiseErrorMessagesOptions, parseTestFunction, parseUseNormalizedImportsOptions, prettierRules_default as prettierRules, reactLanguageOptions_default as reactLanguageOptions, sortExports_default as sortExports, sortImports_default as sortImports, sortObjects_default as sortObjects, typeScriptLanguageOptions_default as typeScriptLanguageOptions, unusedVarsIgnorePatterns_default as unusedVarsIgnorePatterns, vitestConfig_default as vitestConfig };
|
|
4748
|
+
export { checkCallExpression_default as checkCallExpression, combineRestrictedImports_default as combineRestrictedImports, createRuleSchemaFromZodSchema_default as createRuleSchemaFromZodSchema, src_default as default, fixOnCondition_default as fixOnCondition, flattenConfigs_default as flattenConfigs, getImportSpecifiersAfterRemoving_default as getImportSpecifiersAfterRemoving, parseConsistentTestFunctionOptions, parseNoNamespaceImportsOptions, parseNoRelativeImportsOptions, parseStandardiseErrorMessagesOptions, parseTestFunction, parseUseNormalizedImportsOptions, prettierRules_default as prettierRules, reactLanguageOptions_default as reactLanguageOptions, sortExports_default as sortExports, sortImports_default as sortImports, sortObjects_default as sortObjects, typeScriptLanguageOptions_default as typeScriptLanguageOptions, unusedVarsIgnorePatterns_default as unusedVarsIgnorePatterns, vitestConfig_default as vitestConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/eslint-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "A package to provide custom ESLint rules and configs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@alextheman/utility": "^4.
|
|
18
|
+
"@alextheman/utility": "^4.1.0",
|
|
19
19
|
"@typescript-eslint/utils": "^8.50.0",
|
|
20
20
|
"common-tags": "^1.8.2",
|
|
21
21
|
"zod": "^4.2.1"
|