@alextheman/eslint-plugin 1.11.0 → 1.12.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 +173 -18
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +173 -18
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -3706,7 +3706,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
3706
3706
|
|
|
3707
3707
|
// package.json
|
|
3708
3708
|
var name = "@alextheman/eslint-plugin";
|
|
3709
|
-
var version = "1.
|
|
3709
|
+
var version = "1.12.0";
|
|
3710
3710
|
|
|
3711
3711
|
// src/configs/alexPluginBase.ts
|
|
3712
3712
|
function createAlexPluginBaseConfig(plugin2) {
|
|
@@ -3725,7 +3725,8 @@ function createAlexPluginBaseConfig(plugin2) {
|
|
|
3725
3725
|
files: ["**/*.test.ts"],
|
|
3726
3726
|
rules: {
|
|
3727
3727
|
"@alextheman/no-isolated-tests": "error",
|
|
3728
|
-
"@alextheman/no-skipped-tests": "warn"
|
|
3728
|
+
"@alextheman/no-skipped-tests": "warn",
|
|
3729
|
+
"@alextheman/consistent-test-function": ["error", { preference: "test" }]
|
|
3729
3730
|
}
|
|
3730
3731
|
}
|
|
3731
3732
|
];
|
|
@@ -3754,7 +3755,7 @@ var typeScriptBase = [
|
|
|
3754
3755
|
import_eslint_config_prettier.default,
|
|
3755
3756
|
{
|
|
3756
3757
|
name: "@alextheman/eslint-config-typescript-base",
|
|
3757
|
-
files: ["**/*.ts", "**/*.tsx"
|
|
3758
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
3758
3759
|
languageOptions: {
|
|
3759
3760
|
parser: import_parser.default,
|
|
3760
3761
|
parserOptions: {
|
|
@@ -3780,17 +3781,6 @@ var typeScriptBase = [
|
|
|
3780
3781
|
"import/no-unresolved": "error",
|
|
3781
3782
|
eqeqeq: "error",
|
|
3782
3783
|
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
3783
|
-
"no-restricted-imports": [
|
|
3784
|
-
"error",
|
|
3785
|
-
{
|
|
3786
|
-
patterns: [
|
|
3787
|
-
{
|
|
3788
|
-
group: ["node:test"],
|
|
3789
|
-
message: "Use test functions from vitest instead."
|
|
3790
|
-
}
|
|
3791
|
-
]
|
|
3792
|
-
}
|
|
3793
|
-
],
|
|
3794
3784
|
"perfectionist/sort-imports": [
|
|
3795
3785
|
"error",
|
|
3796
3786
|
{
|
|
@@ -3841,6 +3831,22 @@ var typeScriptBase = [
|
|
|
3841
3831
|
"@typescript-eslint/consistent-type-imports": "error",
|
|
3842
3832
|
"prettier/prettier": ["warn", prettierRules_default]
|
|
3843
3833
|
}
|
|
3834
|
+
},
|
|
3835
|
+
{
|
|
3836
|
+
files: ["**/*.test.ts"],
|
|
3837
|
+
rules: {
|
|
3838
|
+
"no-restricted-imports": [
|
|
3839
|
+
"error",
|
|
3840
|
+
{
|
|
3841
|
+
patterns: [
|
|
3842
|
+
{
|
|
3843
|
+
group: ["node:test"],
|
|
3844
|
+
message: "Use test functions from vitest instead."
|
|
3845
|
+
}
|
|
3846
|
+
]
|
|
3847
|
+
}
|
|
3848
|
+
]
|
|
3849
|
+
}
|
|
3844
3850
|
}
|
|
3845
3851
|
];
|
|
3846
3852
|
var typeScriptBase_default = typeScriptBase;
|
|
@@ -3894,6 +3900,10 @@ function createAlexTypeScriptReactBaseConfig(plugin2) {
|
|
|
3894
3900
|
}
|
|
3895
3901
|
var alexTypeScriptReactBase_default = createAlexTypeScriptReactBaseConfig;
|
|
3896
3902
|
|
|
3903
|
+
// src/rules/consistent-test-function.ts
|
|
3904
|
+
var import_utils2 = require("@typescript-eslint/utils");
|
|
3905
|
+
var import_zod = __toESM(require("zod"), 1);
|
|
3906
|
+
|
|
3897
3907
|
// src/create-rule.ts
|
|
3898
3908
|
var import_utils = require("@typescript-eslint/utils");
|
|
3899
3909
|
var createRule = import_utils.ESLintUtils.RuleCreator((ruleName) => {
|
|
@@ -3901,10 +3911,154 @@ var createRule = import_utils.ESLintUtils.RuleCreator((ruleName) => {
|
|
|
3901
3911
|
});
|
|
3902
3912
|
var create_rule_default = createRule;
|
|
3903
3913
|
|
|
3914
|
+
// src/utility/getImportSpecifiersAfterRemoving.ts
|
|
3915
|
+
function getImportSpecifiersAfterRemoving(context, specifiers, importToRemove) {
|
|
3916
|
+
return specifiers.filter((specifier) => {
|
|
3917
|
+
return !(specifier.imported.name === importToRemove);
|
|
3918
|
+
}).map((specifier) => {
|
|
3919
|
+
return context.sourceCode.getText(specifier);
|
|
3920
|
+
}).join(", ");
|
|
3921
|
+
}
|
|
3922
|
+
var getImportSpecifiersAfterRemoving_default = getImportSpecifiersAfterRemoving;
|
|
3923
|
+
|
|
3924
|
+
// src/rules/consistent-test-function.ts
|
|
3925
|
+
var validTestFunctionsSchema = import_zod.default.enum(["test", "it"]);
|
|
3926
|
+
var consistentTestFunction = create_rule_default({
|
|
3927
|
+
name: "consistent-test-function",
|
|
3928
|
+
meta: {
|
|
3929
|
+
docs: {
|
|
3930
|
+
description: "Enforce a consistent function (either `test` or `it`)"
|
|
3931
|
+
},
|
|
3932
|
+
messages: {
|
|
3933
|
+
message: "Unexpected {{source}}. Please use {{preference}} instead."
|
|
3934
|
+
},
|
|
3935
|
+
type: "suggestion",
|
|
3936
|
+
fixable: "code",
|
|
3937
|
+
schema: [
|
|
3938
|
+
{
|
|
3939
|
+
type: "object",
|
|
3940
|
+
properties: {
|
|
3941
|
+
preference: {
|
|
3942
|
+
type: "string"
|
|
3943
|
+
}
|
|
3944
|
+
},
|
|
3945
|
+
additionalProperties: false
|
|
3946
|
+
}
|
|
3947
|
+
]
|
|
3948
|
+
},
|
|
3949
|
+
defaultOptions: [{ preference: "test" }],
|
|
3950
|
+
create(context) {
|
|
3951
|
+
var _a;
|
|
3952
|
+
const preference = (_a = context.options[0]) == null ? void 0 : _a.preference;
|
|
3953
|
+
const validatedPreference = validTestFunctionsSchema.parse(preference != null ? preference : "test");
|
|
3954
|
+
return {
|
|
3955
|
+
CallExpression(node) {
|
|
3956
|
+
if (node.callee.type === import_utils2.AST_NODE_TYPES.Identifier && node.callee.name === "it" && validatedPreference === "test") {
|
|
3957
|
+
return context.report({
|
|
3958
|
+
node,
|
|
3959
|
+
messageId: "message",
|
|
3960
|
+
data: {
|
|
3961
|
+
source: node.callee.name,
|
|
3962
|
+
preference: validatedPreference
|
|
3963
|
+
},
|
|
3964
|
+
fix(fixer) {
|
|
3965
|
+
return fixer.replaceText(node.callee, "test");
|
|
3966
|
+
}
|
|
3967
|
+
});
|
|
3968
|
+
}
|
|
3969
|
+
if (node.callee.type === import_utils2.AST_NODE_TYPES.Identifier && node.callee.name === "test" && validatedPreference === "it") {
|
|
3970
|
+
return context.report({
|
|
3971
|
+
node,
|
|
3972
|
+
messageId: "message",
|
|
3973
|
+
data: {
|
|
3974
|
+
source: node.callee.name,
|
|
3975
|
+
preference: validatedPreference
|
|
3976
|
+
},
|
|
3977
|
+
fix(fixer) {
|
|
3978
|
+
return fixer.replaceText(node.callee, "it");
|
|
3979
|
+
}
|
|
3980
|
+
});
|
|
3981
|
+
}
|
|
3982
|
+
},
|
|
3983
|
+
ImportDeclaration(node) {
|
|
3984
|
+
for (const specifier of node.specifiers) {
|
|
3985
|
+
if (specifier.type === import_utils2.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils2.AST_NODE_TYPES.Identifier && specifier.imported.name === "it" && validatedPreference === "test") {
|
|
3986
|
+
return context.report({
|
|
3987
|
+
node,
|
|
3988
|
+
messageId: "message",
|
|
3989
|
+
data: {
|
|
3990
|
+
source: specifier.imported.name,
|
|
3991
|
+
preference: validatedPreference
|
|
3992
|
+
},
|
|
3993
|
+
fix(fixer) {
|
|
3994
|
+
const importedNames = node.specifiers.map((specifier2) => {
|
|
3995
|
+
return specifier2.type === import_utils2.AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === import_utils2.AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
3996
|
+
});
|
|
3997
|
+
if (importedNames.includes("it") && importedNames.includes("test")) {
|
|
3998
|
+
const newSpecifiers = getImportSpecifiersAfterRemoving_default(
|
|
3999
|
+
context,
|
|
4000
|
+
node.specifiers,
|
|
4001
|
+
"it"
|
|
4002
|
+
);
|
|
4003
|
+
return fixer.replaceTextRange(
|
|
4004
|
+
[
|
|
4005
|
+
node.specifiers[0].range[0],
|
|
4006
|
+
node.specifiers[node.specifiers.length - 1].range[1]
|
|
4007
|
+
],
|
|
4008
|
+
newSpecifiers
|
|
4009
|
+
);
|
|
4010
|
+
}
|
|
4011
|
+
return fixer.replaceTextRange(
|
|
4012
|
+
[specifier.imported.range[0], specifier.imported.range[1]],
|
|
4013
|
+
validatedPreference
|
|
4014
|
+
);
|
|
4015
|
+
}
|
|
4016
|
+
});
|
|
4017
|
+
}
|
|
4018
|
+
if (specifier.type === import_utils2.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils2.AST_NODE_TYPES.Identifier && specifier.imported.name === "test" && validatedPreference === "it") {
|
|
4019
|
+
return context.report({
|
|
4020
|
+
node,
|
|
4021
|
+
messageId: "message",
|
|
4022
|
+
data: {
|
|
4023
|
+
source: specifier.imported.name,
|
|
4024
|
+
preference: validatedPreference
|
|
4025
|
+
},
|
|
4026
|
+
fix(fixer) {
|
|
4027
|
+
const importedNames = node.specifiers.map((specifier2) => {
|
|
4028
|
+
return specifier2.type === import_utils2.AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === import_utils2.AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
4029
|
+
});
|
|
4030
|
+
if (importedNames.includes("it") && importedNames.includes("test")) {
|
|
4031
|
+
const newSpecifiers = getImportSpecifiersAfterRemoving_default(
|
|
4032
|
+
context,
|
|
4033
|
+
node.specifiers,
|
|
4034
|
+
"test"
|
|
4035
|
+
);
|
|
4036
|
+
return fixer.replaceTextRange(
|
|
4037
|
+
[
|
|
4038
|
+
node.specifiers[0].range[0],
|
|
4039
|
+
node.specifiers[node.specifiers.length - 1].range[1]
|
|
4040
|
+
],
|
|
4041
|
+
newSpecifiers
|
|
4042
|
+
);
|
|
4043
|
+
}
|
|
4044
|
+
return fixer.replaceTextRange(
|
|
4045
|
+
[specifier.imported.range[0], specifier.imported.range[1]],
|
|
4046
|
+
validatedPreference
|
|
4047
|
+
);
|
|
4048
|
+
}
|
|
4049
|
+
});
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
};
|
|
4054
|
+
}
|
|
4055
|
+
});
|
|
4056
|
+
var consistent_test_function_default = consistentTestFunction;
|
|
4057
|
+
|
|
3904
4058
|
// src/utility/checkCallExpression.ts
|
|
3905
|
-
var
|
|
4059
|
+
var import_utils3 = require("@typescript-eslint/utils");
|
|
3906
4060
|
function checkCallExpression(node, objectName, propertyName) {
|
|
3907
|
-
return node.callee.type ===
|
|
4061
|
+
return node.callee.type === import_utils3.AST_NODE_TYPES.MemberExpression && node.callee.object.type === import_utils3.AST_NODE_TYPES.Identifier && node.callee.object.name === objectName && node.callee.property.type === import_utils3.AST_NODE_TYPES.Identifier && node.callee.property.name === propertyName;
|
|
3908
4062
|
}
|
|
3909
4063
|
var checkCallExpression_default = checkCallExpression;
|
|
3910
4064
|
|
|
@@ -4152,7 +4306,7 @@ var noSkippedTests = create_rule_default({
|
|
|
4152
4306
|
var no_skipped_tests_default = noSkippedTests;
|
|
4153
4307
|
|
|
4154
4308
|
// src/rules/use-object-shorthand.ts
|
|
4155
|
-
var
|
|
4309
|
+
var import_utils4 = require("@typescript-eslint/utils");
|
|
4156
4310
|
var useObjectShorthand = create_rule_default({
|
|
4157
4311
|
name: "use-object-shorthand",
|
|
4158
4312
|
meta: {
|
|
@@ -4170,7 +4324,7 @@ var useObjectShorthand = create_rule_default({
|
|
|
4170
4324
|
create(context) {
|
|
4171
4325
|
return {
|
|
4172
4326
|
Property(node) {
|
|
4173
|
-
if (node.key.type ===
|
|
4327
|
+
if (node.key.type === import_utils4.AST_NODE_TYPES.Identifier && node.value.type === import_utils4.AST_NODE_TYPES.Identifier && node.key.name === node.value.name && !node.shorthand) {
|
|
4174
4328
|
context.report({
|
|
4175
4329
|
node,
|
|
4176
4330
|
messageId: "useShorthand",
|
|
@@ -4191,6 +4345,7 @@ var use_object_shorthand_default = useObjectShorthand;
|
|
|
4191
4345
|
|
|
4192
4346
|
// src/rules/index.ts
|
|
4193
4347
|
var rules_default = {
|
|
4348
|
+
"consistent-test-function": consistent_test_function_default,
|
|
4194
4349
|
"no-isolated-tests": no_isolated_tests_default,
|
|
4195
4350
|
"no-namespace-imports": no_namespace_imports_default,
|
|
4196
4351
|
"no-plugin-configs-access-from-src-configs": no_plugin_configs_access_from_src_configs_default,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { Linter } from 'eslint';
|
|
2
2
|
import { Config } from 'prettier';
|
|
3
|
+
import z from 'zod';
|
|
3
4
|
|
|
4
5
|
var name = "@alextheman/eslint-plugin";
|
|
5
|
-
var version = "1.
|
|
6
|
+
var version = "1.12.0";
|
|
6
7
|
|
|
7
8
|
declare const prettierRules: Config;
|
|
8
9
|
|
|
10
|
+
declare const validTestFunctionsSchema: z.ZodEnum<{
|
|
11
|
+
test: "test";
|
|
12
|
+
it: "it";
|
|
13
|
+
}>;
|
|
14
|
+
type ValidTestFunctions = z.infer<typeof validTestFunctionsSchema>;
|
|
15
|
+
|
|
9
16
|
interface AlexPlugin {
|
|
10
17
|
meta: {
|
|
11
18
|
name: typeof name;
|
|
@@ -24,4 +31,4 @@ interface AlexPlugin {
|
|
|
24
31
|
|
|
25
32
|
declare const plugin: AlexPlugin;
|
|
26
33
|
|
|
27
|
-
export { type AlexPlugin, plugin as default, prettierRules };
|
|
34
|
+
export { type AlexPlugin, type ValidTestFunctions, plugin as default, prettierRules };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { Linter } from 'eslint';
|
|
2
2
|
import { Config } from 'prettier';
|
|
3
|
+
import z from 'zod';
|
|
3
4
|
|
|
4
5
|
var name = "@alextheman/eslint-plugin";
|
|
5
|
-
var version = "1.
|
|
6
|
+
var version = "1.12.0";
|
|
6
7
|
|
|
7
8
|
declare const prettierRules: Config;
|
|
8
9
|
|
|
10
|
+
declare const validTestFunctionsSchema: z.ZodEnum<{
|
|
11
|
+
test: "test";
|
|
12
|
+
it: "it";
|
|
13
|
+
}>;
|
|
14
|
+
type ValidTestFunctions = z.infer<typeof validTestFunctionsSchema>;
|
|
15
|
+
|
|
9
16
|
interface AlexPlugin {
|
|
10
17
|
meta: {
|
|
11
18
|
name: typeof name;
|
|
@@ -24,4 +31,4 @@ interface AlexPlugin {
|
|
|
24
31
|
|
|
25
32
|
declare const plugin: AlexPlugin;
|
|
26
33
|
|
|
27
|
-
export { type AlexPlugin, plugin as default, prettierRules };
|
|
34
|
+
export { type AlexPlugin, type ValidTestFunctions, plugin as default, prettierRules };
|
package/dist/index.js
CHANGED
|
@@ -3692,7 +3692,7 @@ var require_globals2 = __commonJS({
|
|
|
3692
3692
|
|
|
3693
3693
|
// package.json
|
|
3694
3694
|
var name = "@alextheman/eslint-plugin";
|
|
3695
|
-
var version = "1.
|
|
3695
|
+
var version = "1.12.0";
|
|
3696
3696
|
|
|
3697
3697
|
// src/configs/alexPluginBase.ts
|
|
3698
3698
|
function createAlexPluginBaseConfig(plugin2) {
|
|
@@ -3711,7 +3711,8 @@ function createAlexPluginBaseConfig(plugin2) {
|
|
|
3711
3711
|
files: ["**/*.test.ts"],
|
|
3712
3712
|
rules: {
|
|
3713
3713
|
"@alextheman/no-isolated-tests": "error",
|
|
3714
|
-
"@alextheman/no-skipped-tests": "warn"
|
|
3714
|
+
"@alextheman/no-skipped-tests": "warn",
|
|
3715
|
+
"@alextheman/consistent-test-function": ["error", { preference: "test" }]
|
|
3715
3716
|
}
|
|
3716
3717
|
}
|
|
3717
3718
|
];
|
|
@@ -3740,7 +3741,7 @@ var typeScriptBase = [
|
|
|
3740
3741
|
prettierConfig,
|
|
3741
3742
|
{
|
|
3742
3743
|
name: "@alextheman/eslint-config-typescript-base",
|
|
3743
|
-
files: ["**/*.ts", "**/*.tsx"
|
|
3744
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
3744
3745
|
languageOptions: {
|
|
3745
3746
|
parser: tsparser,
|
|
3746
3747
|
parserOptions: {
|
|
@@ -3766,17 +3767,6 @@ var typeScriptBase = [
|
|
|
3766
3767
|
"import/no-unresolved": "error",
|
|
3767
3768
|
eqeqeq: "error",
|
|
3768
3769
|
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
3769
|
-
"no-restricted-imports": [
|
|
3770
|
-
"error",
|
|
3771
|
-
{
|
|
3772
|
-
patterns: [
|
|
3773
|
-
{
|
|
3774
|
-
group: ["node:test"],
|
|
3775
|
-
message: "Use test functions from vitest instead."
|
|
3776
|
-
}
|
|
3777
|
-
]
|
|
3778
|
-
}
|
|
3779
|
-
],
|
|
3780
3770
|
"perfectionist/sort-imports": [
|
|
3781
3771
|
"error",
|
|
3782
3772
|
{
|
|
@@ -3827,6 +3817,22 @@ var typeScriptBase = [
|
|
|
3827
3817
|
"@typescript-eslint/consistent-type-imports": "error",
|
|
3828
3818
|
"prettier/prettier": ["warn", prettierRules_default]
|
|
3829
3819
|
}
|
|
3820
|
+
},
|
|
3821
|
+
{
|
|
3822
|
+
files: ["**/*.test.ts"],
|
|
3823
|
+
rules: {
|
|
3824
|
+
"no-restricted-imports": [
|
|
3825
|
+
"error",
|
|
3826
|
+
{
|
|
3827
|
+
patterns: [
|
|
3828
|
+
{
|
|
3829
|
+
group: ["node:test"],
|
|
3830
|
+
message: "Use test functions from vitest instead."
|
|
3831
|
+
}
|
|
3832
|
+
]
|
|
3833
|
+
}
|
|
3834
|
+
]
|
|
3835
|
+
}
|
|
3830
3836
|
}
|
|
3831
3837
|
];
|
|
3832
3838
|
var typeScriptBase_default = typeScriptBase;
|
|
@@ -3880,6 +3886,10 @@ function createAlexTypeScriptReactBaseConfig(plugin2) {
|
|
|
3880
3886
|
}
|
|
3881
3887
|
var alexTypeScriptReactBase_default = createAlexTypeScriptReactBaseConfig;
|
|
3882
3888
|
|
|
3889
|
+
// src/rules/consistent-test-function.ts
|
|
3890
|
+
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
3891
|
+
import z from "zod";
|
|
3892
|
+
|
|
3883
3893
|
// src/create-rule.ts
|
|
3884
3894
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
3885
3895
|
var createRule = ESLintUtils.RuleCreator((ruleName) => {
|
|
@@ -3887,10 +3897,154 @@ var createRule = ESLintUtils.RuleCreator((ruleName) => {
|
|
|
3887
3897
|
});
|
|
3888
3898
|
var create_rule_default = createRule;
|
|
3889
3899
|
|
|
3900
|
+
// src/utility/getImportSpecifiersAfterRemoving.ts
|
|
3901
|
+
function getImportSpecifiersAfterRemoving(context, specifiers, importToRemove) {
|
|
3902
|
+
return specifiers.filter((specifier) => {
|
|
3903
|
+
return !(specifier.imported.name === importToRemove);
|
|
3904
|
+
}).map((specifier) => {
|
|
3905
|
+
return context.sourceCode.getText(specifier);
|
|
3906
|
+
}).join(", ");
|
|
3907
|
+
}
|
|
3908
|
+
var getImportSpecifiersAfterRemoving_default = getImportSpecifiersAfterRemoving;
|
|
3909
|
+
|
|
3910
|
+
// src/rules/consistent-test-function.ts
|
|
3911
|
+
var validTestFunctionsSchema = z.enum(["test", "it"]);
|
|
3912
|
+
var consistentTestFunction = create_rule_default({
|
|
3913
|
+
name: "consistent-test-function",
|
|
3914
|
+
meta: {
|
|
3915
|
+
docs: {
|
|
3916
|
+
description: "Enforce a consistent function (either `test` or `it`)"
|
|
3917
|
+
},
|
|
3918
|
+
messages: {
|
|
3919
|
+
message: "Unexpected {{source}}. Please use {{preference}} instead."
|
|
3920
|
+
},
|
|
3921
|
+
type: "suggestion",
|
|
3922
|
+
fixable: "code",
|
|
3923
|
+
schema: [
|
|
3924
|
+
{
|
|
3925
|
+
type: "object",
|
|
3926
|
+
properties: {
|
|
3927
|
+
preference: {
|
|
3928
|
+
type: "string"
|
|
3929
|
+
}
|
|
3930
|
+
},
|
|
3931
|
+
additionalProperties: false
|
|
3932
|
+
}
|
|
3933
|
+
]
|
|
3934
|
+
},
|
|
3935
|
+
defaultOptions: [{ preference: "test" }],
|
|
3936
|
+
create(context) {
|
|
3937
|
+
var _a;
|
|
3938
|
+
const preference = (_a = context.options[0]) == null ? void 0 : _a.preference;
|
|
3939
|
+
const validatedPreference = validTestFunctionsSchema.parse(preference != null ? preference : "test");
|
|
3940
|
+
return {
|
|
3941
|
+
CallExpression(node) {
|
|
3942
|
+
if (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "it" && validatedPreference === "test") {
|
|
3943
|
+
return context.report({
|
|
3944
|
+
node,
|
|
3945
|
+
messageId: "message",
|
|
3946
|
+
data: {
|
|
3947
|
+
source: node.callee.name,
|
|
3948
|
+
preference: validatedPreference
|
|
3949
|
+
},
|
|
3950
|
+
fix(fixer) {
|
|
3951
|
+
return fixer.replaceText(node.callee, "test");
|
|
3952
|
+
}
|
|
3953
|
+
});
|
|
3954
|
+
}
|
|
3955
|
+
if (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "test" && validatedPreference === "it") {
|
|
3956
|
+
return context.report({
|
|
3957
|
+
node,
|
|
3958
|
+
messageId: "message",
|
|
3959
|
+
data: {
|
|
3960
|
+
source: node.callee.name,
|
|
3961
|
+
preference: validatedPreference
|
|
3962
|
+
},
|
|
3963
|
+
fix(fixer) {
|
|
3964
|
+
return fixer.replaceText(node.callee, "it");
|
|
3965
|
+
}
|
|
3966
|
+
});
|
|
3967
|
+
}
|
|
3968
|
+
},
|
|
3969
|
+
ImportDeclaration(node) {
|
|
3970
|
+
for (const specifier of node.specifiers) {
|
|
3971
|
+
if (specifier.type === AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES.Identifier && specifier.imported.name === "it" && validatedPreference === "test") {
|
|
3972
|
+
return context.report({
|
|
3973
|
+
node,
|
|
3974
|
+
messageId: "message",
|
|
3975
|
+
data: {
|
|
3976
|
+
source: specifier.imported.name,
|
|
3977
|
+
preference: validatedPreference
|
|
3978
|
+
},
|
|
3979
|
+
fix(fixer) {
|
|
3980
|
+
const importedNames = node.specifiers.map((specifier2) => {
|
|
3981
|
+
return specifier2.type === AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
3982
|
+
});
|
|
3983
|
+
if (importedNames.includes("it") && importedNames.includes("test")) {
|
|
3984
|
+
const newSpecifiers = getImportSpecifiersAfterRemoving_default(
|
|
3985
|
+
context,
|
|
3986
|
+
node.specifiers,
|
|
3987
|
+
"it"
|
|
3988
|
+
);
|
|
3989
|
+
return fixer.replaceTextRange(
|
|
3990
|
+
[
|
|
3991
|
+
node.specifiers[0].range[0],
|
|
3992
|
+
node.specifiers[node.specifiers.length - 1].range[1]
|
|
3993
|
+
],
|
|
3994
|
+
newSpecifiers
|
|
3995
|
+
);
|
|
3996
|
+
}
|
|
3997
|
+
return fixer.replaceTextRange(
|
|
3998
|
+
[specifier.imported.range[0], specifier.imported.range[1]],
|
|
3999
|
+
validatedPreference
|
|
4000
|
+
);
|
|
4001
|
+
}
|
|
4002
|
+
});
|
|
4003
|
+
}
|
|
4004
|
+
if (specifier.type === AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES.Identifier && specifier.imported.name === "test" && validatedPreference === "it") {
|
|
4005
|
+
return context.report({
|
|
4006
|
+
node,
|
|
4007
|
+
messageId: "message",
|
|
4008
|
+
data: {
|
|
4009
|
+
source: specifier.imported.name,
|
|
4010
|
+
preference: validatedPreference
|
|
4011
|
+
},
|
|
4012
|
+
fix(fixer) {
|
|
4013
|
+
const importedNames = node.specifiers.map((specifier2) => {
|
|
4014
|
+
return specifier2.type === AST_NODE_TYPES.ImportSpecifier && specifier2.imported.type === AST_NODE_TYPES.Identifier ? specifier2.imported.name : "";
|
|
4015
|
+
});
|
|
4016
|
+
if (importedNames.includes("it") && importedNames.includes("test")) {
|
|
4017
|
+
const newSpecifiers = getImportSpecifiersAfterRemoving_default(
|
|
4018
|
+
context,
|
|
4019
|
+
node.specifiers,
|
|
4020
|
+
"test"
|
|
4021
|
+
);
|
|
4022
|
+
return fixer.replaceTextRange(
|
|
4023
|
+
[
|
|
4024
|
+
node.specifiers[0].range[0],
|
|
4025
|
+
node.specifiers[node.specifiers.length - 1].range[1]
|
|
4026
|
+
],
|
|
4027
|
+
newSpecifiers
|
|
4028
|
+
);
|
|
4029
|
+
}
|
|
4030
|
+
return fixer.replaceTextRange(
|
|
4031
|
+
[specifier.imported.range[0], specifier.imported.range[1]],
|
|
4032
|
+
validatedPreference
|
|
4033
|
+
);
|
|
4034
|
+
}
|
|
4035
|
+
});
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
};
|
|
4040
|
+
}
|
|
4041
|
+
});
|
|
4042
|
+
var consistent_test_function_default = consistentTestFunction;
|
|
4043
|
+
|
|
3890
4044
|
// src/utility/checkCallExpression.ts
|
|
3891
|
-
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
4045
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES2 } from "@typescript-eslint/utils";
|
|
3892
4046
|
function checkCallExpression(node, objectName, propertyName) {
|
|
3893
|
-
return node.callee.type ===
|
|
4047
|
+
return node.callee.type === AST_NODE_TYPES2.MemberExpression && node.callee.object.type === AST_NODE_TYPES2.Identifier && node.callee.object.name === objectName && node.callee.property.type === AST_NODE_TYPES2.Identifier && node.callee.property.name === propertyName;
|
|
3894
4048
|
}
|
|
3895
4049
|
var checkCallExpression_default = checkCallExpression;
|
|
3896
4050
|
|
|
@@ -4138,7 +4292,7 @@ var noSkippedTests = create_rule_default({
|
|
|
4138
4292
|
var no_skipped_tests_default = noSkippedTests;
|
|
4139
4293
|
|
|
4140
4294
|
// src/rules/use-object-shorthand.ts
|
|
4141
|
-
import { AST_NODE_TYPES as
|
|
4295
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/utils";
|
|
4142
4296
|
var useObjectShorthand = create_rule_default({
|
|
4143
4297
|
name: "use-object-shorthand",
|
|
4144
4298
|
meta: {
|
|
@@ -4156,7 +4310,7 @@ var useObjectShorthand = create_rule_default({
|
|
|
4156
4310
|
create(context) {
|
|
4157
4311
|
return {
|
|
4158
4312
|
Property(node) {
|
|
4159
|
-
if (node.key.type ===
|
|
4313
|
+
if (node.key.type === AST_NODE_TYPES3.Identifier && node.value.type === AST_NODE_TYPES3.Identifier && node.key.name === node.value.name && !node.shorthand) {
|
|
4160
4314
|
context.report({
|
|
4161
4315
|
node,
|
|
4162
4316
|
messageId: "useShorthand",
|
|
@@ -4177,6 +4331,7 @@ var use_object_shorthand_default = useObjectShorthand;
|
|
|
4177
4331
|
|
|
4178
4332
|
// src/rules/index.ts
|
|
4179
4333
|
var rules_default = {
|
|
4334
|
+
"consistent-test-function": consistent_test_function_default,
|
|
4180
4335
|
"no-isolated-tests": no_isolated_tests_default,
|
|
4181
4336
|
"no-namespace-imports": no_namespace_imports_default,
|
|
4182
4337
|
"no-plugin-configs-access-from-src-configs": no_plugin_configs_access_from_src_configs_default,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/eslint-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"vitest": "^3.2.4"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"common-tags": "^1.8.2"
|
|
56
|
+
"common-tags": "^1.8.2",
|
|
57
|
+
"zod": "^4.1.5"
|
|
57
58
|
}
|
|
58
59
|
}
|