@alextheman/eslint-plugin 2.2.2 → 2.3.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 +80 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +80 -5
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -3715,7 +3715,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
3715
3715
|
|
|
3716
3716
|
// package.json
|
|
3717
3717
|
var name = "@alextheman/eslint-plugin";
|
|
3718
|
-
var version = "2.
|
|
3718
|
+
var version = "2.3.0";
|
|
3719
3719
|
|
|
3720
3720
|
// src/configs/general/javaScriptBase.ts
|
|
3721
3721
|
var import_js = __toESM(require_src(), 1);
|
|
@@ -3893,6 +3893,7 @@ function createCombinedJavaScriptBaseConfig(plugin) {
|
|
|
3893
3893
|
var javaScriptBase_default2 = createCombinedJavaScriptBaseConfig;
|
|
3894
3894
|
|
|
3895
3895
|
// src/configs/general/reactBase.ts
|
|
3896
|
+
var import_eslint_plugin_jsx_a11y = __toESM(require("eslint-plugin-jsx-a11y"), 1);
|
|
3896
3897
|
var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1);
|
|
3897
3898
|
var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1);
|
|
3898
3899
|
var import_eslint_plugin_react_refresh = __toESM(require("eslint-plugin-react-refresh"), 1);
|
|
@@ -3900,6 +3901,7 @@ var import_globals2 = __toESM(require_globals2(), 1);
|
|
|
3900
3901
|
var reactBase = [
|
|
3901
3902
|
import_eslint_plugin_react.default.configs.flat.recommended,
|
|
3902
3903
|
import_eslint_plugin_react.default.configs.flat["jsx-runtime"],
|
|
3904
|
+
import_eslint_plugin_jsx_a11y.default.flatConfigs.recommended,
|
|
3903
3905
|
{
|
|
3904
3906
|
languageOptions: {
|
|
3905
3907
|
ecmaVersion: 2020,
|
|
@@ -3930,6 +3932,15 @@ var reactBase = [
|
|
|
3930
3932
|
],
|
|
3931
3933
|
"react-hooks/exhaustive-deps": "off",
|
|
3932
3934
|
"react-refresh/only-export-components": "off",
|
|
3935
|
+
"react/destructuring-assignment": ["error", "always", { destructureInSignature: "always" }],
|
|
3936
|
+
"react/hook-use-state": "error",
|
|
3937
|
+
"react/jsx-boolean-value": "error",
|
|
3938
|
+
"react/jsx-curly-brace-presence": [
|
|
3939
|
+
"error",
|
|
3940
|
+
{ children: "never", propElementValues: "always", props: "never" }
|
|
3941
|
+
],
|
|
3942
|
+
"react/jsx-props-no-spread-multi": "error",
|
|
3943
|
+
"react/no-danger": "error",
|
|
3933
3944
|
"react/no-unescaped-entities": "off"
|
|
3934
3945
|
}),
|
|
3935
3946
|
settings: {
|
|
@@ -4029,13 +4040,21 @@ var typeScriptBase_default = typeScriptBase;
|
|
|
4029
4040
|
|
|
4030
4041
|
// src/configs/combined/typeScriptBase.ts
|
|
4031
4042
|
function createCombinedTypeScriptBaseConfig(plugin) {
|
|
4032
|
-
return [
|
|
4043
|
+
return [
|
|
4044
|
+
...pluginBase_default(plugin),
|
|
4045
|
+
...typeScriptBase_default,
|
|
4046
|
+
{
|
|
4047
|
+
rules: {
|
|
4048
|
+
"@alextheman/standardise-error-messages": "error"
|
|
4049
|
+
}
|
|
4050
|
+
}
|
|
4051
|
+
];
|
|
4033
4052
|
}
|
|
4034
4053
|
var typeScriptBase_default2 = createCombinedTypeScriptBaseConfig;
|
|
4035
4054
|
|
|
4036
4055
|
// src/configs/combined/typeScriptReactBase.ts
|
|
4037
4056
|
function createCombinedTypeScriptReactBaseConfig(plugin) {
|
|
4038
|
-
return [...
|
|
4057
|
+
return [...typeScriptBase_default2(plugin), ...reactBase_default];
|
|
4039
4058
|
}
|
|
4040
4059
|
var typeScriptReactBase_default = createCombinedTypeScriptReactBaseConfig;
|
|
4041
4060
|
|
|
@@ -4465,6 +4484,61 @@ var noSkippedTests = createRule_default({
|
|
|
4465
4484
|
});
|
|
4466
4485
|
var no_skipped_tests_default = noSkippedTests;
|
|
4467
4486
|
|
|
4487
|
+
// src/rules/standardise-error-messages.ts
|
|
4488
|
+
var import_utils4 = require("@typescript-eslint/utils");
|
|
4489
|
+
function checkCurrentNode(context, node) {
|
|
4490
|
+
var _a, _b;
|
|
4491
|
+
const errorRegex = (_b = (_a = context.options[0]) == null ? void 0 : _a.regex) != null ? _b : "^[A-Z]+(?:_[A-Z]+)*$";
|
|
4492
|
+
if (node.callee.type === import_utils4.AST_NODE_TYPES.Identifier && node.callee.name === "Error") {
|
|
4493
|
+
const [errorArgument] = node.arguments;
|
|
4494
|
+
const errorMessage = errorArgument.type === import_utils4.AST_NODE_TYPES.Literal ? errorArgument.value : "";
|
|
4495
|
+
if (!RegExp(errorRegex).test(typeof errorMessage === "string" ? errorMessage : "")) {
|
|
4496
|
+
return context.report({
|
|
4497
|
+
node,
|
|
4498
|
+
messageId: "message",
|
|
4499
|
+
data: {
|
|
4500
|
+
error: errorMessage,
|
|
4501
|
+
regex: errorRegex
|
|
4502
|
+
}
|
|
4503
|
+
});
|
|
4504
|
+
}
|
|
4505
|
+
}
|
|
4506
|
+
}
|
|
4507
|
+
var standardiseErrorMessages = createRule_default({
|
|
4508
|
+
name: "standardise-error-messages",
|
|
4509
|
+
meta: {
|
|
4510
|
+
docs: {
|
|
4511
|
+
description: "Enforce a consistent standard for error messages."
|
|
4512
|
+
},
|
|
4513
|
+
messages: {
|
|
4514
|
+
message: "Expected error message {{error}} to match {{regex}}."
|
|
4515
|
+
},
|
|
4516
|
+
type: "suggestion",
|
|
4517
|
+
schema: [
|
|
4518
|
+
{
|
|
4519
|
+
type: "object",
|
|
4520
|
+
properties: {
|
|
4521
|
+
regex: {
|
|
4522
|
+
type: "string"
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
}
|
|
4526
|
+
]
|
|
4527
|
+
},
|
|
4528
|
+
defaultOptions: [{ regex: "^[A-Z]+(?:_[A-Z]+)*$" }],
|
|
4529
|
+
create(context) {
|
|
4530
|
+
return {
|
|
4531
|
+
CallExpression(node) {
|
|
4532
|
+
return checkCurrentNode(context, node);
|
|
4533
|
+
},
|
|
4534
|
+
NewExpression(node) {
|
|
4535
|
+
return checkCurrentNode(context, node);
|
|
4536
|
+
}
|
|
4537
|
+
};
|
|
4538
|
+
}
|
|
4539
|
+
});
|
|
4540
|
+
var standardise_error_messages_default = standardiseErrorMessages;
|
|
4541
|
+
|
|
4468
4542
|
// src/rules/use-normalized-imports.ts
|
|
4469
4543
|
var import_path = __toESM(require("path"), 1);
|
|
4470
4544
|
var useNormalizedImports = createRule_default({
|
|
@@ -4517,7 +4591,7 @@ var useNormalizedImports = createRule_default({
|
|
|
4517
4591
|
var use_normalized_imports_default = useNormalizedImports;
|
|
4518
4592
|
|
|
4519
4593
|
// src/rules/use-object-shorthand.ts
|
|
4520
|
-
var
|
|
4594
|
+
var import_utils5 = require("@typescript-eslint/utils");
|
|
4521
4595
|
var useObjectShorthand = createRule_default({
|
|
4522
4596
|
name: "use-object-shorthand",
|
|
4523
4597
|
meta: {
|
|
@@ -4535,7 +4609,7 @@ var useObjectShorthand = createRule_default({
|
|
|
4535
4609
|
create(context) {
|
|
4536
4610
|
return {
|
|
4537
4611
|
Property(node) {
|
|
4538
|
-
if (node.key.type ===
|
|
4612
|
+
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) {
|
|
4539
4613
|
context.report({
|
|
4540
4614
|
node,
|
|
4541
4615
|
messageId: "useShorthand",
|
|
@@ -4562,6 +4636,7 @@ var rules_default = {
|
|
|
4562
4636
|
"no-plugin-configs-access-from-src-configs": no_plugin_configs_access_from_src_configs_default,
|
|
4563
4637
|
"no-relative-imports": no_relative_imports_default,
|
|
4564
4638
|
"no-skipped-tests": no_skipped_tests_default,
|
|
4639
|
+
"standardise-error-messages": standardise_error_messages_default,
|
|
4565
4640
|
"use-normalized-imports": use_normalized_imports_default,
|
|
4566
4641
|
"use-object-shorthand": use_object_shorthand_default
|
|
4567
4642
|
};
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3700,7 +3700,7 @@ var require_globals2 = __commonJS({
|
|
|
3700
3700
|
|
|
3701
3701
|
// package.json
|
|
3702
3702
|
var name = "@alextheman/eslint-plugin";
|
|
3703
|
-
var version = "2.
|
|
3703
|
+
var version = "2.3.0";
|
|
3704
3704
|
|
|
3705
3705
|
// src/configs/general/javaScriptBase.ts
|
|
3706
3706
|
var import_js = __toESM(require_src(), 1);
|
|
@@ -3879,12 +3879,14 @@ var javaScriptBase_default2 = createCombinedJavaScriptBaseConfig;
|
|
|
3879
3879
|
|
|
3880
3880
|
// src/configs/general/reactBase.ts
|
|
3881
3881
|
var import_globals2 = __toESM(require_globals2(), 1);
|
|
3882
|
+
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
3882
3883
|
import reactPlugin from "eslint-plugin-react";
|
|
3883
3884
|
import reactHooks from "eslint-plugin-react-hooks";
|
|
3884
3885
|
import reactRefresh from "eslint-plugin-react-refresh";
|
|
3885
3886
|
var reactBase = [
|
|
3886
3887
|
reactPlugin.configs.flat.recommended,
|
|
3887
3888
|
reactPlugin.configs.flat["jsx-runtime"],
|
|
3889
|
+
jsxA11y.flatConfigs.recommended,
|
|
3888
3890
|
{
|
|
3889
3891
|
languageOptions: {
|
|
3890
3892
|
ecmaVersion: 2020,
|
|
@@ -3915,6 +3917,15 @@ var reactBase = [
|
|
|
3915
3917
|
],
|
|
3916
3918
|
"react-hooks/exhaustive-deps": "off",
|
|
3917
3919
|
"react-refresh/only-export-components": "off",
|
|
3920
|
+
"react/destructuring-assignment": ["error", "always", { destructureInSignature: "always" }],
|
|
3921
|
+
"react/hook-use-state": "error",
|
|
3922
|
+
"react/jsx-boolean-value": "error",
|
|
3923
|
+
"react/jsx-curly-brace-presence": [
|
|
3924
|
+
"error",
|
|
3925
|
+
{ children: "never", propElementValues: "always", props: "never" }
|
|
3926
|
+
],
|
|
3927
|
+
"react/jsx-props-no-spread-multi": "error",
|
|
3928
|
+
"react/no-danger": "error",
|
|
3918
3929
|
"react/no-unescaped-entities": "off"
|
|
3919
3930
|
}),
|
|
3920
3931
|
settings: {
|
|
@@ -4014,13 +4025,21 @@ var typeScriptBase_default = typeScriptBase;
|
|
|
4014
4025
|
|
|
4015
4026
|
// src/configs/combined/typeScriptBase.ts
|
|
4016
4027
|
function createCombinedTypeScriptBaseConfig(plugin) {
|
|
4017
|
-
return [
|
|
4028
|
+
return [
|
|
4029
|
+
...pluginBase_default(plugin),
|
|
4030
|
+
...typeScriptBase_default,
|
|
4031
|
+
{
|
|
4032
|
+
rules: {
|
|
4033
|
+
"@alextheman/standardise-error-messages": "error"
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4036
|
+
];
|
|
4018
4037
|
}
|
|
4019
4038
|
var typeScriptBase_default2 = createCombinedTypeScriptBaseConfig;
|
|
4020
4039
|
|
|
4021
4040
|
// src/configs/combined/typeScriptReactBase.ts
|
|
4022
4041
|
function createCombinedTypeScriptReactBaseConfig(plugin) {
|
|
4023
|
-
return [...
|
|
4042
|
+
return [...typeScriptBase_default2(plugin), ...reactBase_default];
|
|
4024
4043
|
}
|
|
4025
4044
|
var typeScriptReactBase_default = createCombinedTypeScriptReactBaseConfig;
|
|
4026
4045
|
|
|
@@ -4450,6 +4469,61 @@ var noSkippedTests = createRule_default({
|
|
|
4450
4469
|
});
|
|
4451
4470
|
var no_skipped_tests_default = noSkippedTests;
|
|
4452
4471
|
|
|
4472
|
+
// src/rules/standardise-error-messages.ts
|
|
4473
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/utils";
|
|
4474
|
+
function checkCurrentNode(context, node) {
|
|
4475
|
+
var _a, _b;
|
|
4476
|
+
const errorRegex = (_b = (_a = context.options[0]) == null ? void 0 : _a.regex) != null ? _b : "^[A-Z]+(?:_[A-Z]+)*$";
|
|
4477
|
+
if (node.callee.type === AST_NODE_TYPES3.Identifier && node.callee.name === "Error") {
|
|
4478
|
+
const [errorArgument] = node.arguments;
|
|
4479
|
+
const errorMessage = errorArgument.type === AST_NODE_TYPES3.Literal ? errorArgument.value : "";
|
|
4480
|
+
if (!RegExp(errorRegex).test(typeof errorMessage === "string" ? errorMessage : "")) {
|
|
4481
|
+
return context.report({
|
|
4482
|
+
node,
|
|
4483
|
+
messageId: "message",
|
|
4484
|
+
data: {
|
|
4485
|
+
error: errorMessage,
|
|
4486
|
+
regex: errorRegex
|
|
4487
|
+
}
|
|
4488
|
+
});
|
|
4489
|
+
}
|
|
4490
|
+
}
|
|
4491
|
+
}
|
|
4492
|
+
var standardiseErrorMessages = createRule_default({
|
|
4493
|
+
name: "standardise-error-messages",
|
|
4494
|
+
meta: {
|
|
4495
|
+
docs: {
|
|
4496
|
+
description: "Enforce a consistent standard for error messages."
|
|
4497
|
+
},
|
|
4498
|
+
messages: {
|
|
4499
|
+
message: "Expected error message {{error}} to match {{regex}}."
|
|
4500
|
+
},
|
|
4501
|
+
type: "suggestion",
|
|
4502
|
+
schema: [
|
|
4503
|
+
{
|
|
4504
|
+
type: "object",
|
|
4505
|
+
properties: {
|
|
4506
|
+
regex: {
|
|
4507
|
+
type: "string"
|
|
4508
|
+
}
|
|
4509
|
+
}
|
|
4510
|
+
}
|
|
4511
|
+
]
|
|
4512
|
+
},
|
|
4513
|
+
defaultOptions: [{ regex: "^[A-Z]+(?:_[A-Z]+)*$" }],
|
|
4514
|
+
create(context) {
|
|
4515
|
+
return {
|
|
4516
|
+
CallExpression(node) {
|
|
4517
|
+
return checkCurrentNode(context, node);
|
|
4518
|
+
},
|
|
4519
|
+
NewExpression(node) {
|
|
4520
|
+
return checkCurrentNode(context, node);
|
|
4521
|
+
}
|
|
4522
|
+
};
|
|
4523
|
+
}
|
|
4524
|
+
});
|
|
4525
|
+
var standardise_error_messages_default = standardiseErrorMessages;
|
|
4526
|
+
|
|
4453
4527
|
// src/rules/use-normalized-imports.ts
|
|
4454
4528
|
import path from "path";
|
|
4455
4529
|
var useNormalizedImports = createRule_default({
|
|
@@ -4502,7 +4576,7 @@ var useNormalizedImports = createRule_default({
|
|
|
4502
4576
|
var use_normalized_imports_default = useNormalizedImports;
|
|
4503
4577
|
|
|
4504
4578
|
// src/rules/use-object-shorthand.ts
|
|
4505
|
-
import { AST_NODE_TYPES as
|
|
4579
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/utils";
|
|
4506
4580
|
var useObjectShorthand = createRule_default({
|
|
4507
4581
|
name: "use-object-shorthand",
|
|
4508
4582
|
meta: {
|
|
@@ -4520,7 +4594,7 @@ var useObjectShorthand = createRule_default({
|
|
|
4520
4594
|
create(context) {
|
|
4521
4595
|
return {
|
|
4522
4596
|
Property(node) {
|
|
4523
|
-
if (node.key.type ===
|
|
4597
|
+
if (node.key.type === AST_NODE_TYPES4.Identifier && node.value.type === AST_NODE_TYPES4.Identifier && node.key.name === node.value.name && !node.shorthand) {
|
|
4524
4598
|
context.report({
|
|
4525
4599
|
node,
|
|
4526
4600
|
messageId: "useShorthand",
|
|
@@ -4547,6 +4621,7 @@ var rules_default = {
|
|
|
4547
4621
|
"no-plugin-configs-access-from-src-configs": no_plugin_configs_access_from_src_configs_default,
|
|
4548
4622
|
"no-relative-imports": no_relative_imports_default,
|
|
4549
4623
|
"no-skipped-tests": no_skipped_tests_default,
|
|
4624
|
+
"standardise-error-messages": standardise_error_messages_default,
|
|
4550
4625
|
"use-normalized-imports": use_normalized_imports_default,
|
|
4551
4626
|
"use-object-shorthand": use_object_shorthand_default
|
|
4552
4627
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/eslint-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "A package to provide custom ESLint rules and configs",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "alextheman",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/common-tags": "^1.8.4",
|
|
43
43
|
"@types/eslint": "^9.6.1",
|
|
44
|
+
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
|
|
44
45
|
"@types/node": "^24.9.1",
|
|
45
46
|
"@typescript-eslint/rule-tester": "^8.46.2",
|
|
46
47
|
"@typescript-eslint/utils": "^8.46.2",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"eslint-config-prettier": "^10.1.8",
|
|
62
63
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
63
64
|
"eslint-plugin-import": "^2.32.0",
|
|
65
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
64
66
|
"eslint-plugin-perfectionist": "^4.15.0",
|
|
65
67
|
"eslint-plugin-prettier": "^5.5.3",
|
|
66
68
|
"eslint-plugin-react": "^7.37.5",
|