@alextheman/eslint-plugin 4.9.2 → 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 +101 -40
- package/dist/index.d.cts +51 -10
- package/dist/index.d.ts +51 -10
- package/dist/index.js +101 -42
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,8 @@ let eslint_config_prettier = require("eslint-config-prettier");
|
|
|
37
37
|
eslint_config_prettier = __toESM(eslint_config_prettier);
|
|
38
38
|
let eslint_plugin_import = require("eslint-plugin-import");
|
|
39
39
|
eslint_plugin_import = __toESM(eslint_plugin_import);
|
|
40
|
+
let eslint_plugin_n = require("eslint-plugin-n");
|
|
41
|
+
eslint_plugin_n = __toESM(eslint_plugin_n);
|
|
40
42
|
let eslint_plugin_perfectionist = require("eslint-plugin-perfectionist");
|
|
41
43
|
eslint_plugin_perfectionist = __toESM(eslint_plugin_perfectionist);
|
|
42
44
|
let eslint_plugin_prettier = require("eslint-plugin-prettier");
|
|
@@ -3477,6 +3479,67 @@ function createRuleSchemaFromZodSchema(schema$1) {
|
|
|
3477
3479
|
}
|
|
3478
3480
|
var createRuleSchemaFromZodSchema_default = createRuleSchemaFromZodSchema;
|
|
3479
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
|
+
|
|
3480
3543
|
//#endregion
|
|
3481
3544
|
//#region src/utility/public/getImportSpecifiersAfterRemoving.ts
|
|
3482
3545
|
/**
|
|
@@ -3605,6 +3668,7 @@ var unusedVarsIgnorePatterns_default = unusedVarsIgnorePatterns;
|
|
|
3605
3668
|
const generalJavaScript = [
|
|
3606
3669
|
_eslint_js.default.configs.recommended,
|
|
3607
3670
|
eslint_config_prettier.default,
|
|
3671
|
+
eslint_plugin_n.default.configs["flat/recommended"],
|
|
3608
3672
|
{
|
|
3609
3673
|
files: [
|
|
3610
3674
|
"**/*.js",
|
|
@@ -3615,10 +3679,26 @@ const generalJavaScript = [
|
|
|
3615
3679
|
ignores: ["dist"],
|
|
3616
3680
|
languageOptions: javaScriptLanguageOptions_default,
|
|
3617
3681
|
name: "@alextheman/general/javascript",
|
|
3618
|
-
plugins: {
|
|
3682
|
+
plugins: {
|
|
3683
|
+
import: eslint_plugin_import.default,
|
|
3684
|
+
n: eslint_plugin_n.default
|
|
3685
|
+
},
|
|
3619
3686
|
rules: {
|
|
3620
3687
|
eqeqeq: "error",
|
|
3621
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",
|
|
3701
|
+
"n/prefer-node-protocol": "error",
|
|
3622
3702
|
"no-cond-assign": "error",
|
|
3623
3703
|
"no-console": ["error", { allow: [
|
|
3624
3704
|
"warn",
|
|
@@ -3950,8 +4030,12 @@ var typeScript_default$2 = generalTypeScript;
|
|
|
3950
4030
|
//#endregion
|
|
3951
4031
|
//#region src/configs/personal/alexCLine.ts
|
|
3952
4032
|
const personalAlexCLine = [{
|
|
3953
|
-
files: ["src
|
|
4033
|
+
files: ["src/**/*.ts"],
|
|
3954
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"],
|
|
3955
4039
|
plugins: { perfectionist: eslint_plugin_perfectionist.default },
|
|
3956
4040
|
rules: { "perfectionist/sort-objects": ["error", sortObjects_default] }
|
|
3957
4041
|
}];
|
|
@@ -3978,7 +4062,8 @@ const personalTypeScriptPackage = [eslint_plugin_jsdoc.default.configs["flat/rec
|
|
|
3978
4062
|
{ tags: ["template"] },
|
|
3979
4063
|
{ tags: ["param"] },
|
|
3980
4064
|
{ tags: ["throws"] },
|
|
3981
|
-
{ tags: ["returns"] }
|
|
4065
|
+
{ tags: ["returns"] },
|
|
4066
|
+
{ tags: ["example"] }
|
|
3982
4067
|
] }],
|
|
3983
4068
|
"jsdoc/tag-lines": [
|
|
3984
4069
|
"error",
|
|
@@ -4197,61 +4282,36 @@ function combinedTypeScriptReact(plugin) {
|
|
|
4197
4282
|
}
|
|
4198
4283
|
var typeScriptReact_default = combinedTypeScriptReact;
|
|
4199
4284
|
|
|
4200
|
-
//#endregion
|
|
4201
|
-
//#region src/utility/private/camelToKebab.ts
|
|
4202
|
-
function camelToKebab(string) {
|
|
4203
|
-
return (0, _alextheman_utility.camelToKebab)(string.replace(/[Tt]ypeScript/, "typescript").replace(/[Jj]avaScript/, "javascript"));
|
|
4204
|
-
}
|
|
4205
|
-
var camelToKebab_default = camelToKebab;
|
|
4206
|
-
|
|
4207
|
-
//#endregion
|
|
4208
|
-
//#region src/utility/private/createConfigGroup.ts
|
|
4209
|
-
function createConfigGroup(group, configs) {
|
|
4210
|
-
const newConfigs = {};
|
|
4211
|
-
for (const key in configs) newConfigs[`${camelToKebab_default(group)}/${camelToKebab_default(key)}`] = configs[key];
|
|
4212
|
-
return newConfigs;
|
|
4213
|
-
}
|
|
4214
|
-
var createConfigGroup_default = createConfigGroup;
|
|
4215
|
-
|
|
4216
|
-
//#endregion
|
|
4217
|
-
//#region src/utility/private/createPluginConfigs.ts
|
|
4218
|
-
function createPluginConfigs(config) {
|
|
4219
|
-
const allConfigs = {};
|
|
4220
|
-
for (const configGroupEntries of Object.entries(config)) Object.assign(allConfigs, createConfigGroup_default(...configGroupEntries));
|
|
4221
|
-
return allConfigs;
|
|
4222
|
-
}
|
|
4223
|
-
var createPluginConfigs_default = createPluginConfigs;
|
|
4224
|
-
|
|
4225
4285
|
//#endregion
|
|
4226
4286
|
//#region src/configs/index.ts
|
|
4227
4287
|
function createAlexPluginConfigs(plugin) {
|
|
4228
|
-
return
|
|
4288
|
+
return flattenConfigs_default({
|
|
4229
4289
|
combined: {
|
|
4230
|
-
|
|
4231
|
-
|
|
4290
|
+
javascript: [...javaScript_default(plugin), ...packageJson_default],
|
|
4291
|
+
javascriptReact: [...javaScriptReact_default(plugin), ...packageJson_default],
|
|
4232
4292
|
react: [...react_default, ...packageJson_default],
|
|
4233
4293
|
tests: [...tests_default(plugin), ...packageJson_default],
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4294
|
+
typescript: [...typeScript_default(plugin), ...packageJson_default],
|
|
4295
|
+
typescriptPackage: [...typeScriptPackage_default(plugin), ...packageJson_default],
|
|
4296
|
+
typescriptReact: [...typeScriptReact_default(plugin), ...packageJson_default]
|
|
4237
4297
|
},
|
|
4238
4298
|
general: {
|
|
4239
|
-
|
|
4299
|
+
javascript: javaScript_default$1,
|
|
4240
4300
|
packageJson: packageJson_default,
|
|
4241
4301
|
react: react_default$2,
|
|
4242
|
-
|
|
4302
|
+
typescript: typeScript_default$2
|
|
4243
4303
|
},
|
|
4244
4304
|
personal: {
|
|
4245
4305
|
alexCLine: alexCLine_default,
|
|
4246
4306
|
components: components_default,
|
|
4247
4307
|
eslintPlugin: eslintPlugin_default(plugin),
|
|
4248
|
-
|
|
4308
|
+
javascript: javaScriptBase_default(plugin),
|
|
4249
4309
|
neurosongsBackEnd: neurosongsBackEnd_default,
|
|
4250
4310
|
neurosongsFrontEnd: neurosongsFrontEnd_default,
|
|
4251
4311
|
react: react_default$1,
|
|
4252
4312
|
tests: tests_default$2,
|
|
4253
|
-
|
|
4254
|
-
|
|
4313
|
+
typescript: typeScript_default$1(plugin),
|
|
4314
|
+
typescriptPackage: typeScriptPackage_default$1,
|
|
4255
4315
|
utility: utility_default
|
|
4256
4316
|
},
|
|
4257
4317
|
plugin: {
|
|
@@ -4680,7 +4740,7 @@ var rules_default = {
|
|
|
4680
4740
|
//#endregion
|
|
4681
4741
|
//#region package.json
|
|
4682
4742
|
var name = "@alextheman/eslint-plugin";
|
|
4683
|
-
var version = "
|
|
4743
|
+
var version = "5.0.0";
|
|
4684
4744
|
|
|
4685
4745
|
//#endregion
|
|
4686
4746
|
//#region src/alexPlugin.ts
|
|
@@ -4706,6 +4766,7 @@ exports.combineRestrictedImports = combineRestrictedImports_default;
|
|
|
4706
4766
|
exports.createRuleSchemaFromZodSchema = createRuleSchemaFromZodSchema_default;
|
|
4707
4767
|
exports.default = src_default;
|
|
4708
4768
|
exports.fixOnCondition = fixOnCondition_default;
|
|
4769
|
+
exports.flattenConfigs = flattenConfigs_default;
|
|
4709
4770
|
exports.getImportSpecifiersAfterRemoving = getImportSpecifiersAfterRemoving_default;
|
|
4710
4771
|
exports.parseConsistentTestFunctionOptions = parseConsistentTestFunctionOptions;
|
|
4711
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,9 +1,10 @@
|
|
|
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";
|
|
5
5
|
import prettierConfig from "eslint-config-prettier";
|
|
6
6
|
import importPlugin from "eslint-plugin-import";
|
|
7
|
+
import nodePlugin from "eslint-plugin-n";
|
|
7
8
|
import perfectionist from "eslint-plugin-perfectionist";
|
|
8
9
|
import prettierPlugin from "eslint-plugin-prettier";
|
|
9
10
|
import tseslint from "typescript-eslint";
|
|
@@ -3462,6 +3463,67 @@ function createRuleSchemaFromZodSchema(schema$1) {
|
|
|
3462
3463
|
}
|
|
3463
3464
|
var createRuleSchemaFromZodSchema_default = createRuleSchemaFromZodSchema;
|
|
3464
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
|
+
|
|
3465
3527
|
//#endregion
|
|
3466
3528
|
//#region src/utility/public/getImportSpecifiersAfterRemoving.ts
|
|
3467
3529
|
/**
|
|
@@ -3590,6 +3652,7 @@ var unusedVarsIgnorePatterns_default = unusedVarsIgnorePatterns;
|
|
|
3590
3652
|
const generalJavaScript = [
|
|
3591
3653
|
js.configs.recommended,
|
|
3592
3654
|
prettierConfig,
|
|
3655
|
+
nodePlugin.configs["flat/recommended"],
|
|
3593
3656
|
{
|
|
3594
3657
|
files: [
|
|
3595
3658
|
"**/*.js",
|
|
@@ -3600,10 +3663,26 @@ const generalJavaScript = [
|
|
|
3600
3663
|
ignores: ["dist"],
|
|
3601
3664
|
languageOptions: javaScriptLanguageOptions_default,
|
|
3602
3665
|
name: "@alextheman/general/javascript",
|
|
3603
|
-
plugins: {
|
|
3666
|
+
plugins: {
|
|
3667
|
+
import: importPlugin,
|
|
3668
|
+
n: nodePlugin
|
|
3669
|
+
},
|
|
3604
3670
|
rules: {
|
|
3605
3671
|
eqeqeq: "error",
|
|
3606
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",
|
|
3685
|
+
"n/prefer-node-protocol": "error",
|
|
3607
3686
|
"no-cond-assign": "error",
|
|
3608
3687
|
"no-console": ["error", { allow: [
|
|
3609
3688
|
"warn",
|
|
@@ -3935,8 +4014,12 @@ var typeScript_default$2 = generalTypeScript;
|
|
|
3935
4014
|
//#endregion
|
|
3936
4015
|
//#region src/configs/personal/alexCLine.ts
|
|
3937
4016
|
const personalAlexCLine = [{
|
|
3938
|
-
files: ["src
|
|
4017
|
+
files: ["src/**/*.ts"],
|
|
3939
4018
|
name: "@alextheman/personal/alex-c-line",
|
|
4019
|
+
plugins: { n: nodePlugin },
|
|
4020
|
+
rules: { "n/hashbang": "off" }
|
|
4021
|
+
}, {
|
|
4022
|
+
files: ["src/commands/index.ts"],
|
|
3940
4023
|
plugins: { perfectionist },
|
|
3941
4024
|
rules: { "perfectionist/sort-objects": ["error", sortObjects_default] }
|
|
3942
4025
|
}];
|
|
@@ -3963,7 +4046,8 @@ const personalTypeScriptPackage = [jsdoc.configs["flat/recommended-typescript-er
|
|
|
3963
4046
|
{ tags: ["template"] },
|
|
3964
4047
|
{ tags: ["param"] },
|
|
3965
4048
|
{ tags: ["throws"] },
|
|
3966
|
-
{ tags: ["returns"] }
|
|
4049
|
+
{ tags: ["returns"] },
|
|
4050
|
+
{ tags: ["example"] }
|
|
3967
4051
|
] }],
|
|
3968
4052
|
"jsdoc/tag-lines": [
|
|
3969
4053
|
"error",
|
|
@@ -4182,61 +4266,36 @@ function combinedTypeScriptReact(plugin) {
|
|
|
4182
4266
|
}
|
|
4183
4267
|
var typeScriptReact_default = combinedTypeScriptReact;
|
|
4184
4268
|
|
|
4185
|
-
//#endregion
|
|
4186
|
-
//#region src/utility/private/camelToKebab.ts
|
|
4187
|
-
function camelToKebab$1(string) {
|
|
4188
|
-
return camelToKebab(string.replace(/[Tt]ypeScript/, "typescript").replace(/[Jj]avaScript/, "javascript"));
|
|
4189
|
-
}
|
|
4190
|
-
var camelToKebab_default = camelToKebab$1;
|
|
4191
|
-
|
|
4192
|
-
//#endregion
|
|
4193
|
-
//#region src/utility/private/createConfigGroup.ts
|
|
4194
|
-
function createConfigGroup(group, configs) {
|
|
4195
|
-
const newConfigs = {};
|
|
4196
|
-
for (const key in configs) newConfigs[`${camelToKebab_default(group)}/${camelToKebab_default(key)}`] = configs[key];
|
|
4197
|
-
return newConfigs;
|
|
4198
|
-
}
|
|
4199
|
-
var createConfigGroup_default = createConfigGroup;
|
|
4200
|
-
|
|
4201
|
-
//#endregion
|
|
4202
|
-
//#region src/utility/private/createPluginConfigs.ts
|
|
4203
|
-
function createPluginConfigs(config) {
|
|
4204
|
-
const allConfigs = {};
|
|
4205
|
-
for (const configGroupEntries of Object.entries(config)) Object.assign(allConfigs, createConfigGroup_default(...configGroupEntries));
|
|
4206
|
-
return allConfigs;
|
|
4207
|
-
}
|
|
4208
|
-
var createPluginConfigs_default = createPluginConfigs;
|
|
4209
|
-
|
|
4210
4269
|
//#endregion
|
|
4211
4270
|
//#region src/configs/index.ts
|
|
4212
4271
|
function createAlexPluginConfigs(plugin) {
|
|
4213
|
-
return
|
|
4272
|
+
return flattenConfigs_default({
|
|
4214
4273
|
combined: {
|
|
4215
|
-
|
|
4216
|
-
|
|
4274
|
+
javascript: [...javaScript_default(plugin), ...packageJson_default],
|
|
4275
|
+
javascriptReact: [...javaScriptReact_default(plugin), ...packageJson_default],
|
|
4217
4276
|
react: [...react_default, ...packageJson_default],
|
|
4218
4277
|
tests: [...tests_default(plugin), ...packageJson_default],
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4278
|
+
typescript: [...typeScript_default(plugin), ...packageJson_default],
|
|
4279
|
+
typescriptPackage: [...typeScriptPackage_default(plugin), ...packageJson_default],
|
|
4280
|
+
typescriptReact: [...typeScriptReact_default(plugin), ...packageJson_default]
|
|
4222
4281
|
},
|
|
4223
4282
|
general: {
|
|
4224
|
-
|
|
4283
|
+
javascript: javaScript_default$1,
|
|
4225
4284
|
packageJson: packageJson_default,
|
|
4226
4285
|
react: react_default$2,
|
|
4227
|
-
|
|
4286
|
+
typescript: typeScript_default$2
|
|
4228
4287
|
},
|
|
4229
4288
|
personal: {
|
|
4230
4289
|
alexCLine: alexCLine_default,
|
|
4231
4290
|
components: components_default,
|
|
4232
4291
|
eslintPlugin: eslintPlugin_default(plugin),
|
|
4233
|
-
|
|
4292
|
+
javascript: javaScriptBase_default(plugin),
|
|
4234
4293
|
neurosongsBackEnd: neurosongsBackEnd_default,
|
|
4235
4294
|
neurosongsFrontEnd: neurosongsFrontEnd_default,
|
|
4236
4295
|
react: react_default$1,
|
|
4237
4296
|
tests: tests_default$2,
|
|
4238
|
-
|
|
4239
|
-
|
|
4297
|
+
typescript: typeScript_default$1(plugin),
|
|
4298
|
+
typescriptPackage: typeScriptPackage_default$1,
|
|
4240
4299
|
utility: utility_default
|
|
4241
4300
|
},
|
|
4242
4301
|
plugin: {
|
|
@@ -4665,7 +4724,7 @@ var rules_default = {
|
|
|
4665
4724
|
//#endregion
|
|
4666
4725
|
//#region package.json
|
|
4667
4726
|
var name = "@alextheman/eslint-plugin";
|
|
4668
|
-
var version = "
|
|
4727
|
+
var version = "5.0.0";
|
|
4669
4728
|
|
|
4670
4729
|
//#endregion
|
|
4671
4730
|
//#region src/alexPlugin.ts
|
|
@@ -4686,4 +4745,4 @@ var alexPlugin_default = alexPlugin;
|
|
|
4686
4745
|
var src_default = alexPlugin_default;
|
|
4687
4746
|
|
|
4688
4747
|
//#endregion
|
|
4689
|
-
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"
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"eslint-plugin-import": "^2.32.0",
|
|
37
37
|
"eslint-plugin-jsdoc": "^61.5.0",
|
|
38
38
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
39
|
+
"eslint-plugin-n": "^17.23.1",
|
|
39
40
|
"eslint-plugin-package-json": "^0.85.0",
|
|
40
41
|
"eslint-plugin-perfectionist": "^5.0.0",
|
|
41
42
|
"eslint-plugin-prettier": "^5.5.4",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"eslint-plugin-import": ">=2.0.0",
|
|
63
64
|
"eslint-plugin-jsdoc": ">=61.5.0",
|
|
64
65
|
"eslint-plugin-jsx-a11y": ">=6.0.0",
|
|
66
|
+
"eslint-plugin-n": ">=17.23.1",
|
|
65
67
|
"eslint-plugin-package-json": ">=0.85.0",
|
|
66
68
|
"eslint-plugin-perfectionist": ">=4.0.0",
|
|
67
69
|
"eslint-plugin-prettier": ">=5.0.0",
|