@alextheman/eslint-plugin 4.10.0 → 5.0.1
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 +95 -39
- package/dist/index.d.cts +51 -10
- package/dist/index.d.ts +51 -10
- package/dist/index.js +96 -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
|
}];
|
|
@@ -3981,10 +4059,12 @@ const personalTypeScriptPackage = [eslint_plugin_jsdoc.default.configs["flat/rec
|
|
|
3981
4059
|
"jsdoc/check-tag-names": ["error", { definedTags: ["note"] }],
|
|
3982
4060
|
"jsdoc/require-jsdoc": ["warn", requireJsdocOptions_default],
|
|
3983
4061
|
"jsdoc/sort-tags": ["error", { tagSequence: [
|
|
4062
|
+
{ tags: ["deprecated"] },
|
|
3984
4063
|
{ tags: ["template"] },
|
|
3985
4064
|
{ tags: ["param"] },
|
|
3986
4065
|
{ tags: ["throws"] },
|
|
3987
|
-
{ tags: ["returns"] }
|
|
4066
|
+
{ tags: ["returns"] },
|
|
4067
|
+
{ tags: ["example"] }
|
|
3988
4068
|
] }],
|
|
3989
4069
|
"jsdoc/tag-lines": [
|
|
3990
4070
|
"error",
|
|
@@ -4203,61 +4283,36 @@ function combinedTypeScriptReact(plugin) {
|
|
|
4203
4283
|
}
|
|
4204
4284
|
var typeScriptReact_default = combinedTypeScriptReact;
|
|
4205
4285
|
|
|
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
4286
|
//#endregion
|
|
4232
4287
|
//#region src/configs/index.ts
|
|
4233
4288
|
function createAlexPluginConfigs(plugin) {
|
|
4234
|
-
return
|
|
4289
|
+
return flattenConfigs_default({
|
|
4235
4290
|
combined: {
|
|
4236
|
-
|
|
4237
|
-
|
|
4291
|
+
javascript: [...javaScript_default(plugin), ...packageJson_default],
|
|
4292
|
+
javascriptReact: [...javaScriptReact_default(plugin), ...packageJson_default],
|
|
4238
4293
|
react: [...react_default, ...packageJson_default],
|
|
4239
4294
|
tests: [...tests_default(plugin), ...packageJson_default],
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4295
|
+
typescript: [...typeScript_default(plugin), ...packageJson_default],
|
|
4296
|
+
typescriptPackage: [...typeScriptPackage_default(plugin), ...packageJson_default],
|
|
4297
|
+
typescriptReact: [...typeScriptReact_default(plugin), ...packageJson_default]
|
|
4243
4298
|
},
|
|
4244
4299
|
general: {
|
|
4245
|
-
|
|
4300
|
+
javascript: javaScript_default$1,
|
|
4246
4301
|
packageJson: packageJson_default,
|
|
4247
4302
|
react: react_default$2,
|
|
4248
|
-
|
|
4303
|
+
typescript: typeScript_default$2
|
|
4249
4304
|
},
|
|
4250
4305
|
personal: {
|
|
4251
4306
|
alexCLine: alexCLine_default,
|
|
4252
4307
|
components: components_default,
|
|
4253
4308
|
eslintPlugin: eslintPlugin_default(plugin),
|
|
4254
|
-
|
|
4309
|
+
javascript: javaScriptBase_default(plugin),
|
|
4255
4310
|
neurosongsBackEnd: neurosongsBackEnd_default,
|
|
4256
4311
|
neurosongsFrontEnd: neurosongsFrontEnd_default,
|
|
4257
4312
|
react: react_default$1,
|
|
4258
4313
|
tests: tests_default$2,
|
|
4259
|
-
|
|
4260
|
-
|
|
4314
|
+
typescript: typeScript_default$1(plugin),
|
|
4315
|
+
typescriptPackage: typeScriptPackage_default$1,
|
|
4261
4316
|
utility: utility_default
|
|
4262
4317
|
},
|
|
4263
4318
|
plugin: {
|
|
@@ -4686,7 +4741,7 @@ var rules_default = {
|
|
|
4686
4741
|
//#endregion
|
|
4687
4742
|
//#region package.json
|
|
4688
4743
|
var name = "@alextheman/eslint-plugin";
|
|
4689
|
-
var version = "
|
|
4744
|
+
var version = "5.0.1";
|
|
4690
4745
|
|
|
4691
4746
|
//#endregion
|
|
4692
4747
|
//#region src/alexPlugin.ts
|
|
@@ -4712,6 +4767,7 @@ exports.combineRestrictedImports = combineRestrictedImports_default;
|
|
|
4712
4767
|
exports.createRuleSchemaFromZodSchema = createRuleSchemaFromZodSchema_default;
|
|
4713
4768
|
exports.default = src_default;
|
|
4714
4769
|
exports.fixOnCondition = fixOnCondition_default;
|
|
4770
|
+
exports.flattenConfigs = flattenConfigs_default;
|
|
4715
4771
|
exports.getImportSpecifiersAfterRemoving = getImportSpecifiersAfterRemoving_default;
|
|
4716
4772
|
exports.parseConsistentTestFunctionOptions = parseConsistentTestFunctionOptions;
|
|
4717
4773
|
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
|
}];
|
|
@@ -3965,10 +4043,12 @@ const personalTypeScriptPackage = [jsdoc.configs["flat/recommended-typescript-er
|
|
|
3965
4043
|
"jsdoc/check-tag-names": ["error", { definedTags: ["note"] }],
|
|
3966
4044
|
"jsdoc/require-jsdoc": ["warn", requireJsdocOptions_default],
|
|
3967
4045
|
"jsdoc/sort-tags": ["error", { tagSequence: [
|
|
4046
|
+
{ tags: ["deprecated"] },
|
|
3968
4047
|
{ tags: ["template"] },
|
|
3969
4048
|
{ tags: ["param"] },
|
|
3970
4049
|
{ tags: ["throws"] },
|
|
3971
|
-
{ tags: ["returns"] }
|
|
4050
|
+
{ tags: ["returns"] },
|
|
4051
|
+
{ tags: ["example"] }
|
|
3972
4052
|
] }],
|
|
3973
4053
|
"jsdoc/tag-lines": [
|
|
3974
4054
|
"error",
|
|
@@ -4187,61 +4267,36 @@ function combinedTypeScriptReact(plugin) {
|
|
|
4187
4267
|
}
|
|
4188
4268
|
var typeScriptReact_default = combinedTypeScriptReact;
|
|
4189
4269
|
|
|
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
4270
|
//#endregion
|
|
4216
4271
|
//#region src/configs/index.ts
|
|
4217
4272
|
function createAlexPluginConfigs(plugin) {
|
|
4218
|
-
return
|
|
4273
|
+
return flattenConfigs_default({
|
|
4219
4274
|
combined: {
|
|
4220
|
-
|
|
4221
|
-
|
|
4275
|
+
javascript: [...javaScript_default(plugin), ...packageJson_default],
|
|
4276
|
+
javascriptReact: [...javaScriptReact_default(plugin), ...packageJson_default],
|
|
4222
4277
|
react: [...react_default, ...packageJson_default],
|
|
4223
4278
|
tests: [...tests_default(plugin), ...packageJson_default],
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4279
|
+
typescript: [...typeScript_default(plugin), ...packageJson_default],
|
|
4280
|
+
typescriptPackage: [...typeScriptPackage_default(plugin), ...packageJson_default],
|
|
4281
|
+
typescriptReact: [...typeScriptReact_default(plugin), ...packageJson_default]
|
|
4227
4282
|
},
|
|
4228
4283
|
general: {
|
|
4229
|
-
|
|
4284
|
+
javascript: javaScript_default$1,
|
|
4230
4285
|
packageJson: packageJson_default,
|
|
4231
4286
|
react: react_default$2,
|
|
4232
|
-
|
|
4287
|
+
typescript: typeScript_default$2
|
|
4233
4288
|
},
|
|
4234
4289
|
personal: {
|
|
4235
4290
|
alexCLine: alexCLine_default,
|
|
4236
4291
|
components: components_default,
|
|
4237
4292
|
eslintPlugin: eslintPlugin_default(plugin),
|
|
4238
|
-
|
|
4293
|
+
javascript: javaScriptBase_default(plugin),
|
|
4239
4294
|
neurosongsBackEnd: neurosongsBackEnd_default,
|
|
4240
4295
|
neurosongsFrontEnd: neurosongsFrontEnd_default,
|
|
4241
4296
|
react: react_default$1,
|
|
4242
4297
|
tests: tests_default$2,
|
|
4243
|
-
|
|
4244
|
-
|
|
4298
|
+
typescript: typeScript_default$1(plugin),
|
|
4299
|
+
typescriptPackage: typeScriptPackage_default$1,
|
|
4245
4300
|
utility: utility_default
|
|
4246
4301
|
},
|
|
4247
4302
|
plugin: {
|
|
@@ -4670,7 +4725,7 @@ var rules_default = {
|
|
|
4670
4725
|
//#endregion
|
|
4671
4726
|
//#region package.json
|
|
4672
4727
|
var name = "@alextheman/eslint-plugin";
|
|
4673
|
-
var version = "
|
|
4728
|
+
var version = "5.0.1";
|
|
4674
4729
|
|
|
4675
4730
|
//#endregion
|
|
4676
4731
|
//#region src/alexPlugin.ts
|
|
@@ -4691,4 +4746,4 @@ var alexPlugin_default = alexPlugin;
|
|
|
4691
4746
|
var src_default = alexPlugin_default;
|
|
4692
4747
|
|
|
4693
4748
|
//#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 };
|
|
4749
|
+
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.1",
|
|
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"
|