@alextheman/eslint-plugin 2.8.2 → 3.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 +144 -129
- package/dist/index.d.cts +32 -28
- package/dist/index.d.ts +32 -28
- package/dist/index.js +137 -127
- package/package.json +13 -17
package/dist/index.js
CHANGED
|
@@ -3405,7 +3405,7 @@ var require_package = __commonJS({
|
|
|
3405
3405
|
"node_modules/@eslint/js/package.json"(exports, module) {
|
|
3406
3406
|
module.exports = {
|
|
3407
3407
|
name: "@eslint/js",
|
|
3408
|
-
version: "9.
|
|
3408
|
+
version: "9.39.1",
|
|
3409
3409
|
description: "ESLint JavaScript language implementation",
|
|
3410
3410
|
funding: "https://eslint.org/donate",
|
|
3411
3411
|
main: "./src/index.js",
|
|
@@ -3447,7 +3447,7 @@ var require_eslint_all = __commonJS({
|
|
|
3447
3447
|
"node_modules/@eslint/js/src/configs/eslint-all.js"(exports, module) {
|
|
3448
3448
|
"use strict";
|
|
3449
3449
|
module.exports = Object.freeze({
|
|
3450
|
-
|
|
3450
|
+
rules: Object.freeze({
|
|
3451
3451
|
"accessor-pairs": "error",
|
|
3452
3452
|
"array-callback-return": "error",
|
|
3453
3453
|
"arrow-body-style": "error",
|
|
@@ -3631,6 +3631,7 @@ var require_eslint_all = __commonJS({
|
|
|
3631
3631
|
"prefer-rest-params": "error",
|
|
3632
3632
|
"prefer-spread": "error",
|
|
3633
3633
|
"prefer-template": "error",
|
|
3634
|
+
"preserve-caught-error": "error",
|
|
3634
3635
|
"radix": "error",
|
|
3635
3636
|
"require-atomic-updates": "error",
|
|
3636
3637
|
"require-await": "error",
|
|
@@ -3646,7 +3647,7 @@ var require_eslint_all = __commonJS({
|
|
|
3646
3647
|
"valid-typeof": "error",
|
|
3647
3648
|
"vars-on-top": "error",
|
|
3648
3649
|
"yoda": "error"
|
|
3649
|
-
}
|
|
3650
|
+
})
|
|
3650
3651
|
});
|
|
3651
3652
|
}
|
|
3652
3653
|
});
|
|
@@ -3743,7 +3744,7 @@ var require_src = __commonJS({
|
|
|
3743
3744
|
|
|
3744
3745
|
// package.json
|
|
3745
3746
|
var name = "@alextheman/eslint-plugin";
|
|
3746
|
-
var version = "
|
|
3747
|
+
var version = "3.0.0";
|
|
3747
3748
|
|
|
3748
3749
|
// src/configs/index.ts
|
|
3749
3750
|
import packageJson from "eslint-plugin-package-json";
|
|
@@ -3844,14 +3845,14 @@ var import_js = __toESM(require_src(), 1);
|
|
|
3844
3845
|
import prettierConfig from "eslint-config-prettier";
|
|
3845
3846
|
import importPlugin from "eslint-plugin-import";
|
|
3846
3847
|
|
|
3847
|
-
// src/configs/
|
|
3848
|
+
// src/configs/helpers/javaScriptLanguageOptions.ts
|
|
3848
3849
|
var import_globals2 = __toESM(require_globals2(), 1);
|
|
3849
3850
|
var javaScriptLanguageOptions = {
|
|
3850
3851
|
globals: __spreadValues(__spreadValues(__spreadValues({}, import_globals2.default.node), import_globals2.default.browser), import_globals2.default.vitest)
|
|
3851
3852
|
};
|
|
3852
3853
|
var javaScriptLanguageOptions_default = javaScriptLanguageOptions;
|
|
3853
3854
|
|
|
3854
|
-
// src/configs/
|
|
3855
|
+
// src/configs/helpers/unusedVarsIgnorePatterns.ts
|
|
3855
3856
|
var unusedVarsIgnorePatterns = {
|
|
3856
3857
|
argsIgnorePattern: "^_",
|
|
3857
3858
|
caughtErrorsIgnorePattern: "^_",
|
|
@@ -3910,7 +3911,7 @@ var javaScriptBase_default = javaScriptBase;
|
|
|
3910
3911
|
import perfectionist from "eslint-plugin-perfectionist";
|
|
3911
3912
|
import prettierPlugin from "eslint-plugin-prettier";
|
|
3912
3913
|
|
|
3913
|
-
// src/configs/
|
|
3914
|
+
// src/configs/helpers/prettierRules.ts
|
|
3914
3915
|
var prettierRules = {
|
|
3915
3916
|
printWidth: 100
|
|
3916
3917
|
};
|
|
@@ -3993,10 +3994,20 @@ var javaScriptBase_default3 = createCombinedJavaScriptBaseConfig;
|
|
|
3993
3994
|
// src/configs/general/reactBase.ts
|
|
3994
3995
|
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
3995
3996
|
import reactPlugin from "eslint-plugin-react";
|
|
3996
|
-
import reactHooks from "eslint-plugin-react-hooks";
|
|
3997
3997
|
import reactRefresh from "eslint-plugin-react-refresh";
|
|
3998
3998
|
|
|
3999
|
-
// src/configs/
|
|
3999
|
+
// src/configs/helpers/reactHooks.ts
|
|
4000
|
+
import { omitProperties } from "@alextheman/utility";
|
|
4001
|
+
import reactHooksPlugin from "eslint-plugin-react-hooks";
|
|
4002
|
+
var reactHooks = __spreadProps(__spreadValues({}, reactHooksPlugin), {
|
|
4003
|
+
configs: __spreadProps(__spreadValues({}, omitProperties(reactHooksPlugin.configs, "flat")), {
|
|
4004
|
+
"flat/recommended": reactHooksPlugin.configs.flat.recommended,
|
|
4005
|
+
"flat/recommended-latest": reactHooksPlugin.configs.flat["recommended-latest"]
|
|
4006
|
+
})
|
|
4007
|
+
});
|
|
4008
|
+
var reactHooks_default = reactHooks;
|
|
4009
|
+
|
|
4010
|
+
// src/configs/helpers/reactLanguageOptions.ts
|
|
4000
4011
|
var import_globals3 = __toESM(require_globals2(), 1);
|
|
4001
4012
|
var reactLanguageOptions = {
|
|
4002
4013
|
ecmaVersion: 2020,
|
|
@@ -4019,10 +4030,10 @@ var reactBase = [
|
|
|
4019
4030
|
name: "@alextheman/general/react",
|
|
4020
4031
|
plugins: {
|
|
4021
4032
|
react: reactPlugin,
|
|
4022
|
-
"react-hooks":
|
|
4033
|
+
"react-hooks": reactHooks_default,
|
|
4023
4034
|
"react-refresh": reactRefresh
|
|
4024
4035
|
},
|
|
4025
|
-
rules: __spreadProps(__spreadValues({},
|
|
4036
|
+
rules: __spreadProps(__spreadValues({}, reactHooks_default.configs["flat/recommended"].rules), {
|
|
4026
4037
|
"react/destructuring-assignment": ["error", "always", { destructureInSignature: "always" }],
|
|
4027
4038
|
"react/hook-use-state": "error",
|
|
4028
4039
|
"react/jsx-curly-brace-presence": [
|
|
@@ -4044,7 +4055,6 @@ var reactBase_default = reactBase;
|
|
|
4044
4055
|
|
|
4045
4056
|
// src/configs/personal/reactBase.ts
|
|
4046
4057
|
import reactPlugin2 from "eslint-plugin-react";
|
|
4047
|
-
import reactHooks2 from "eslint-plugin-react-hooks";
|
|
4048
4058
|
import reactRefresh2 from "eslint-plugin-react-refresh";
|
|
4049
4059
|
var personalReactBaseConfig = [
|
|
4050
4060
|
{
|
|
@@ -4052,7 +4062,7 @@ var personalReactBaseConfig = [
|
|
|
4052
4062
|
name: "@alextheman/personal/react",
|
|
4053
4063
|
plugins: {
|
|
4054
4064
|
react: reactPlugin2,
|
|
4055
|
-
"react-hooks":
|
|
4065
|
+
"react-hooks": reactHooks_default,
|
|
4056
4066
|
"react-refresh": reactRefresh2
|
|
4057
4067
|
},
|
|
4058
4068
|
rules: {
|
|
@@ -4094,12 +4104,12 @@ function createCombinedJavaScriptReactBaseConfig(plugin) {
|
|
|
4094
4104
|
var javaScriptReactBase_default = createCombinedJavaScriptReactBaseConfig;
|
|
4095
4105
|
|
|
4096
4106
|
// src/configs/general/typeScriptBase.ts
|
|
4097
|
-
import
|
|
4107
|
+
import tseslint2 from "typescript-eslint";
|
|
4098
4108
|
|
|
4099
|
-
// src/configs/
|
|
4100
|
-
import
|
|
4109
|
+
// src/configs/helpers/typeScriptLanguageOptions.ts
|
|
4110
|
+
import tseslint from "typescript-eslint";
|
|
4101
4111
|
var typeScriptLanguageOptions = {
|
|
4102
|
-
parser:
|
|
4112
|
+
parser: tseslint.parser,
|
|
4103
4113
|
parserOptions: {
|
|
4104
4114
|
ecmaVersion: "latest",
|
|
4105
4115
|
projectService: true,
|
|
@@ -4111,7 +4121,7 @@ var typeScriptLanguageOptions_default = typeScriptLanguageOptions;
|
|
|
4111
4121
|
|
|
4112
4122
|
// src/configs/general/typeScriptBase.ts
|
|
4113
4123
|
var typeScriptBase = [
|
|
4114
|
-
...
|
|
4124
|
+
...tseslint2.configs.recommended,
|
|
4115
4125
|
...javaScriptBase_default,
|
|
4116
4126
|
{
|
|
4117
4127
|
files: ["**/*.ts", "**/*.tsx"],
|
|
@@ -4140,7 +4150,7 @@ var typeScriptBase_default = typeScriptBase;
|
|
|
4140
4150
|
// src/configs/personal/eslintPlugin.ts
|
|
4141
4151
|
import perfectionist2 from "eslint-plugin-perfectionist";
|
|
4142
4152
|
|
|
4143
|
-
// src/configs/
|
|
4153
|
+
// src/configs/helpers/sortObjects.ts
|
|
4144
4154
|
var sortObjects = {
|
|
4145
4155
|
customGroups: [],
|
|
4146
4156
|
destructuredObjects: true,
|
|
@@ -4179,20 +4189,25 @@ function createPersonalEslintPluginConfig(plugin) {
|
|
|
4179
4189
|
"no-restricted-imports": [
|
|
4180
4190
|
"error",
|
|
4181
4191
|
{
|
|
4182
|
-
paths: [
|
|
4183
|
-
|
|
4192
|
+
paths: [
|
|
4193
|
+
...["src/alexPlugin", "src/index", "src"].map((name2) => {
|
|
4194
|
+
return {
|
|
4195
|
+
importNames: ["default"],
|
|
4196
|
+
message: "Do not import the plugin directly from the config files. Please create a function that takes in the plugin and returns the config instead.",
|
|
4197
|
+
name: name2
|
|
4198
|
+
};
|
|
4199
|
+
}),
|
|
4200
|
+
{
|
|
4184
4201
|
importNames: ["default"],
|
|
4185
|
-
message:
|
|
4186
|
-
name:
|
|
4187
|
-
}
|
|
4188
|
-
|
|
4202
|
+
message: 'Please import from "src/configs/helpers/reactHooks" instead.',
|
|
4203
|
+
name: "eslint-plugin-react-hooks"
|
|
4204
|
+
}
|
|
4205
|
+
]
|
|
4189
4206
|
}
|
|
4190
4207
|
]
|
|
4191
4208
|
}
|
|
4192
4209
|
},
|
|
4193
4210
|
{
|
|
4194
|
-
// Since the object exported in the rules index serves the same function as the exports in other projects, it's best to sort them in alphabetical order
|
|
4195
|
-
// as well to make it easier to compare against the file directory.
|
|
4196
4211
|
files: ["src/rules/index.ts", "src/configs/**"],
|
|
4197
4212
|
rules: {
|
|
4198
4213
|
"perfectionist/sort-objects": ["error", sortObjects_default]
|
|
@@ -4298,7 +4313,7 @@ var neurosongsFrontEndConfig = [
|
|
|
4298
4313
|
var neurosongsFrontEnd_default = neurosongsFrontEndConfig;
|
|
4299
4314
|
|
|
4300
4315
|
// src/configs/personal/typeScriptBase.ts
|
|
4301
|
-
import
|
|
4316
|
+
import tseslint3 from "typescript-eslint";
|
|
4302
4317
|
function createPersonalTypeScriptBaseConfig(plugin) {
|
|
4303
4318
|
return [
|
|
4304
4319
|
{
|
|
@@ -4307,7 +4322,7 @@ function createPersonalTypeScriptBaseConfig(plugin) {
|
|
|
4307
4322
|
name: "@alextheman/personal/typescript",
|
|
4308
4323
|
plugins: {
|
|
4309
4324
|
"@alextheman": plugin,
|
|
4310
|
-
"@typescript-eslint":
|
|
4325
|
+
"@typescript-eslint": tseslint3.plugin
|
|
4311
4326
|
},
|
|
4312
4327
|
rules: {
|
|
4313
4328
|
"@alextheman/standardise-error-messages": "error",
|
|
@@ -4325,12 +4340,12 @@ function createPersonalTypeScriptBaseConfig(plugin) {
|
|
|
4325
4340
|
var typeScriptBase_default2 = createPersonalTypeScriptBaseConfig;
|
|
4326
4341
|
|
|
4327
4342
|
// src/configs/personal/utility.ts
|
|
4328
|
-
import
|
|
4343
|
+
import tseslint4 from "typescript-eslint";
|
|
4329
4344
|
var utilityConfig = [
|
|
4330
4345
|
{
|
|
4331
4346
|
name: "@alextheman/personal/utility",
|
|
4332
4347
|
plugins: {
|
|
4333
|
-
"@typescript-eslint":
|
|
4348
|
+
"@typescript-eslint": tseslint4.plugin
|
|
4334
4349
|
},
|
|
4335
4350
|
rules: {
|
|
4336
4351
|
"@typescript-eslint/explicit-module-boundary-types": "error"
|
|
@@ -4448,7 +4463,7 @@ var configs_default = createAlexPluginConfigs;
|
|
|
4448
4463
|
|
|
4449
4464
|
// src/rules/consistent-test-function.ts
|
|
4450
4465
|
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
4451
|
-
import
|
|
4466
|
+
import z2 from "zod";
|
|
4452
4467
|
|
|
4453
4468
|
// src/createRule.ts
|
|
4454
4469
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
@@ -4457,6 +4472,14 @@ var createRule = ESLintUtils.RuleCreator((ruleName) => {
|
|
|
4457
4472
|
});
|
|
4458
4473
|
var createRule_default = createRule;
|
|
4459
4474
|
|
|
4475
|
+
// src/utility/createRuleSchema.ts
|
|
4476
|
+
import { omitProperties as omitProperties2 } from "@alextheman/utility";
|
|
4477
|
+
import z from "zod";
|
|
4478
|
+
function createRuleSchema(schema6) {
|
|
4479
|
+
return [omitProperties2(z.toJSONSchema(schema6), "$schema")];
|
|
4480
|
+
}
|
|
4481
|
+
var createRuleSchema_default = createRuleSchema;
|
|
4482
|
+
|
|
4460
4483
|
// src/utility/getImportSpecifiersAfterRemoving.ts
|
|
4461
4484
|
function getImportSpecifiersAfterRemoving(context, specifiers, importToRemove) {
|
|
4462
4485
|
return specifiers.filter((specifier) => {
|
|
@@ -4468,10 +4491,17 @@ function getImportSpecifiersAfterRemoving(context, specifiers, importToRemove) {
|
|
|
4468
4491
|
var getImportSpecifiersAfterRemoving_default = getImportSpecifiersAfterRemoving;
|
|
4469
4492
|
|
|
4470
4493
|
// src/rules/consistent-test-function.ts
|
|
4471
|
-
var validTestFunctionsSchema =
|
|
4494
|
+
var validTestFunctionsSchema = z2.enum(["test", "it"]);
|
|
4472
4495
|
function parseTestFunction(data) {
|
|
4473
4496
|
return validTestFunctionsSchema.parse(data);
|
|
4474
4497
|
}
|
|
4498
|
+
var consistentTestFunctionOptionsSchema = z2.object({
|
|
4499
|
+
preference: validTestFunctionsSchema
|
|
4500
|
+
}).partial();
|
|
4501
|
+
function parseConsistentTestFunctionOptions(data) {
|
|
4502
|
+
return consistentTestFunctionOptionsSchema.parse(data);
|
|
4503
|
+
}
|
|
4504
|
+
var schema = createRuleSchema_default(consistentTestFunctionOptionsSchema);
|
|
4475
4505
|
var consistentTestFunction = createRule_default({
|
|
4476
4506
|
name: "consistent-test-function",
|
|
4477
4507
|
meta: {
|
|
@@ -4483,46 +4513,36 @@ var consistentTestFunction = createRule_default({
|
|
|
4483
4513
|
},
|
|
4484
4514
|
type: "suggestion",
|
|
4485
4515
|
fixable: "code",
|
|
4486
|
-
schema
|
|
4487
|
-
{
|
|
4488
|
-
type: "object",
|
|
4489
|
-
properties: {
|
|
4490
|
-
preference: {
|
|
4491
|
-
type: "string",
|
|
4492
|
-
enum: ["it", "test"]
|
|
4493
|
-
}
|
|
4494
|
-
},
|
|
4495
|
-
additionalProperties: false
|
|
4496
|
-
}
|
|
4497
|
-
]
|
|
4516
|
+
schema
|
|
4498
4517
|
},
|
|
4499
4518
|
defaultOptions: [{ preference: "test" }],
|
|
4500
4519
|
create(context) {
|
|
4501
4520
|
var _a;
|
|
4502
|
-
const preference = (
|
|
4503
|
-
|
|
4521
|
+
const { preference } = parseConsistentTestFunctionOptions(
|
|
4522
|
+
(_a = context.options[0]) != null ? _a : { preference: "test" }
|
|
4523
|
+
);
|
|
4504
4524
|
return {
|
|
4505
4525
|
CallExpression(node) {
|
|
4506
|
-
if (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "it" &&
|
|
4526
|
+
if (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "it" && preference === "test") {
|
|
4507
4527
|
return context.report({
|
|
4508
4528
|
node,
|
|
4509
4529
|
messageId: "message",
|
|
4510
4530
|
data: {
|
|
4511
4531
|
source: node.callee.name,
|
|
4512
|
-
preference
|
|
4532
|
+
preference
|
|
4513
4533
|
},
|
|
4514
4534
|
fix(fixer) {
|
|
4515
4535
|
return fixer.replaceText(node.callee, "test");
|
|
4516
4536
|
}
|
|
4517
4537
|
});
|
|
4518
4538
|
}
|
|
4519
|
-
if (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "test" &&
|
|
4539
|
+
if (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "test" && preference === "it") {
|
|
4520
4540
|
return context.report({
|
|
4521
4541
|
node,
|
|
4522
4542
|
messageId: "message",
|
|
4523
4543
|
data: {
|
|
4524
4544
|
source: node.callee.name,
|
|
4525
|
-
preference
|
|
4545
|
+
preference
|
|
4526
4546
|
},
|
|
4527
4547
|
fix(fixer) {
|
|
4528
4548
|
return fixer.replaceText(node.callee, "it");
|
|
@@ -4532,13 +4552,13 @@ var consistentTestFunction = createRule_default({
|
|
|
4532
4552
|
},
|
|
4533
4553
|
ImportDeclaration(node) {
|
|
4534
4554
|
for (const specifier of node.specifiers) {
|
|
4535
|
-
if (specifier.type === AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES.Identifier && specifier.imported.name === "it" &&
|
|
4555
|
+
if (specifier.type === AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES.Identifier && specifier.imported.name === "it" && preference === "test") {
|
|
4536
4556
|
return context.report({
|
|
4537
4557
|
node,
|
|
4538
4558
|
messageId: "message",
|
|
4539
4559
|
data: {
|
|
4540
4560
|
source: specifier.imported.name,
|
|
4541
|
-
preference
|
|
4561
|
+
preference
|
|
4542
4562
|
},
|
|
4543
4563
|
fix(fixer) {
|
|
4544
4564
|
const importedNames = node.specifiers.map((specifier2) => {
|
|
@@ -4560,18 +4580,18 @@ var consistentTestFunction = createRule_default({
|
|
|
4560
4580
|
}
|
|
4561
4581
|
return fixer.replaceTextRange(
|
|
4562
4582
|
[specifier.imported.range[0], specifier.imported.range[1]],
|
|
4563
|
-
|
|
4583
|
+
preference
|
|
4564
4584
|
);
|
|
4565
4585
|
}
|
|
4566
4586
|
});
|
|
4567
4587
|
}
|
|
4568
|
-
if (specifier.type === AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES.Identifier && specifier.imported.name === "test" &&
|
|
4588
|
+
if (specifier.type === AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES.Identifier && specifier.imported.name === "test" && preference === "it") {
|
|
4569
4589
|
return context.report({
|
|
4570
4590
|
node,
|
|
4571
4591
|
messageId: "message",
|
|
4572
4592
|
data: {
|
|
4573
4593
|
source: specifier.imported.name,
|
|
4574
|
-
preference
|
|
4594
|
+
preference
|
|
4575
4595
|
},
|
|
4576
4596
|
fix(fixer) {
|
|
4577
4597
|
const importedNames = node.specifiers.map((specifier2) => {
|
|
@@ -4593,7 +4613,7 @@ var consistentTestFunction = createRule_default({
|
|
|
4593
4613
|
}
|
|
4594
4614
|
return fixer.replaceTextRange(
|
|
4595
4615
|
[specifier.imported.range[0], specifier.imported.range[1]],
|
|
4596
|
-
|
|
4616
|
+
preference
|
|
4597
4617
|
);
|
|
4598
4618
|
}
|
|
4599
4619
|
});
|
|
@@ -4645,6 +4665,14 @@ var noIsolatedTests = createRule_default({
|
|
|
4645
4665
|
var no_isolated_tests_default = noIsolatedTests;
|
|
4646
4666
|
|
|
4647
4667
|
// src/rules/no-namespace-imports.ts
|
|
4668
|
+
import z3 from "zod";
|
|
4669
|
+
var noNamespaceImportsOptionsSchema = z3.object({
|
|
4670
|
+
allow: z3.array(z3.string())
|
|
4671
|
+
}).partial();
|
|
4672
|
+
function parseNoNamespaceImportsOptions(data) {
|
|
4673
|
+
return noNamespaceImportsOptionsSchema.parse(data);
|
|
4674
|
+
}
|
|
4675
|
+
var schema2 = createRuleSchema_default(noNamespaceImportsOptionsSchema);
|
|
4648
4676
|
var noNamespaceImports = createRule_default({
|
|
4649
4677
|
name: "no-namespace-imports",
|
|
4650
4678
|
meta: {
|
|
@@ -4655,31 +4683,17 @@ var noNamespaceImports = createRule_default({
|
|
|
4655
4683
|
message: 'Import * from "{{source}}" is not allowed. Please use named imports instead.'
|
|
4656
4684
|
},
|
|
4657
4685
|
type: "suggestion",
|
|
4658
|
-
schema:
|
|
4659
|
-
{
|
|
4660
|
-
type: "object",
|
|
4661
|
-
properties: {
|
|
4662
|
-
allow: {
|
|
4663
|
-
type: "array",
|
|
4664
|
-
items: {
|
|
4665
|
-
type: "string"
|
|
4666
|
-
},
|
|
4667
|
-
uniqueItems: true
|
|
4668
|
-
}
|
|
4669
|
-
},
|
|
4670
|
-
additionalProperties: false
|
|
4671
|
-
}
|
|
4672
|
-
]
|
|
4686
|
+
schema: schema2
|
|
4673
4687
|
},
|
|
4674
4688
|
defaultOptions: [{ allow: [""] }],
|
|
4675
4689
|
create(context) {
|
|
4676
4690
|
var _a;
|
|
4677
|
-
const
|
|
4691
|
+
const { allow } = parseNoNamespaceImportsOptions((_a = context.options[0]) != null ? _a : { allow: [] });
|
|
4678
4692
|
return {
|
|
4679
4693
|
ImportDeclaration(node) {
|
|
4680
4694
|
const allSpecifiers = node.specifiers;
|
|
4681
4695
|
for (const specifier of allSpecifiers) {
|
|
4682
|
-
if (specifier.type === "ImportNamespaceSpecifier" && !(
|
|
4696
|
+
if (specifier.type === "ImportNamespaceSpecifier" && !(allow == null ? void 0 : allow.includes(node.source.value))) {
|
|
4683
4697
|
context.report({
|
|
4684
4698
|
node,
|
|
4685
4699
|
messageId: "message",
|
|
@@ -4732,6 +4746,14 @@ var noPluginConfigAccessFromSrcConfigs = createRule_default({
|
|
|
4732
4746
|
var no_plugin_configs_access_from_src_configs_default = noPluginConfigAccessFromSrcConfigs;
|
|
4733
4747
|
|
|
4734
4748
|
// src/rules/no-relative-imports.ts
|
|
4749
|
+
import z4 from "zod";
|
|
4750
|
+
var noRelativeImportsOptionsSchema = z4.object({
|
|
4751
|
+
depth: z4.int().nonnegative()
|
|
4752
|
+
}).partial();
|
|
4753
|
+
function parseNoRelativeImportsOptions(data) {
|
|
4754
|
+
return noRelativeImportsOptionsSchema.parse(data);
|
|
4755
|
+
}
|
|
4756
|
+
var schema3 = createRuleSchema_default(noRelativeImportsOptionsSchema);
|
|
4735
4757
|
var noRelativeImports = createRule_default({
|
|
4736
4758
|
name: "no-relative-imports",
|
|
4737
4759
|
meta: {
|
|
@@ -4743,34 +4765,16 @@ var noRelativeImports = createRule_default({
|
|
|
4743
4765
|
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}}?!"
|
|
4744
4766
|
},
|
|
4745
4767
|
type: "suggestion",
|
|
4746
|
-
schema:
|
|
4747
|
-
{
|
|
4748
|
-
type: "object",
|
|
4749
|
-
properties: {
|
|
4750
|
-
depth: {
|
|
4751
|
-
type: "number"
|
|
4752
|
-
}
|
|
4753
|
-
},
|
|
4754
|
-
additionalProperties: false
|
|
4755
|
-
}
|
|
4756
|
-
]
|
|
4768
|
+
schema: schema3
|
|
4757
4769
|
},
|
|
4758
4770
|
defaultOptions: [{ depth: void 0 }],
|
|
4759
4771
|
create(context) {
|
|
4760
4772
|
var _a;
|
|
4761
|
-
const
|
|
4762
|
-
if (allowedDepth !== void 0) {
|
|
4763
|
-
if (allowedDepth % 1 !== 0) {
|
|
4764
|
-
throw new Error("NON_INTEGER_DEPTH_NOT_ALLOWED");
|
|
4765
|
-
}
|
|
4766
|
-
if (allowedDepth < 0) {
|
|
4767
|
-
throw new Error("NEGATIVE_DEPTH_NOT_ALLOWED");
|
|
4768
|
-
}
|
|
4769
|
-
}
|
|
4773
|
+
const { depth } = parseNoRelativeImportsOptions((_a = context.options[0]) != null ? _a : { depth: void 0 });
|
|
4770
4774
|
return {
|
|
4771
4775
|
ImportDeclaration(node) {
|
|
4772
4776
|
if (node.source.value.includes("./") || node.source.value.includes("../")) {
|
|
4773
|
-
if (
|
|
4777
|
+
if (depth === void 0) {
|
|
4774
4778
|
return context.report({
|
|
4775
4779
|
node,
|
|
4776
4780
|
messageId: "strictNoRelative",
|
|
@@ -4798,18 +4802,18 @@ var noRelativeImports = createRule_default({
|
|
|
4798
4802
|
}
|
|
4799
4803
|
});
|
|
4800
4804
|
}
|
|
4801
|
-
if (
|
|
4805
|
+
if (depth === 0 && importPathParts[0] === ".") {
|
|
4802
4806
|
return;
|
|
4803
4807
|
}
|
|
4804
4808
|
let endOfRelativePathFound = false;
|
|
4805
|
-
for (const part of importPathParts.slice(0,
|
|
4809
|
+
for (const part of importPathParts.slice(0, depth + 1)) {
|
|
4806
4810
|
if (part !== "..") {
|
|
4807
4811
|
endOfRelativePathFound = true;
|
|
4808
4812
|
break;
|
|
4809
4813
|
}
|
|
4810
4814
|
}
|
|
4811
4815
|
if (!endOfRelativePathFound) {
|
|
4812
|
-
if (
|
|
4816
|
+
if (depth === 0) {
|
|
4813
4817
|
return context.report({
|
|
4814
4818
|
node,
|
|
4815
4819
|
messageId: "rootOnly",
|
|
@@ -4823,8 +4827,8 @@ var noRelativeImports = createRule_default({
|
|
|
4823
4827
|
messageId: "exceededAllowedDepth",
|
|
4824
4828
|
data: {
|
|
4825
4829
|
source: node.source.value,
|
|
4826
|
-
depth
|
|
4827
|
-
s:
|
|
4830
|
+
depth,
|
|
4831
|
+
s: depth !== 1 ? "s" : ""
|
|
4828
4832
|
}
|
|
4829
4833
|
});
|
|
4830
4834
|
}
|
|
@@ -4869,9 +4873,20 @@ var no_skipped_tests_default = noSkippedTests;
|
|
|
4869
4873
|
|
|
4870
4874
|
// src/rules/standardise-error-messages.ts
|
|
4871
4875
|
import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/utils";
|
|
4876
|
+
import z5 from "zod";
|
|
4877
|
+
var standardiseErrorMessagesOptionsSchema = z5.object({
|
|
4878
|
+
regex: z5.string()
|
|
4879
|
+
}).partial();
|
|
4880
|
+
function parseStandardiseErrorMessagesOptions(data) {
|
|
4881
|
+
return standardiseErrorMessagesOptionsSchema.parse(data);
|
|
4882
|
+
}
|
|
4883
|
+
var schema4 = createRuleSchema_default(standardiseErrorMessagesOptionsSchema);
|
|
4884
|
+
var defaultErrorRegex = "^[A-Z]+(?:_[A-Z]+)*$";
|
|
4872
4885
|
function checkCurrentNode(context, node) {
|
|
4873
|
-
var _a
|
|
4874
|
-
const errorRegex =
|
|
4886
|
+
var _a;
|
|
4887
|
+
const { regex: errorRegex = defaultErrorRegex } = parseStandardiseErrorMessagesOptions(
|
|
4888
|
+
(_a = context.options[0]) != null ? _a : { regex: defaultErrorRegex }
|
|
4889
|
+
);
|
|
4875
4890
|
if (node.callee.type === AST_NODE_TYPES3.Identifier && node.callee.name === "Error") {
|
|
4876
4891
|
const [errorArgument] = node.arguments;
|
|
4877
4892
|
const errorMessage = errorArgument.type === AST_NODE_TYPES3.Literal ? errorArgument.value : "";
|
|
@@ -4897,19 +4912,9 @@ var standardiseErrorMessages = createRule_default({
|
|
|
4897
4912
|
message: "Expected error message {{error}} to match {{regex}}."
|
|
4898
4913
|
},
|
|
4899
4914
|
type: "suggestion",
|
|
4900
|
-
schema:
|
|
4901
|
-
{
|
|
4902
|
-
type: "object",
|
|
4903
|
-
properties: {
|
|
4904
|
-
regex: {
|
|
4905
|
-
type: "string"
|
|
4906
|
-
}
|
|
4907
|
-
},
|
|
4908
|
-
additionalProperties: false
|
|
4909
|
-
}
|
|
4910
|
-
]
|
|
4915
|
+
schema: schema4
|
|
4911
4916
|
},
|
|
4912
|
-
defaultOptions: [{ regex:
|
|
4917
|
+
defaultOptions: [{ regex: defaultErrorRegex }],
|
|
4913
4918
|
create(context) {
|
|
4914
4919
|
return {
|
|
4915
4920
|
CallExpression(node) {
|
|
@@ -4925,6 +4930,14 @@ var standardise_error_messages_default = standardiseErrorMessages;
|
|
|
4925
4930
|
|
|
4926
4931
|
// src/rules/use-normalized-imports.ts
|
|
4927
4932
|
import path from "path";
|
|
4933
|
+
import z6 from "zod";
|
|
4934
|
+
var useNormalizedImportsOptionsSchema = z6.object({
|
|
4935
|
+
fixable: z6.boolean()
|
|
4936
|
+
}).partial();
|
|
4937
|
+
function parseUseNormalizedImportsOptions(data) {
|
|
4938
|
+
return useNormalizedImportsOptionsSchema.parse(data);
|
|
4939
|
+
}
|
|
4940
|
+
var schema5 = createRuleSchema_default(useNormalizedImportsOptionsSchema);
|
|
4928
4941
|
var useNormalizedImports = createRule_default({
|
|
4929
4942
|
name: "use-normalized-imports",
|
|
4930
4943
|
meta: {
|
|
@@ -4935,23 +4948,15 @@ var useNormalizedImports = createRule_default({
|
|
|
4935
4948
|
pathNotNormalized: "Import path {{nonNormalized}} is not normalised. Please use {{normalized}} instead."
|
|
4936
4949
|
},
|
|
4937
4950
|
type: "suggestion",
|
|
4938
|
-
schema:
|
|
4939
|
-
{
|
|
4940
|
-
type: "object",
|
|
4941
|
-
properties: {
|
|
4942
|
-
fixable: {
|
|
4943
|
-
type: "boolean"
|
|
4944
|
-
}
|
|
4945
|
-
},
|
|
4946
|
-
additionalProperties: false
|
|
4947
|
-
}
|
|
4948
|
-
],
|
|
4951
|
+
schema: schema5,
|
|
4949
4952
|
fixable: "code"
|
|
4950
4953
|
},
|
|
4951
4954
|
defaultOptions: [{ fixable: true }],
|
|
4952
4955
|
create(context) {
|
|
4953
|
-
var _a
|
|
4954
|
-
const isFixable
|
|
4956
|
+
var _a;
|
|
4957
|
+
const { fixable: isFixable } = parseUseNormalizedImportsOptions(
|
|
4958
|
+
(_a = context.options[0]) != null ? _a : { fixable: true }
|
|
4959
|
+
);
|
|
4955
4960
|
return {
|
|
4956
4961
|
ImportDeclaration(node) {
|
|
4957
4962
|
const normalizedPath = path.posix.normalize(node.source.value);
|
|
@@ -5043,7 +5048,12 @@ var alexPlugin_default = alexPlugin;
|
|
|
5043
5048
|
var index_default = alexPlugin_default;
|
|
5044
5049
|
export {
|
|
5045
5050
|
index_default as default,
|
|
5051
|
+
parseConsistentTestFunctionOptions,
|
|
5052
|
+
parseNoNamespaceImportsOptions,
|
|
5053
|
+
parseNoRelativeImportsOptions,
|
|
5054
|
+
parseStandardiseErrorMessagesOptions,
|
|
5046
5055
|
parseTestFunction,
|
|
5056
|
+
parseUseNormalizedImportsOptions,
|
|
5047
5057
|
prettierRules_default as prettierRules,
|
|
5048
5058
|
sortObjects_default as sortObjects
|
|
5049
5059
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/eslint-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A package to provide custom ESLint rules and configs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"format-prettier": "npm run format-prettier-typescript && npm run format-prettier-javascript",
|
|
26
26
|
"format-prettier-javascript": "prettier --write \"./**/*.js\"",
|
|
27
27
|
"format-prettier-typescript": "prettier --write --parser typescript \"./**/*.ts\"",
|
|
28
|
-
"generate-rule-options-types": "tsx src/utility/generateRuleOptionsTypes.ts",
|
|
29
28
|
"lint": "tsx src/utility/checkConfigChanges.ts || npm run build && npm run lint-tsc && npm run lint-eslint && npm run lint-prettier",
|
|
30
29
|
"lint-eslint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\" \"package.json\"",
|
|
31
30
|
"lint-prettier": "npm run lint-prettier-typescript && npm run lint-prettier-javascript",
|
|
@@ -40,41 +39,38 @@
|
|
|
40
39
|
"dependencies": {
|
|
41
40
|
"@alextheman/utility": "^2.15.1",
|
|
42
41
|
"common-tags": "^1.8.2",
|
|
43
|
-
"eslint-plugin-package-json": "^0.64.0",
|
|
44
|
-
"json-schema-to-typescript": "^15.0.4",
|
|
45
42
|
"zod": "^4.1.12"
|
|
46
43
|
},
|
|
47
44
|
"devDependencies": {
|
|
48
45
|
"@types/common-tags": "^1.8.4",
|
|
49
46
|
"@types/eslint": "^9.6.1",
|
|
50
47
|
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
|
|
51
|
-
"@types/node": "^24.10.
|
|
52
|
-
"@typescript-eslint/rule-tester": "^8.46.
|
|
53
|
-
"@typescript-eslint/utils": "^8.46.
|
|
48
|
+
"@types/node": "^24.10.1",
|
|
49
|
+
"@typescript-eslint/rule-tester": "^8.46.4",
|
|
50
|
+
"@typescript-eslint/utils": "^8.46.4",
|
|
54
51
|
"eslint-plugin-eslint-plugin": "^7.2.0",
|
|
55
52
|
"globals": "^16.5.0",
|
|
56
53
|
"husky": "^9.1.7",
|
|
57
54
|
"jiti": "^2.6.1",
|
|
58
55
|
"prettier": "^3.6.2",
|
|
59
|
-
"tsup": "^8.5.
|
|
56
|
+
"tsup": "^8.5.1",
|
|
60
57
|
"tsx": "^4.20.6",
|
|
61
58
|
"typescript": "^5.9.3",
|
|
62
59
|
"vite-tsconfig-paths": "^5.1.4",
|
|
63
|
-
"vitest": "^4.0.
|
|
60
|
+
"vitest": "^4.0.9"
|
|
64
61
|
},
|
|
65
62
|
"peerDependencies": {
|
|
66
|
-
"
|
|
67
|
-
"@typescript-eslint/parser": "^8.37.0",
|
|
68
|
-
"eslint": "^9.31.0",
|
|
63
|
+
"eslint": "^9.39.1",
|
|
69
64
|
"eslint-config-prettier": "^10.1.8",
|
|
70
65
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
71
66
|
"eslint-plugin-import": "^2.32.0",
|
|
72
67
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
73
|
-
"eslint-plugin-
|
|
74
|
-
"eslint-plugin-
|
|
68
|
+
"eslint-plugin-package-json": "^0.74.0",
|
|
69
|
+
"eslint-plugin-perfectionist": "^4.15.1",
|
|
70
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
75
71
|
"eslint-plugin-react": "^7.37.5",
|
|
76
|
-
"eslint-plugin-react-hooks": "^
|
|
77
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
78
|
-
"typescript-eslint": "^8.
|
|
72
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
73
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
74
|
+
"typescript-eslint": "^8.46.4"
|
|
79
75
|
}
|
|
80
76
|
}
|