@alextheman/eslint-plugin 3.1.1 → 3.1.2
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 +31 -34
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +31 -34
- package/package.json +1 -1
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.1.
|
|
3768
|
+
var version = "3.1.2";
|
|
3769
3769
|
|
|
3770
3770
|
// src/configs/index.ts
|
|
3771
3771
|
var import_eslint_plugin_package_json = __toESM(require("eslint-plugin-package-json"), 1);
|
|
@@ -4487,13 +4487,24 @@ var configs_default = createAlexPluginConfigs;
|
|
|
4487
4487
|
var import_utils2 = require("@typescript-eslint/utils");
|
|
4488
4488
|
var import_zod2 = __toESM(require("zod"), 1);
|
|
4489
4489
|
|
|
4490
|
-
// src/createRule.ts
|
|
4490
|
+
// src/rules/helpers/createRule.ts
|
|
4491
4491
|
var import_utils = require("@typescript-eslint/utils");
|
|
4492
4492
|
var createRule = import_utils.ESLintUtils.RuleCreator((ruleName) => {
|
|
4493
4493
|
return `https://github.com/AlexMan123456/eslint-plugin/${ruleName}`;
|
|
4494
4494
|
});
|
|
4495
4495
|
var createRule_default = createRule;
|
|
4496
4496
|
|
|
4497
|
+
// src/rules/helpers/fixOnCondition.ts
|
|
4498
|
+
function fixOnCondition(fixable, fix) {
|
|
4499
|
+
return (fixer) => {
|
|
4500
|
+
if (!fixable) {
|
|
4501
|
+
return null;
|
|
4502
|
+
}
|
|
4503
|
+
return fix(fixer);
|
|
4504
|
+
};
|
|
4505
|
+
}
|
|
4506
|
+
var fixOnCondition_default = fixOnCondition;
|
|
4507
|
+
|
|
4497
4508
|
// src/utility/createRuleSchema.ts
|
|
4498
4509
|
var import_utility4 = require("@alextheman/utility");
|
|
4499
4510
|
var import_zod = __toESM(require("zod"), 1);
|
|
@@ -4552,12 +4563,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4552
4563
|
source: node.callee.name,
|
|
4553
4564
|
preference
|
|
4554
4565
|
},
|
|
4555
|
-
fix(fixer) {
|
|
4556
|
-
if (!fixable) {
|
|
4557
|
-
return null;
|
|
4558
|
-
}
|
|
4566
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
4559
4567
|
return fixer.replaceText(node.callee, "test");
|
|
4560
|
-
}
|
|
4568
|
+
})
|
|
4561
4569
|
});
|
|
4562
4570
|
}
|
|
4563
4571
|
if (node.callee.type === import_utils2.AST_NODE_TYPES.Identifier && node.callee.name === "test" && preference === "it") {
|
|
@@ -4568,12 +4576,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4568
4576
|
source: node.callee.name,
|
|
4569
4577
|
preference
|
|
4570
4578
|
},
|
|
4571
|
-
fix(fixer) {
|
|
4572
|
-
if (!fixable) {
|
|
4573
|
-
return null;
|
|
4574
|
-
}
|
|
4579
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
4575
4580
|
return fixer.replaceText(node.callee, "it");
|
|
4576
|
-
}
|
|
4581
|
+
})
|
|
4577
4582
|
});
|
|
4578
4583
|
}
|
|
4579
4584
|
},
|
|
@@ -4587,10 +4592,7 @@ var consistentTestFunction = createRule_default({
|
|
|
4587
4592
|
source: specifier.imported.name,
|
|
4588
4593
|
preference
|
|
4589
4594
|
},
|
|
4590
|
-
fix(fixer) {
|
|
4591
|
-
if (!fixable) {
|
|
4592
|
-
return null;
|
|
4593
|
-
}
|
|
4595
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
4594
4596
|
const importedNames = node.specifiers.map((specifier2) => {
|
|
4595
4597
|
return specifier2.type === import_utils2.AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === import_utils2.AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
4596
4598
|
});
|
|
@@ -4612,7 +4614,7 @@ var consistentTestFunction = createRule_default({
|
|
|
4612
4614
|
[specifier.imported.range[0], specifier.imported.range[1]],
|
|
4613
4615
|
preference
|
|
4614
4616
|
);
|
|
4615
|
-
}
|
|
4617
|
+
})
|
|
4616
4618
|
});
|
|
4617
4619
|
}
|
|
4618
4620
|
if (specifier.type === import_utils2.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils2.AST_NODE_TYPES.Identifier && specifier.imported.name === "test" && preference === "it") {
|
|
@@ -4623,10 +4625,7 @@ var consistentTestFunction = createRule_default({
|
|
|
4623
4625
|
source: specifier.imported.name,
|
|
4624
4626
|
preference
|
|
4625
4627
|
},
|
|
4626
|
-
fix(fixer) {
|
|
4627
|
-
if (!fixable) {
|
|
4628
|
-
return null;
|
|
4629
|
-
}
|
|
4628
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
4630
4629
|
const importedNames = node.specifiers.map((specifier2) => {
|
|
4631
4630
|
return specifier2.type === import_utils2.AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === import_utils2.AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
4632
4631
|
});
|
|
@@ -4648,7 +4647,7 @@ var consistentTestFunction = createRule_default({
|
|
|
4648
4647
|
[specifier.imported.range[0], specifier.imported.range[1]],
|
|
4649
4648
|
preference
|
|
4650
4649
|
);
|
|
4651
|
-
}
|
|
4650
|
+
})
|
|
4652
4651
|
});
|
|
4653
4652
|
}
|
|
4654
4653
|
}
|
|
@@ -4987,7 +4986,9 @@ var useNormalizedImports = createRule_default({
|
|
|
4987
4986
|
defaultOptions: [{ fixable: true }],
|
|
4988
4987
|
create(context) {
|
|
4989
4988
|
var _a;
|
|
4990
|
-
const { fixable } = parseUseNormalizedImportsOptions(
|
|
4989
|
+
const { fixable = true } = parseUseNormalizedImportsOptions(
|
|
4990
|
+
(_a = context.options[0]) != null ? _a : { fixable: true }
|
|
4991
|
+
);
|
|
4991
4992
|
return {
|
|
4992
4993
|
ImportDeclaration(node) {
|
|
4993
4994
|
const normalizedPath = import_path.default.posix.normalize(node.source.value);
|
|
@@ -4999,13 +5000,10 @@ var useNormalizedImports = createRule_default({
|
|
|
4999
5000
|
nonNormalized: node.source.value,
|
|
5000
5001
|
normalized: normalizedPath
|
|
5001
5002
|
},
|
|
5002
|
-
fix(fixer) {
|
|
5003
|
-
if (!fixable) {
|
|
5004
|
-
return null;
|
|
5005
|
-
}
|
|
5003
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
5006
5004
|
const [quote] = node.source.raw;
|
|
5007
5005
|
return fixer.replaceText(node.source, `${quote}${normalizedPath}${quote}`);
|
|
5008
|
-
}
|
|
5006
|
+
})
|
|
5009
5007
|
});
|
|
5010
5008
|
}
|
|
5011
5009
|
}
|
|
@@ -5039,7 +5037,9 @@ var useObjectShorthand = createRule_default({
|
|
|
5039
5037
|
defaultOptions: [{ fixable: true }],
|
|
5040
5038
|
create(context) {
|
|
5041
5039
|
var _a;
|
|
5042
|
-
const { fixable } = parseUseObjectShorthandOptions(
|
|
5040
|
+
const { fixable = true } = parseUseObjectShorthandOptions(
|
|
5041
|
+
(_a = context.options[0]) != null ? _a : { fixable: true }
|
|
5042
|
+
);
|
|
5043
5043
|
return {
|
|
5044
5044
|
Property(node) {
|
|
5045
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) {
|
|
@@ -5049,13 +5049,10 @@ var useObjectShorthand = createRule_default({
|
|
|
5049
5049
|
data: {
|
|
5050
5050
|
source: context.sourceCode.getText(node)
|
|
5051
5051
|
},
|
|
5052
|
-
fix(fixer) {
|
|
5053
|
-
if (!fixable) {
|
|
5054
|
-
return null;
|
|
5055
|
-
}
|
|
5052
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
5056
5053
|
const key = node.key;
|
|
5057
5054
|
return fixer.replaceTextRange([node.range[0], node.range[1]], key.name);
|
|
5058
|
-
}
|
|
5055
|
+
})
|
|
5059
5056
|
});
|
|
5060
5057
|
}
|
|
5061
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.1.
|
|
7
|
+
var version = "3.1.2";
|
|
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
|
|
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.1.
|
|
7
|
+
var version = "3.1.2";
|
|
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
|
|
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.1.
|
|
3747
|
+
var version = "3.1.2";
|
|
3748
3748
|
|
|
3749
3749
|
// src/configs/index.ts
|
|
3750
3750
|
import packageJson from "eslint-plugin-package-json";
|
|
@@ -4466,13 +4466,24 @@ var configs_default = createAlexPluginConfigs;
|
|
|
4466
4466
|
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
4467
4467
|
import z2 from "zod";
|
|
4468
4468
|
|
|
4469
|
-
// src/createRule.ts
|
|
4469
|
+
// src/rules/helpers/createRule.ts
|
|
4470
4470
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
4471
4471
|
var createRule = ESLintUtils.RuleCreator((ruleName) => {
|
|
4472
4472
|
return `https://github.com/AlexMan123456/eslint-plugin/${ruleName}`;
|
|
4473
4473
|
});
|
|
4474
4474
|
var createRule_default = createRule;
|
|
4475
4475
|
|
|
4476
|
+
// src/rules/helpers/fixOnCondition.ts
|
|
4477
|
+
function fixOnCondition(fixable, fix) {
|
|
4478
|
+
return (fixer) => {
|
|
4479
|
+
if (!fixable) {
|
|
4480
|
+
return null;
|
|
4481
|
+
}
|
|
4482
|
+
return fix(fixer);
|
|
4483
|
+
};
|
|
4484
|
+
}
|
|
4485
|
+
var fixOnCondition_default = fixOnCondition;
|
|
4486
|
+
|
|
4476
4487
|
// src/utility/createRuleSchema.ts
|
|
4477
4488
|
import { omitProperties as omitProperties2 } from "@alextheman/utility";
|
|
4478
4489
|
import z from "zod";
|
|
@@ -4531,12 +4542,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4531
4542
|
source: node.callee.name,
|
|
4532
4543
|
preference
|
|
4533
4544
|
},
|
|
4534
|
-
fix(fixer) {
|
|
4535
|
-
if (!fixable) {
|
|
4536
|
-
return null;
|
|
4537
|
-
}
|
|
4545
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
4538
4546
|
return fixer.replaceText(node.callee, "test");
|
|
4539
|
-
}
|
|
4547
|
+
})
|
|
4540
4548
|
});
|
|
4541
4549
|
}
|
|
4542
4550
|
if (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "test" && preference === "it") {
|
|
@@ -4547,12 +4555,9 @@ var consistentTestFunction = createRule_default({
|
|
|
4547
4555
|
source: node.callee.name,
|
|
4548
4556
|
preference
|
|
4549
4557
|
},
|
|
4550
|
-
fix(fixer) {
|
|
4551
|
-
if (!fixable) {
|
|
4552
|
-
return null;
|
|
4553
|
-
}
|
|
4558
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
4554
4559
|
return fixer.replaceText(node.callee, "it");
|
|
4555
|
-
}
|
|
4560
|
+
})
|
|
4556
4561
|
});
|
|
4557
4562
|
}
|
|
4558
4563
|
},
|
|
@@ -4566,10 +4571,7 @@ var consistentTestFunction = createRule_default({
|
|
|
4566
4571
|
source: specifier.imported.name,
|
|
4567
4572
|
preference
|
|
4568
4573
|
},
|
|
4569
|
-
fix(fixer) {
|
|
4570
|
-
if (!fixable) {
|
|
4571
|
-
return null;
|
|
4572
|
-
}
|
|
4574
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
4573
4575
|
const importedNames = node.specifiers.map((specifier2) => {
|
|
4574
4576
|
return specifier2.type === AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
4575
4577
|
});
|
|
@@ -4591,7 +4593,7 @@ var consistentTestFunction = createRule_default({
|
|
|
4591
4593
|
[specifier.imported.range[0], specifier.imported.range[1]],
|
|
4592
4594
|
preference
|
|
4593
4595
|
);
|
|
4594
|
-
}
|
|
4596
|
+
})
|
|
4595
4597
|
});
|
|
4596
4598
|
}
|
|
4597
4599
|
if (specifier.type === AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES.Identifier && specifier.imported.name === "test" && preference === "it") {
|
|
@@ -4602,10 +4604,7 @@ var consistentTestFunction = createRule_default({
|
|
|
4602
4604
|
source: specifier.imported.name,
|
|
4603
4605
|
preference
|
|
4604
4606
|
},
|
|
4605
|
-
fix(fixer) {
|
|
4606
|
-
if (!fixable) {
|
|
4607
|
-
return null;
|
|
4608
|
-
}
|
|
4607
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
4609
4608
|
const importedNames = node.specifiers.map((specifier2) => {
|
|
4610
4609
|
return specifier2.type === AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
4611
4610
|
});
|
|
@@ -4627,7 +4626,7 @@ var consistentTestFunction = createRule_default({
|
|
|
4627
4626
|
[specifier.imported.range[0], specifier.imported.range[1]],
|
|
4628
4627
|
preference
|
|
4629
4628
|
);
|
|
4630
|
-
}
|
|
4629
|
+
})
|
|
4631
4630
|
});
|
|
4632
4631
|
}
|
|
4633
4632
|
}
|
|
@@ -4966,7 +4965,9 @@ var useNormalizedImports = createRule_default({
|
|
|
4966
4965
|
defaultOptions: [{ fixable: true }],
|
|
4967
4966
|
create(context) {
|
|
4968
4967
|
var _a;
|
|
4969
|
-
const { fixable } = parseUseNormalizedImportsOptions(
|
|
4968
|
+
const { fixable = true } = parseUseNormalizedImportsOptions(
|
|
4969
|
+
(_a = context.options[0]) != null ? _a : { fixable: true }
|
|
4970
|
+
);
|
|
4970
4971
|
return {
|
|
4971
4972
|
ImportDeclaration(node) {
|
|
4972
4973
|
const normalizedPath = path.posix.normalize(node.source.value);
|
|
@@ -4978,13 +4979,10 @@ var useNormalizedImports = createRule_default({
|
|
|
4978
4979
|
nonNormalized: node.source.value,
|
|
4979
4980
|
normalized: normalizedPath
|
|
4980
4981
|
},
|
|
4981
|
-
fix(fixer) {
|
|
4982
|
-
if (!fixable) {
|
|
4983
|
-
return null;
|
|
4984
|
-
}
|
|
4982
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
4985
4983
|
const [quote] = node.source.raw;
|
|
4986
4984
|
return fixer.replaceText(node.source, `${quote}${normalizedPath}${quote}`);
|
|
4987
|
-
}
|
|
4985
|
+
})
|
|
4988
4986
|
});
|
|
4989
4987
|
}
|
|
4990
4988
|
}
|
|
@@ -5018,7 +5016,9 @@ var useObjectShorthand = createRule_default({
|
|
|
5018
5016
|
defaultOptions: [{ fixable: true }],
|
|
5019
5017
|
create(context) {
|
|
5020
5018
|
var _a;
|
|
5021
|
-
const { fixable } = parseUseObjectShorthandOptions(
|
|
5019
|
+
const { fixable = true } = parseUseObjectShorthandOptions(
|
|
5020
|
+
(_a = context.options[0]) != null ? _a : { fixable: true }
|
|
5021
|
+
);
|
|
5022
5022
|
return {
|
|
5023
5023
|
Property(node) {
|
|
5024
5024
|
if (node.key.type === AST_NODE_TYPES4.Identifier && node.value.type === AST_NODE_TYPES4.Identifier && node.key.name === node.value.name && !node.shorthand) {
|
|
@@ -5028,13 +5028,10 @@ var useObjectShorthand = createRule_default({
|
|
|
5028
5028
|
data: {
|
|
5029
5029
|
source: context.sourceCode.getText(node)
|
|
5030
5030
|
},
|
|
5031
|
-
fix(fixer) {
|
|
5032
|
-
if (!fixable) {
|
|
5033
|
-
return null;
|
|
5034
|
-
}
|
|
5031
|
+
fix: fixOnCondition_default(fixable, (fixer) => {
|
|
5035
5032
|
const key = node.key;
|
|
5036
5033
|
return fixer.replaceTextRange([node.range[0], node.range[1]], key.name);
|
|
5037
|
-
}
|
|
5034
|
+
})
|
|
5038
5035
|
});
|
|
5039
5036
|
}
|
|
5040
5037
|
}
|