@alextheman/eslint-plugin 3.0.2 → 3.1.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 +49 -25
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +49 -25
- package/package.json +2 -3
package/dist/index.cjs
CHANGED
|
@@ -3765,7 +3765,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
3765
3765
|
|
|
3766
3766
|
// package.json
|
|
3767
3767
|
var name = "@alextheman/eslint-plugin";
|
|
3768
|
-
var version = "3.0
|
|
3768
|
+
var version = "3.1.0";
|
|
3769
3769
|
|
|
3770
3770
|
// src/configs/index.ts
|
|
3771
3771
|
var import_eslint_plugin_package_json = __toESM(require("eslint-plugin-package-json"), 1);
|
|
@@ -4497,8 +4497,8 @@ var createRule_default = createRule;
|
|
|
4497
4497
|
// src/utility/createRuleSchema.ts
|
|
4498
4498
|
var import_utility4 = require("@alextheman/utility");
|
|
4499
4499
|
var import_zod = __toESM(require("zod"), 1);
|
|
4500
|
-
function createRuleSchema(
|
|
4501
|
-
return [(0, import_utility4.omitProperties)(import_zod.default.toJSONSchema(
|
|
4500
|
+
function createRuleSchema(schema5) {
|
|
4501
|
+
return [(0, import_utility4.omitProperties)(import_zod.default.toJSONSchema(schema5), "$schema")];
|
|
4502
4502
|
}
|
|
4503
4503
|
var createRuleSchema_default = createRuleSchema;
|
|
4504
4504
|
|
|
@@ -4518,12 +4518,13 @@ function parseTestFunction(data) {
|
|
|
4518
4518
|
return validTestFunctionsSchema.parse(data);
|
|
4519
4519
|
}
|
|
4520
4520
|
var consistentTestFunctionOptionsSchema = import_zod2.default.object({
|
|
4521
|
-
preference: validTestFunctionsSchema
|
|
4521
|
+
preference: validTestFunctionsSchema,
|
|
4522
|
+
fixable: import_zod2.default.boolean()
|
|
4522
4523
|
}).partial();
|
|
4523
4524
|
function parseConsistentTestFunctionOptions(data) {
|
|
4524
4525
|
return consistentTestFunctionOptionsSchema.parse(data);
|
|
4525
4526
|
}
|
|
4526
|
-
var
|
|
4527
|
+
var defaultOptions = { preference: "test", fixable: true };
|
|
4527
4528
|
var consistentTestFunction = createRule_default({
|
|
4528
4529
|
name: "consistent-test-function",
|
|
4529
4530
|
meta: {
|
|
@@ -4535,14 +4536,12 @@ var consistentTestFunction = createRule_default({
|
|
|
4535
4536
|
},
|
|
4536
4537
|
type: "suggestion",
|
|
4537
4538
|
fixable: "code",
|
|
4538
|
-
schema
|
|
4539
|
+
schema: createRuleSchema_default(consistentTestFunctionOptionsSchema)
|
|
4539
4540
|
},
|
|
4540
|
-
defaultOptions: [
|
|
4541
|
+
defaultOptions: [defaultOptions],
|
|
4541
4542
|
create(context) {
|
|
4542
4543
|
var _a;
|
|
4543
|
-
const { preference } = parseConsistentTestFunctionOptions(
|
|
4544
|
-
(_a = context.options[0]) != null ? _a : { preference: "test" }
|
|
4545
|
-
);
|
|
4544
|
+
const { preference = defaultOptions.preference, fixable = defaultOptions.fixable } = parseConsistentTestFunctionOptions((_a = context.options[0]) != null ? _a : defaultOptions);
|
|
4546
4545
|
return {
|
|
4547
4546
|
CallExpression(node) {
|
|
4548
4547
|
if (node.callee.type === import_utils2.AST_NODE_TYPES.Identifier && node.callee.name === "it" && preference === "test") {
|
|
@@ -4554,6 +4553,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4554
4553
|
preference
|
|
4555
4554
|
},
|
|
4556
4555
|
fix(fixer) {
|
|
4556
|
+
if (!fixable) {
|
|
4557
|
+
return null;
|
|
4558
|
+
}
|
|
4557
4559
|
return fixer.replaceText(node.callee, "test");
|
|
4558
4560
|
}
|
|
4559
4561
|
});
|
|
@@ -4567,6 +4569,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4567
4569
|
preference
|
|
4568
4570
|
},
|
|
4569
4571
|
fix(fixer) {
|
|
4572
|
+
if (!fixable) {
|
|
4573
|
+
return null;
|
|
4574
|
+
}
|
|
4570
4575
|
return fixer.replaceText(node.callee, "it");
|
|
4571
4576
|
}
|
|
4572
4577
|
});
|
|
@@ -4583,6 +4588,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4583
4588
|
preference
|
|
4584
4589
|
},
|
|
4585
4590
|
fix(fixer) {
|
|
4591
|
+
if (!fixable) {
|
|
4592
|
+
return null;
|
|
4593
|
+
}
|
|
4586
4594
|
const importedNames = node.specifiers.map((specifier2) => {
|
|
4587
4595
|
return specifier2.type === import_utils2.AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === import_utils2.AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
4588
4596
|
});
|
|
@@ -4616,6 +4624,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4616
4624
|
preference
|
|
4617
4625
|
},
|
|
4618
4626
|
fix(fixer) {
|
|
4627
|
+
if (!fixable) {
|
|
4628
|
+
return null;
|
|
4629
|
+
}
|
|
4619
4630
|
const importedNames = node.specifiers.map((specifier2) => {
|
|
4620
4631
|
return specifier2.type === import_utils2.AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === import_utils2.AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
4621
4632
|
});
|
|
@@ -4694,7 +4705,7 @@ var noNamespaceImportsOptionsSchema = import_zod3.default.object({
|
|
|
4694
4705
|
function parseNoNamespaceImportsOptions(data) {
|
|
4695
4706
|
return noNamespaceImportsOptionsSchema.parse(data);
|
|
4696
4707
|
}
|
|
4697
|
-
var
|
|
4708
|
+
var schema = createRuleSchema_default(noNamespaceImportsOptionsSchema);
|
|
4698
4709
|
var noNamespaceImports = createRule_default({
|
|
4699
4710
|
name: "no-namespace-imports",
|
|
4700
4711
|
meta: {
|
|
@@ -4705,7 +4716,7 @@ var noNamespaceImports = createRule_default({
|
|
|
4705
4716
|
message: 'Import * from "{{source}}" is not allowed. Please use named imports instead.'
|
|
4706
4717
|
},
|
|
4707
4718
|
type: "suggestion",
|
|
4708
|
-
schema
|
|
4719
|
+
schema
|
|
4709
4720
|
},
|
|
4710
4721
|
defaultOptions: [{ allow: [""] }],
|
|
4711
4722
|
create(context) {
|
|
@@ -4775,7 +4786,7 @@ var noRelativeImportsOptionsSchema = import_zod4.default.object({
|
|
|
4775
4786
|
function parseNoRelativeImportsOptions(data) {
|
|
4776
4787
|
return noRelativeImportsOptionsSchema.parse(data);
|
|
4777
4788
|
}
|
|
4778
|
-
var
|
|
4789
|
+
var schema2 = createRuleSchema_default(noRelativeImportsOptionsSchema);
|
|
4779
4790
|
var noRelativeImports = createRule_default({
|
|
4780
4791
|
name: "no-relative-imports",
|
|
4781
4792
|
meta: {
|
|
@@ -4787,7 +4798,7 @@ var noRelativeImports = createRule_default({
|
|
|
4787
4798
|
stupidPath: "For the love of God, please do not mix relative path parts in your import statements like that! How can you possibly be ok with {{source}}?!"
|
|
4788
4799
|
},
|
|
4789
4800
|
type: "suggestion",
|
|
4790
|
-
schema:
|
|
4801
|
+
schema: schema2
|
|
4791
4802
|
},
|
|
4792
4803
|
defaultOptions: [{ depth: void 0 }],
|
|
4793
4804
|
create(context) {
|
|
@@ -4902,7 +4913,7 @@ var standardiseErrorMessagesOptionsSchema = import_zod5.default.object({
|
|
|
4902
4913
|
function parseStandardiseErrorMessagesOptions(data) {
|
|
4903
4914
|
return standardiseErrorMessagesOptionsSchema.parse(data);
|
|
4904
4915
|
}
|
|
4905
|
-
var
|
|
4916
|
+
var schema3 = createRuleSchema_default(standardiseErrorMessagesOptionsSchema);
|
|
4906
4917
|
var defaultErrorRegex = "^[A-Z]+(?:_[A-Z]+)*$";
|
|
4907
4918
|
function checkCurrentNode(context, node) {
|
|
4908
4919
|
var _a;
|
|
@@ -4934,7 +4945,7 @@ var standardiseErrorMessages = createRule_default({
|
|
|
4934
4945
|
message: "Expected error message {{error}} to match {{regex}}."
|
|
4935
4946
|
},
|
|
4936
4947
|
type: "suggestion",
|
|
4937
|
-
schema:
|
|
4948
|
+
schema: schema3
|
|
4938
4949
|
},
|
|
4939
4950
|
defaultOptions: [{ regex: defaultErrorRegex }],
|
|
4940
4951
|
create(context) {
|
|
@@ -4959,7 +4970,7 @@ var useNormalizedImportsOptionsSchema = import_zod6.default.object({
|
|
|
4959
4970
|
function parseUseNormalizedImportsOptions(data) {
|
|
4960
4971
|
return useNormalizedImportsOptionsSchema.parse(data);
|
|
4961
4972
|
}
|
|
4962
|
-
var
|
|
4973
|
+
var schema4 = createRuleSchema_default(useNormalizedImportsOptionsSchema);
|
|
4963
4974
|
var useNormalizedImports = createRule_default({
|
|
4964
4975
|
name: "use-normalized-imports",
|
|
4965
4976
|
meta: {
|
|
@@ -4970,15 +4981,13 @@ var useNormalizedImports = createRule_default({
|
|
|
4970
4981
|
pathNotNormalized: "Import path {{nonNormalized}} is not normalised. Please use {{normalized}} instead."
|
|
4971
4982
|
},
|
|
4972
4983
|
type: "suggestion",
|
|
4973
|
-
schema:
|
|
4984
|
+
schema: schema4,
|
|
4974
4985
|
fixable: "code"
|
|
4975
4986
|
},
|
|
4976
4987
|
defaultOptions: [{ fixable: true }],
|
|
4977
4988
|
create(context) {
|
|
4978
4989
|
var _a;
|
|
4979
|
-
const { fixable
|
|
4980
|
-
(_a = context.options[0]) != null ? _a : { fixable: true }
|
|
4981
|
-
);
|
|
4990
|
+
const { fixable } = parseUseNormalizedImportsOptions((_a = context.options[0]) != null ? _a : { fixable: true });
|
|
4982
4991
|
return {
|
|
4983
4992
|
ImportDeclaration(node) {
|
|
4984
4993
|
const normalizedPath = import_path.default.posix.normalize(node.source.value);
|
|
@@ -4990,10 +4999,13 @@ var useNormalizedImports = createRule_default({
|
|
|
4990
4999
|
nonNormalized: node.source.value,
|
|
4991
5000
|
normalized: normalizedPath
|
|
4992
5001
|
},
|
|
4993
|
-
fix
|
|
5002
|
+
fix(fixer) {
|
|
5003
|
+
if (!fixable) {
|
|
5004
|
+
return null;
|
|
5005
|
+
}
|
|
4994
5006
|
const [quote] = node.source.raw;
|
|
4995
5007
|
return fixer.replaceText(node.source, `${quote}${normalizedPath}${quote}`);
|
|
4996
|
-
}
|
|
5008
|
+
}
|
|
4997
5009
|
});
|
|
4998
5010
|
}
|
|
4999
5011
|
}
|
|
@@ -5004,6 +5016,13 @@ var use_normalized_imports_default = useNormalizedImports;
|
|
|
5004
5016
|
|
|
5005
5017
|
// src/rules/use-object-shorthand.ts
|
|
5006
5018
|
var import_utils5 = require("@typescript-eslint/utils");
|
|
5019
|
+
var import_zod7 = __toESM(require("zod"), 1);
|
|
5020
|
+
var useObjectShorthandOptionsSchema = import_zod7.default.object({
|
|
5021
|
+
fixable: import_zod7.default.boolean()
|
|
5022
|
+
}).partial();
|
|
5023
|
+
function parseUseObjectShorthandOptions(data) {
|
|
5024
|
+
return useObjectShorthandOptionsSchema.parse(data);
|
|
5025
|
+
}
|
|
5007
5026
|
var useObjectShorthand = createRule_default({
|
|
5008
5027
|
name: "use-object-shorthand",
|
|
5009
5028
|
meta: {
|
|
@@ -5015,10 +5034,12 @@ var useObjectShorthand = createRule_default({
|
|
|
5015
5034
|
},
|
|
5016
5035
|
type: "suggestion",
|
|
5017
5036
|
fixable: "code",
|
|
5018
|
-
schema:
|
|
5037
|
+
schema: createRuleSchema_default(useObjectShorthandOptionsSchema)
|
|
5019
5038
|
},
|
|
5020
|
-
defaultOptions: [],
|
|
5039
|
+
defaultOptions: [{ fixable: true }],
|
|
5021
5040
|
create(context) {
|
|
5041
|
+
var _a;
|
|
5042
|
+
const { fixable } = parseUseObjectShorthandOptions((_a = context.options[0]) != null ? _a : { fixable: true });
|
|
5022
5043
|
return {
|
|
5023
5044
|
Property(node) {
|
|
5024
5045
|
if (node.key.type === import_utils5.AST_NODE_TYPES.Identifier && node.value.type === import_utils5.AST_NODE_TYPES.Identifier && node.key.name === node.value.name && !node.shorthand) {
|
|
@@ -5029,6 +5050,9 @@ var useObjectShorthand = createRule_default({
|
|
|
5029
5050
|
source: context.sourceCode.getText(node)
|
|
5030
5051
|
},
|
|
5031
5052
|
fix(fixer) {
|
|
5053
|
+
if (!fixable) {
|
|
5054
|
+
return null;
|
|
5055
|
+
}
|
|
5032
5056
|
const key = node.key;
|
|
5033
5057
|
return fixer.replaceTextRange([node.range[0], node.range[1]], key.name);
|
|
5034
5058
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ import { Config } from 'prettier';
|
|
|
4
4
|
import z from 'zod';
|
|
5
5
|
|
|
6
6
|
var name = "@alextheman/eslint-plugin";
|
|
7
|
-
var version = "3.0
|
|
7
|
+
var version = "3.1.0";
|
|
8
8
|
|
|
9
9
|
type CamelToKebab<S extends string> = S extends `${IgnoreCase<"J">}avaScript${infer Rest}` ? Rest extends "" ? "javascript" : `javascript${CamelToKebab<Rest>}` : S extends `${IgnoreCase<"T">}ypeScript${infer Rest}` ? Rest extends "" ? "typescript" : `typescript${CamelToKebab<Rest>}` : S extends `${infer Head}${infer Tail}` ? Head extends Lowercase<Head> ? `${Head}${CamelToKebab<Tail>}` : `-${Lowercase<Head>}${CamelToKebab<Tail>}` : S;
|
|
10
10
|
|
|
@@ -69,6 +69,7 @@ declare const consistentTestFunctionOptionsSchema: z.ZodObject<{
|
|
|
69
69
|
test: "test";
|
|
70
70
|
it: "it";
|
|
71
71
|
}>>;
|
|
72
|
+
fixable: z.ZodOptional<z.ZodBoolean>;
|
|
72
73
|
}, z.core.$strip>;
|
|
73
74
|
type ConsistentTestFunctionOptions = z.infer<typeof consistentTestFunctionOptionsSchema>;
|
|
74
75
|
declare function parseConsistentTestFunctionOptions(data: unknown): ConsistentTestFunctionOptions;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Config } from 'prettier';
|
|
|
4
4
|
import z from 'zod';
|
|
5
5
|
|
|
6
6
|
var name = "@alextheman/eslint-plugin";
|
|
7
|
-
var version = "3.0
|
|
7
|
+
var version = "3.1.0";
|
|
8
8
|
|
|
9
9
|
type CamelToKebab<S extends string> = S extends `${IgnoreCase<"J">}avaScript${infer Rest}` ? Rest extends "" ? "javascript" : `javascript${CamelToKebab<Rest>}` : S extends `${IgnoreCase<"T">}ypeScript${infer Rest}` ? Rest extends "" ? "typescript" : `typescript${CamelToKebab<Rest>}` : S extends `${infer Head}${infer Tail}` ? Head extends Lowercase<Head> ? `${Head}${CamelToKebab<Tail>}` : `-${Lowercase<Head>}${CamelToKebab<Tail>}` : S;
|
|
10
10
|
|
|
@@ -69,6 +69,7 @@ declare const consistentTestFunctionOptionsSchema: z.ZodObject<{
|
|
|
69
69
|
test: "test";
|
|
70
70
|
it: "it";
|
|
71
71
|
}>>;
|
|
72
|
+
fixable: z.ZodOptional<z.ZodBoolean>;
|
|
72
73
|
}, z.core.$strip>;
|
|
73
74
|
type ConsistentTestFunctionOptions = z.infer<typeof consistentTestFunctionOptionsSchema>;
|
|
74
75
|
declare function parseConsistentTestFunctionOptions(data: unknown): ConsistentTestFunctionOptions;
|
package/dist/index.js
CHANGED
|
@@ -3744,7 +3744,7 @@ var require_src = __commonJS({
|
|
|
3744
3744
|
|
|
3745
3745
|
// package.json
|
|
3746
3746
|
var name = "@alextheman/eslint-plugin";
|
|
3747
|
-
var version = "3.0
|
|
3747
|
+
var version = "3.1.0";
|
|
3748
3748
|
|
|
3749
3749
|
// src/configs/index.ts
|
|
3750
3750
|
import packageJson from "eslint-plugin-package-json";
|
|
@@ -4476,8 +4476,8 @@ var createRule_default = createRule;
|
|
|
4476
4476
|
// src/utility/createRuleSchema.ts
|
|
4477
4477
|
import { omitProperties as omitProperties2 } from "@alextheman/utility";
|
|
4478
4478
|
import z from "zod";
|
|
4479
|
-
function createRuleSchema(
|
|
4480
|
-
return [omitProperties2(z.toJSONSchema(
|
|
4479
|
+
function createRuleSchema(schema5) {
|
|
4480
|
+
return [omitProperties2(z.toJSONSchema(schema5), "$schema")];
|
|
4481
4481
|
}
|
|
4482
4482
|
var createRuleSchema_default = createRuleSchema;
|
|
4483
4483
|
|
|
@@ -4497,12 +4497,13 @@ function parseTestFunction(data) {
|
|
|
4497
4497
|
return validTestFunctionsSchema.parse(data);
|
|
4498
4498
|
}
|
|
4499
4499
|
var consistentTestFunctionOptionsSchema = z2.object({
|
|
4500
|
-
preference: validTestFunctionsSchema
|
|
4500
|
+
preference: validTestFunctionsSchema,
|
|
4501
|
+
fixable: z2.boolean()
|
|
4501
4502
|
}).partial();
|
|
4502
4503
|
function parseConsistentTestFunctionOptions(data) {
|
|
4503
4504
|
return consistentTestFunctionOptionsSchema.parse(data);
|
|
4504
4505
|
}
|
|
4505
|
-
var
|
|
4506
|
+
var defaultOptions = { preference: "test", fixable: true };
|
|
4506
4507
|
var consistentTestFunction = createRule_default({
|
|
4507
4508
|
name: "consistent-test-function",
|
|
4508
4509
|
meta: {
|
|
@@ -4514,14 +4515,12 @@ var consistentTestFunction = createRule_default({
|
|
|
4514
4515
|
},
|
|
4515
4516
|
type: "suggestion",
|
|
4516
4517
|
fixable: "code",
|
|
4517
|
-
schema
|
|
4518
|
+
schema: createRuleSchema_default(consistentTestFunctionOptionsSchema)
|
|
4518
4519
|
},
|
|
4519
|
-
defaultOptions: [
|
|
4520
|
+
defaultOptions: [defaultOptions],
|
|
4520
4521
|
create(context) {
|
|
4521
4522
|
var _a;
|
|
4522
|
-
const { preference } = parseConsistentTestFunctionOptions(
|
|
4523
|
-
(_a = context.options[0]) != null ? _a : { preference: "test" }
|
|
4524
|
-
);
|
|
4523
|
+
const { preference = defaultOptions.preference, fixable = defaultOptions.fixable } = parseConsistentTestFunctionOptions((_a = context.options[0]) != null ? _a : defaultOptions);
|
|
4525
4524
|
return {
|
|
4526
4525
|
CallExpression(node) {
|
|
4527
4526
|
if (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "it" && preference === "test") {
|
|
@@ -4533,6 +4532,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4533
4532
|
preference
|
|
4534
4533
|
},
|
|
4535
4534
|
fix(fixer) {
|
|
4535
|
+
if (!fixable) {
|
|
4536
|
+
return null;
|
|
4537
|
+
}
|
|
4536
4538
|
return fixer.replaceText(node.callee, "test");
|
|
4537
4539
|
}
|
|
4538
4540
|
});
|
|
@@ -4546,6 +4548,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4546
4548
|
preference
|
|
4547
4549
|
},
|
|
4548
4550
|
fix(fixer) {
|
|
4551
|
+
if (!fixable) {
|
|
4552
|
+
return null;
|
|
4553
|
+
}
|
|
4549
4554
|
return fixer.replaceText(node.callee, "it");
|
|
4550
4555
|
}
|
|
4551
4556
|
});
|
|
@@ -4562,6 +4567,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4562
4567
|
preference
|
|
4563
4568
|
},
|
|
4564
4569
|
fix(fixer) {
|
|
4570
|
+
if (!fixable) {
|
|
4571
|
+
return null;
|
|
4572
|
+
}
|
|
4565
4573
|
const importedNames = node.specifiers.map((specifier2) => {
|
|
4566
4574
|
return specifier2.type === AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
4567
4575
|
});
|
|
@@ -4595,6 +4603,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4595
4603
|
preference
|
|
4596
4604
|
},
|
|
4597
4605
|
fix(fixer) {
|
|
4606
|
+
if (!fixable) {
|
|
4607
|
+
return null;
|
|
4608
|
+
}
|
|
4598
4609
|
const importedNames = node.specifiers.map((specifier2) => {
|
|
4599
4610
|
return specifier2.type === AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
4600
4611
|
});
|
|
@@ -4673,7 +4684,7 @@ var noNamespaceImportsOptionsSchema = z3.object({
|
|
|
4673
4684
|
function parseNoNamespaceImportsOptions(data) {
|
|
4674
4685
|
return noNamespaceImportsOptionsSchema.parse(data);
|
|
4675
4686
|
}
|
|
4676
|
-
var
|
|
4687
|
+
var schema = createRuleSchema_default(noNamespaceImportsOptionsSchema);
|
|
4677
4688
|
var noNamespaceImports = createRule_default({
|
|
4678
4689
|
name: "no-namespace-imports",
|
|
4679
4690
|
meta: {
|
|
@@ -4684,7 +4695,7 @@ var noNamespaceImports = createRule_default({
|
|
|
4684
4695
|
message: 'Import * from "{{source}}" is not allowed. Please use named imports instead.'
|
|
4685
4696
|
},
|
|
4686
4697
|
type: "suggestion",
|
|
4687
|
-
schema
|
|
4698
|
+
schema
|
|
4688
4699
|
},
|
|
4689
4700
|
defaultOptions: [{ allow: [""] }],
|
|
4690
4701
|
create(context) {
|
|
@@ -4754,7 +4765,7 @@ var noRelativeImportsOptionsSchema = z4.object({
|
|
|
4754
4765
|
function parseNoRelativeImportsOptions(data) {
|
|
4755
4766
|
return noRelativeImportsOptionsSchema.parse(data);
|
|
4756
4767
|
}
|
|
4757
|
-
var
|
|
4768
|
+
var schema2 = createRuleSchema_default(noRelativeImportsOptionsSchema);
|
|
4758
4769
|
var noRelativeImports = createRule_default({
|
|
4759
4770
|
name: "no-relative-imports",
|
|
4760
4771
|
meta: {
|
|
@@ -4766,7 +4777,7 @@ var noRelativeImports = createRule_default({
|
|
|
4766
4777
|
stupidPath: "For the love of God, please do not mix relative path parts in your import statements like that! How can you possibly be ok with {{source}}?!"
|
|
4767
4778
|
},
|
|
4768
4779
|
type: "suggestion",
|
|
4769
|
-
schema:
|
|
4780
|
+
schema: schema2
|
|
4770
4781
|
},
|
|
4771
4782
|
defaultOptions: [{ depth: void 0 }],
|
|
4772
4783
|
create(context) {
|
|
@@ -4881,7 +4892,7 @@ var standardiseErrorMessagesOptionsSchema = z5.object({
|
|
|
4881
4892
|
function parseStandardiseErrorMessagesOptions(data) {
|
|
4882
4893
|
return standardiseErrorMessagesOptionsSchema.parse(data);
|
|
4883
4894
|
}
|
|
4884
|
-
var
|
|
4895
|
+
var schema3 = createRuleSchema_default(standardiseErrorMessagesOptionsSchema);
|
|
4885
4896
|
var defaultErrorRegex = "^[A-Z]+(?:_[A-Z]+)*$";
|
|
4886
4897
|
function checkCurrentNode(context, node) {
|
|
4887
4898
|
var _a;
|
|
@@ -4913,7 +4924,7 @@ var standardiseErrorMessages = createRule_default({
|
|
|
4913
4924
|
message: "Expected error message {{error}} to match {{regex}}."
|
|
4914
4925
|
},
|
|
4915
4926
|
type: "suggestion",
|
|
4916
|
-
schema:
|
|
4927
|
+
schema: schema3
|
|
4917
4928
|
},
|
|
4918
4929
|
defaultOptions: [{ regex: defaultErrorRegex }],
|
|
4919
4930
|
create(context) {
|
|
@@ -4938,7 +4949,7 @@ var useNormalizedImportsOptionsSchema = z6.object({
|
|
|
4938
4949
|
function parseUseNormalizedImportsOptions(data) {
|
|
4939
4950
|
return useNormalizedImportsOptionsSchema.parse(data);
|
|
4940
4951
|
}
|
|
4941
|
-
var
|
|
4952
|
+
var schema4 = createRuleSchema_default(useNormalizedImportsOptionsSchema);
|
|
4942
4953
|
var useNormalizedImports = createRule_default({
|
|
4943
4954
|
name: "use-normalized-imports",
|
|
4944
4955
|
meta: {
|
|
@@ -4949,15 +4960,13 @@ var useNormalizedImports = createRule_default({
|
|
|
4949
4960
|
pathNotNormalized: "Import path {{nonNormalized}} is not normalised. Please use {{normalized}} instead."
|
|
4950
4961
|
},
|
|
4951
4962
|
type: "suggestion",
|
|
4952
|
-
schema:
|
|
4963
|
+
schema: schema4,
|
|
4953
4964
|
fixable: "code"
|
|
4954
4965
|
},
|
|
4955
4966
|
defaultOptions: [{ fixable: true }],
|
|
4956
4967
|
create(context) {
|
|
4957
4968
|
var _a;
|
|
4958
|
-
const { fixable
|
|
4959
|
-
(_a = context.options[0]) != null ? _a : { fixable: true }
|
|
4960
|
-
);
|
|
4969
|
+
const { fixable } = parseUseNormalizedImportsOptions((_a = context.options[0]) != null ? _a : { fixable: true });
|
|
4961
4970
|
return {
|
|
4962
4971
|
ImportDeclaration(node) {
|
|
4963
4972
|
const normalizedPath = path.posix.normalize(node.source.value);
|
|
@@ -4969,10 +4978,13 @@ var useNormalizedImports = createRule_default({
|
|
|
4969
4978
|
nonNormalized: node.source.value,
|
|
4970
4979
|
normalized: normalizedPath
|
|
4971
4980
|
},
|
|
4972
|
-
fix
|
|
4981
|
+
fix(fixer) {
|
|
4982
|
+
if (!fixable) {
|
|
4983
|
+
return null;
|
|
4984
|
+
}
|
|
4973
4985
|
const [quote] = node.source.raw;
|
|
4974
4986
|
return fixer.replaceText(node.source, `${quote}${normalizedPath}${quote}`);
|
|
4975
|
-
}
|
|
4987
|
+
}
|
|
4976
4988
|
});
|
|
4977
4989
|
}
|
|
4978
4990
|
}
|
|
@@ -4983,6 +4995,13 @@ var use_normalized_imports_default = useNormalizedImports;
|
|
|
4983
4995
|
|
|
4984
4996
|
// src/rules/use-object-shorthand.ts
|
|
4985
4997
|
import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/utils";
|
|
4998
|
+
import z7 from "zod";
|
|
4999
|
+
var useObjectShorthandOptionsSchema = z7.object({
|
|
5000
|
+
fixable: z7.boolean()
|
|
5001
|
+
}).partial();
|
|
5002
|
+
function parseUseObjectShorthandOptions(data) {
|
|
5003
|
+
return useObjectShorthandOptionsSchema.parse(data);
|
|
5004
|
+
}
|
|
4986
5005
|
var useObjectShorthand = createRule_default({
|
|
4987
5006
|
name: "use-object-shorthand",
|
|
4988
5007
|
meta: {
|
|
@@ -4994,10 +5013,12 @@ var useObjectShorthand = createRule_default({
|
|
|
4994
5013
|
},
|
|
4995
5014
|
type: "suggestion",
|
|
4996
5015
|
fixable: "code",
|
|
4997
|
-
schema:
|
|
5016
|
+
schema: createRuleSchema_default(useObjectShorthandOptionsSchema)
|
|
4998
5017
|
},
|
|
4999
|
-
defaultOptions: [],
|
|
5018
|
+
defaultOptions: [{ fixable: true }],
|
|
5000
5019
|
create(context) {
|
|
5020
|
+
var _a;
|
|
5021
|
+
const { fixable } = parseUseObjectShorthandOptions((_a = context.options[0]) != null ? _a : { fixable: true });
|
|
5001
5022
|
return {
|
|
5002
5023
|
Property(node) {
|
|
5003
5024
|
if (node.key.type === AST_NODE_TYPES4.Identifier && node.value.type === AST_NODE_TYPES4.Identifier && node.key.name === node.value.name && !node.shorthand) {
|
|
@@ -5008,6 +5029,9 @@ var useObjectShorthand = createRule_default({
|
|
|
5008
5029
|
source: context.sourceCode.getText(node)
|
|
5009
5030
|
},
|
|
5010
5031
|
fix(fixer) {
|
|
5032
|
+
if (!fixable) {
|
|
5033
|
+
return null;
|
|
5034
|
+
}
|
|
5011
5035
|
const key = node.key;
|
|
5012
5036
|
return fixer.replaceTextRange([node.range[0], node.range[1]], key.name);
|
|
5013
5037
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/eslint-plugin",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "A package to provide custom ESLint rules and configs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@alextheman/utility": "^2.15.1",
|
|
42
|
+
"@typescript-eslint/utils": "^8.46.4",
|
|
42
43
|
"common-tags": "^1.8.2",
|
|
43
44
|
"zod": "^4.1.12"
|
|
44
45
|
},
|
|
@@ -48,8 +49,6 @@
|
|
|
48
49
|
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
|
|
49
50
|
"@types/node": "^24.10.1",
|
|
50
51
|
"@typescript-eslint/rule-tester": "^8.46.4",
|
|
51
|
-
"@typescript-eslint/utils": "^8.46.4",
|
|
52
|
-
"eslint-plugin-eslint-plugin": "^7.2.0",
|
|
53
52
|
"globals": "^16.5.0",
|
|
54
53
|
"husky": "^9.1.7",
|
|
55
54
|
"prettier": "^3.6.2",
|