@alextheman/eslint-plugin 2.2.3 → 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 +69 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +69 -5
- package/package.json +1 -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);
|
|
@@ -4040,13 +4040,21 @@ var typeScriptBase_default = typeScriptBase;
|
|
|
4040
4040
|
|
|
4041
4041
|
// src/configs/combined/typeScriptBase.ts
|
|
4042
4042
|
function createCombinedTypeScriptBaseConfig(plugin) {
|
|
4043
|
-
return [
|
|
4043
|
+
return [
|
|
4044
|
+
...pluginBase_default(plugin),
|
|
4045
|
+
...typeScriptBase_default,
|
|
4046
|
+
{
|
|
4047
|
+
rules: {
|
|
4048
|
+
"@alextheman/standardise-error-messages": "error"
|
|
4049
|
+
}
|
|
4050
|
+
}
|
|
4051
|
+
];
|
|
4044
4052
|
}
|
|
4045
4053
|
var typeScriptBase_default2 = createCombinedTypeScriptBaseConfig;
|
|
4046
4054
|
|
|
4047
4055
|
// src/configs/combined/typeScriptReactBase.ts
|
|
4048
4056
|
function createCombinedTypeScriptReactBaseConfig(plugin) {
|
|
4049
|
-
return [...
|
|
4057
|
+
return [...typeScriptBase_default2(plugin), ...reactBase_default];
|
|
4050
4058
|
}
|
|
4051
4059
|
var typeScriptReactBase_default = createCombinedTypeScriptReactBaseConfig;
|
|
4052
4060
|
|
|
@@ -4476,6 +4484,61 @@ var noSkippedTests = createRule_default({
|
|
|
4476
4484
|
});
|
|
4477
4485
|
var no_skipped_tests_default = noSkippedTests;
|
|
4478
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
|
+
|
|
4479
4542
|
// src/rules/use-normalized-imports.ts
|
|
4480
4543
|
var import_path = __toESM(require("path"), 1);
|
|
4481
4544
|
var useNormalizedImports = createRule_default({
|
|
@@ -4528,7 +4591,7 @@ var useNormalizedImports = createRule_default({
|
|
|
4528
4591
|
var use_normalized_imports_default = useNormalizedImports;
|
|
4529
4592
|
|
|
4530
4593
|
// src/rules/use-object-shorthand.ts
|
|
4531
|
-
var
|
|
4594
|
+
var import_utils5 = require("@typescript-eslint/utils");
|
|
4532
4595
|
var useObjectShorthand = createRule_default({
|
|
4533
4596
|
name: "use-object-shorthand",
|
|
4534
4597
|
meta: {
|
|
@@ -4546,7 +4609,7 @@ var useObjectShorthand = createRule_default({
|
|
|
4546
4609
|
create(context) {
|
|
4547
4610
|
return {
|
|
4548
4611
|
Property(node) {
|
|
4549
|
-
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) {
|
|
4550
4613
|
context.report({
|
|
4551
4614
|
node,
|
|
4552
4615
|
messageId: "useShorthand",
|
|
@@ -4573,6 +4636,7 @@ var rules_default = {
|
|
|
4573
4636
|
"no-plugin-configs-access-from-src-configs": no_plugin_configs_access_from_src_configs_default,
|
|
4574
4637
|
"no-relative-imports": no_relative_imports_default,
|
|
4575
4638
|
"no-skipped-tests": no_skipped_tests_default,
|
|
4639
|
+
"standardise-error-messages": standardise_error_messages_default,
|
|
4576
4640
|
"use-normalized-imports": use_normalized_imports_default,
|
|
4577
4641
|
"use-object-shorthand": use_object_shorthand_default
|
|
4578
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);
|
|
@@ -4025,13 +4025,21 @@ var typeScriptBase_default = typeScriptBase;
|
|
|
4025
4025
|
|
|
4026
4026
|
// src/configs/combined/typeScriptBase.ts
|
|
4027
4027
|
function createCombinedTypeScriptBaseConfig(plugin) {
|
|
4028
|
-
return [
|
|
4028
|
+
return [
|
|
4029
|
+
...pluginBase_default(plugin),
|
|
4030
|
+
...typeScriptBase_default,
|
|
4031
|
+
{
|
|
4032
|
+
rules: {
|
|
4033
|
+
"@alextheman/standardise-error-messages": "error"
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4036
|
+
];
|
|
4029
4037
|
}
|
|
4030
4038
|
var typeScriptBase_default2 = createCombinedTypeScriptBaseConfig;
|
|
4031
4039
|
|
|
4032
4040
|
// src/configs/combined/typeScriptReactBase.ts
|
|
4033
4041
|
function createCombinedTypeScriptReactBaseConfig(plugin) {
|
|
4034
|
-
return [...
|
|
4042
|
+
return [...typeScriptBase_default2(plugin), ...reactBase_default];
|
|
4035
4043
|
}
|
|
4036
4044
|
var typeScriptReactBase_default = createCombinedTypeScriptReactBaseConfig;
|
|
4037
4045
|
|
|
@@ -4461,6 +4469,61 @@ var noSkippedTests = createRule_default({
|
|
|
4461
4469
|
});
|
|
4462
4470
|
var no_skipped_tests_default = noSkippedTests;
|
|
4463
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
|
+
|
|
4464
4527
|
// src/rules/use-normalized-imports.ts
|
|
4465
4528
|
import path from "path";
|
|
4466
4529
|
var useNormalizedImports = createRule_default({
|
|
@@ -4513,7 +4576,7 @@ var useNormalizedImports = createRule_default({
|
|
|
4513
4576
|
var use_normalized_imports_default = useNormalizedImports;
|
|
4514
4577
|
|
|
4515
4578
|
// src/rules/use-object-shorthand.ts
|
|
4516
|
-
import { AST_NODE_TYPES as
|
|
4579
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/utils";
|
|
4517
4580
|
var useObjectShorthand = createRule_default({
|
|
4518
4581
|
name: "use-object-shorthand",
|
|
4519
4582
|
meta: {
|
|
@@ -4531,7 +4594,7 @@ var useObjectShorthand = createRule_default({
|
|
|
4531
4594
|
create(context) {
|
|
4532
4595
|
return {
|
|
4533
4596
|
Property(node) {
|
|
4534
|
-
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) {
|
|
4535
4598
|
context.report({
|
|
4536
4599
|
node,
|
|
4537
4600
|
messageId: "useShorthand",
|
|
@@ -4558,6 +4621,7 @@ var rules_default = {
|
|
|
4558
4621
|
"no-plugin-configs-access-from-src-configs": no_plugin_configs_access_from_src_configs_default,
|
|
4559
4622
|
"no-relative-imports": no_relative_imports_default,
|
|
4560
4623
|
"no-skipped-tests": no_skipped_tests_default,
|
|
4624
|
+
"standardise-error-messages": standardise_error_messages_default,
|
|
4561
4625
|
"use-normalized-imports": use_normalized_imports_default,
|
|
4562
4626
|
"use-object-shorthand": use_object_shorthand_default
|
|
4563
4627
|
};
|