@alextheman/eslint-plugin 5.8.1 → 5.9.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 +45 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.js +46 -6
- package/dist/internal/index.cjs +4243 -0
- package/dist/internal/index.d.cts +174 -0
- package/dist/internal/index.d.ts +174 -0
- package/dist/internal/index.js +4231 -0
- package/dist/utility/index.d.cts +1 -1
- package/package.json +10 -3
package/dist/index.cjs
CHANGED
|
@@ -4521,8 +4521,8 @@ const sortExports = {
|
|
|
4521
4521
|
const sortImports = {
|
|
4522
4522
|
customGroups: [
|
|
4523
4523
|
{
|
|
4524
|
-
elementNamePattern: ["
|
|
4525
|
-
groupName: "
|
|
4524
|
+
elementNamePattern: [".json"],
|
|
4525
|
+
groupName: "json"
|
|
4526
4526
|
},
|
|
4527
4527
|
{
|
|
4528
4528
|
elementNamePattern: ["^tests/.*"],
|
|
@@ -4543,7 +4543,7 @@ const sortImports = {
|
|
|
4543
4543
|
"value-builtin",
|
|
4544
4544
|
"value-tests",
|
|
4545
4545
|
"value-internal",
|
|
4546
|
-
"
|
|
4546
|
+
"json"
|
|
4547
4547
|
],
|
|
4548
4548
|
ignoreCase: true,
|
|
4549
4549
|
internalPattern: ["^src/.*"],
|
|
@@ -4929,7 +4929,7 @@ function internalTypeScript(plugin) {
|
|
|
4929
4929
|
"@typescript-eslint": typescript_eslint.default.plugin
|
|
4930
4930
|
},
|
|
4931
4931
|
rules: {
|
|
4932
|
-
"@alextheman/standardise-error-messages": "
|
|
4932
|
+
"@alextheman/standardise-error-messages": "off",
|
|
4933
4933
|
"@typescript-eslint/array-type": ["error", { default: "array" }],
|
|
4934
4934
|
"@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: "as" }],
|
|
4935
4935
|
"@typescript-eslint/consistent-type-definitions": "error",
|
|
@@ -5223,6 +5223,45 @@ const consistentTestFunction = createRule({
|
|
|
5223
5223
|
}
|
|
5224
5224
|
});
|
|
5225
5225
|
|
|
5226
|
+
//#endregion
|
|
5227
|
+
//#region src/rules/has-standards.ts
|
|
5228
|
+
const hasStandardsOptionsSchema = zod.default.object({ fixable: zod.default.boolean() }).partial();
|
|
5229
|
+
function parseHasStandardsOptions(input) {
|
|
5230
|
+
return (0, _alextheman_utility.parseZodSchema)(hasStandardsOptionsSchema, input);
|
|
5231
|
+
}
|
|
5232
|
+
const defaultOptions = { fixable: false };
|
|
5233
|
+
const targetValue = "I have standards, you'd better have some too!";
|
|
5234
|
+
const hasStandards = createRule({
|
|
5235
|
+
name: "no-isolated-tests",
|
|
5236
|
+
meta: {
|
|
5237
|
+
docs: { description: _alextheman_utility.normaliseIndents`
|
|
5238
|
+
Enforces that any string literal must contain the phrase "${targetValue}"
|
|
5239
|
+
This is a very pointless rule in practice, but it helps with the end-to-end tests as a nice trivial rule to test entrypoints with. Please do not actually use this in practice.` },
|
|
5240
|
+
messages: { message: "Set your standards and you'll do great." },
|
|
5241
|
+
type: "suggestion",
|
|
5242
|
+
schema: createRuleSchemaFromZodSchema(hasStandardsOptionsSchema),
|
|
5243
|
+
fixable: "code"
|
|
5244
|
+
},
|
|
5245
|
+
defaultOptions: [defaultOptions],
|
|
5246
|
+
create(context) {
|
|
5247
|
+
const { fixable = false } = parseHasStandardsOptions(context.options[0] ?? defaultOptions);
|
|
5248
|
+
return { Literal(node) {
|
|
5249
|
+
if (node.value !== targetValue) return context.report({
|
|
5250
|
+
node,
|
|
5251
|
+
messageId: "message",
|
|
5252
|
+
data: {
|
|
5253
|
+
source: node,
|
|
5254
|
+
value: node.value
|
|
5255
|
+
},
|
|
5256
|
+
fix: fixOnCondition(fixable, (fixer) => {
|
|
5257
|
+
const [quote] = node.raw;
|
|
5258
|
+
return fixer.replaceText(node, `${quote}${targetValue}${quote}`);
|
|
5259
|
+
})
|
|
5260
|
+
});
|
|
5261
|
+
} };
|
|
5262
|
+
}
|
|
5263
|
+
});
|
|
5264
|
+
|
|
5226
5265
|
//#endregion
|
|
5227
5266
|
//#region src/rules/no-isolated-tests.ts
|
|
5228
5267
|
const noIsolatedTests = createRule({
|
|
@@ -5505,6 +5544,7 @@ const useObjectShorthand = createRule({
|
|
|
5505
5544
|
//#region src/rules/index.ts
|
|
5506
5545
|
var rules_default = {
|
|
5507
5546
|
"consistent-test-function": consistentTestFunction,
|
|
5547
|
+
"has-standards": hasStandards,
|
|
5508
5548
|
"no-isolated-tests": noIsolatedTests,
|
|
5509
5549
|
"no-namespace-imports": noNamespaceImports,
|
|
5510
5550
|
"no-plugin-configs-access-from-src-configs": noPluginConfigAccessFromSrcConfigs,
|
|
@@ -5518,7 +5558,7 @@ var rules_default = {
|
|
|
5518
5558
|
//#endregion
|
|
5519
5559
|
//#region package.json
|
|
5520
5560
|
var name = "@alextheman/eslint-plugin";
|
|
5521
|
-
var version = "5.
|
|
5561
|
+
var version = "5.9.0";
|
|
5522
5562
|
|
|
5523
5563
|
//#endregion
|
|
5524
5564
|
//#region src/alexPlugin.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -5,8 +5,8 @@ import { PluginOptions } from "typedoc-plugin-markdown";
|
|
|
5
5
|
import * as vite from "vite";
|
|
6
6
|
import { VitestEnvironment } from "vitest/node";
|
|
7
7
|
import { TSESTree } from "@typescript-eslint/utils";
|
|
8
|
-
import { JSONSchema4 } from "@typescript-eslint/utils/json-schema";
|
|
9
8
|
import z from "zod";
|
|
9
|
+
import { JSONSchema4 } from "@typescript-eslint/utils/json-schema";
|
|
10
10
|
import { RuleContext, RuleFix, RuleFixer } from "@typescript-eslint/utils/ts-eslint";
|
|
11
11
|
|
|
12
12
|
//#region src/utility/private/camelToKebab.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataError, camelToKebab, deepCopy, deepFreeze, omitProperties } from "@alextheman/utility";
|
|
1
|
+
import { DataError, camelToKebab, deepCopy, deepFreeze, normaliseIndents, omitProperties, parseZodSchema } from "@alextheman/utility";
|
|
2
2
|
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
3
3
|
import z from "zod";
|
|
4
4
|
import js from "@eslint/js";
|
|
@@ -4505,8 +4505,8 @@ const sortExports = {
|
|
|
4505
4505
|
const sortImports = {
|
|
4506
4506
|
customGroups: [
|
|
4507
4507
|
{
|
|
4508
|
-
elementNamePattern: ["
|
|
4509
|
-
groupName: "
|
|
4508
|
+
elementNamePattern: [".json"],
|
|
4509
|
+
groupName: "json"
|
|
4510
4510
|
},
|
|
4511
4511
|
{
|
|
4512
4512
|
elementNamePattern: ["^tests/.*"],
|
|
@@ -4527,7 +4527,7 @@ const sortImports = {
|
|
|
4527
4527
|
"value-builtin",
|
|
4528
4528
|
"value-tests",
|
|
4529
4529
|
"value-internal",
|
|
4530
|
-
"
|
|
4530
|
+
"json"
|
|
4531
4531
|
],
|
|
4532
4532
|
ignoreCase: true,
|
|
4533
4533
|
internalPattern: ["^src/.*"],
|
|
@@ -4913,7 +4913,7 @@ function internalTypeScript(plugin) {
|
|
|
4913
4913
|
"@typescript-eslint": tseslint.plugin
|
|
4914
4914
|
},
|
|
4915
4915
|
rules: {
|
|
4916
|
-
"@alextheman/standardise-error-messages": "
|
|
4916
|
+
"@alextheman/standardise-error-messages": "off",
|
|
4917
4917
|
"@typescript-eslint/array-type": ["error", { default: "array" }],
|
|
4918
4918
|
"@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: "as" }],
|
|
4919
4919
|
"@typescript-eslint/consistent-type-definitions": "error",
|
|
@@ -5207,6 +5207,45 @@ const consistentTestFunction = createRule({
|
|
|
5207
5207
|
}
|
|
5208
5208
|
});
|
|
5209
5209
|
|
|
5210
|
+
//#endregion
|
|
5211
|
+
//#region src/rules/has-standards.ts
|
|
5212
|
+
const hasStandardsOptionsSchema = z.object({ fixable: z.boolean() }).partial();
|
|
5213
|
+
function parseHasStandardsOptions(input) {
|
|
5214
|
+
return parseZodSchema(hasStandardsOptionsSchema, input);
|
|
5215
|
+
}
|
|
5216
|
+
const defaultOptions = { fixable: false };
|
|
5217
|
+
const targetValue = "I have standards, you'd better have some too!";
|
|
5218
|
+
const hasStandards = createRule({
|
|
5219
|
+
name: "no-isolated-tests",
|
|
5220
|
+
meta: {
|
|
5221
|
+
docs: { description: normaliseIndents`
|
|
5222
|
+
Enforces that any string literal must contain the phrase "${targetValue}"
|
|
5223
|
+
This is a very pointless rule in practice, but it helps with the end-to-end tests as a nice trivial rule to test entrypoints with. Please do not actually use this in practice.` },
|
|
5224
|
+
messages: { message: "Set your standards and you'll do great." },
|
|
5225
|
+
type: "suggestion",
|
|
5226
|
+
schema: createRuleSchemaFromZodSchema(hasStandardsOptionsSchema),
|
|
5227
|
+
fixable: "code"
|
|
5228
|
+
},
|
|
5229
|
+
defaultOptions: [defaultOptions],
|
|
5230
|
+
create(context) {
|
|
5231
|
+
const { fixable = false } = parseHasStandardsOptions(context.options[0] ?? defaultOptions);
|
|
5232
|
+
return { Literal(node) {
|
|
5233
|
+
if (node.value !== targetValue) return context.report({
|
|
5234
|
+
node,
|
|
5235
|
+
messageId: "message",
|
|
5236
|
+
data: {
|
|
5237
|
+
source: node,
|
|
5238
|
+
value: node.value
|
|
5239
|
+
},
|
|
5240
|
+
fix: fixOnCondition(fixable, (fixer) => {
|
|
5241
|
+
const [quote] = node.raw;
|
|
5242
|
+
return fixer.replaceText(node, `${quote}${targetValue}${quote}`);
|
|
5243
|
+
})
|
|
5244
|
+
});
|
|
5245
|
+
} };
|
|
5246
|
+
}
|
|
5247
|
+
});
|
|
5248
|
+
|
|
5210
5249
|
//#endregion
|
|
5211
5250
|
//#region src/rules/no-isolated-tests.ts
|
|
5212
5251
|
const noIsolatedTests = createRule({
|
|
@@ -5489,6 +5528,7 @@ const useObjectShorthand = createRule({
|
|
|
5489
5528
|
//#region src/rules/index.ts
|
|
5490
5529
|
var rules_default = {
|
|
5491
5530
|
"consistent-test-function": consistentTestFunction,
|
|
5531
|
+
"has-standards": hasStandards,
|
|
5492
5532
|
"no-isolated-tests": noIsolatedTests,
|
|
5493
5533
|
"no-namespace-imports": noNamespaceImports,
|
|
5494
5534
|
"no-plugin-configs-access-from-src-configs": noPluginConfigAccessFromSrcConfigs,
|
|
@@ -5502,7 +5542,7 @@ var rules_default = {
|
|
|
5502
5542
|
//#endregion
|
|
5503
5543
|
//#region package.json
|
|
5504
5544
|
var name = "@alextheman/eslint-plugin";
|
|
5505
|
-
var version = "5.
|
|
5545
|
+
var version = "5.9.0";
|
|
5506
5546
|
|
|
5507
5547
|
//#endregion
|
|
5508
5548
|
//#region src/alexPlugin.ts
|