@sarj/eslint-plugin 15.26.8 → 15.28.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/_docs-XCw_6XV9.d.cts +88 -0
- package/dist/_docs-XCw_6XV9.d.ts +88 -0
- package/dist/index.cjs +970 -840
- package/dist/index.d.cts +10 -89
- package/dist/index.d.ts +10 -89
- package/dist/index.js +968 -838
- package/dist/rule-examples.cjs +112 -0
- package/dist/rule-examples.d.cts +7 -0
- package/dist/rule-examples.d.ts +7 -0
- package/dist/rule-examples.js +77 -0
- package/package.json +4 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview _docs — typed source-owned rule documentation and executable examples.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
type RuleCategory = "architecture" | "correctness" | "maintainability" | "performance" | "security" | "style" | "testing";
|
|
9
|
+
type AutofixPolicy = "none" | "safe" | "suggestion";
|
|
10
|
+
type DefaultLevel = "error" | "warning";
|
|
11
|
+
type ExampleOutcome = "match" | "no-match";
|
|
12
|
+
interface ExampleFile {
|
|
13
|
+
readonly path: string;
|
|
14
|
+
readonly source: string;
|
|
15
|
+
}
|
|
16
|
+
/** A reviewed example. It remains private unless `public: true` is explicit. */
|
|
17
|
+
interface RuleExample {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly scenarioId?: string;
|
|
20
|
+
readonly title: string;
|
|
21
|
+
readonly outcome: ExampleOutcome;
|
|
22
|
+
readonly files: readonly ExampleFile[];
|
|
23
|
+
readonly focusPath: string;
|
|
24
|
+
readonly expectedCount: number;
|
|
25
|
+
readonly public?: boolean;
|
|
26
|
+
readonly fixedFiles?: readonly ExampleFile[];
|
|
27
|
+
}
|
|
28
|
+
/** Human-authored fields that cannot be derived from the ESLint rule module. */
|
|
29
|
+
interface RuleDocumentation {
|
|
30
|
+
readonly summary: string;
|
|
31
|
+
readonly rationale: string;
|
|
32
|
+
readonly remediation: string;
|
|
33
|
+
readonly category: RuleCategory;
|
|
34
|
+
readonly defaultLevel?: DefaultLevel;
|
|
35
|
+
readonly languages?: readonly "typescript"[];
|
|
36
|
+
readonly autofix?: AutofixPolicy;
|
|
37
|
+
readonly aliases?: readonly string[];
|
|
38
|
+
readonly limitations?: readonly string[];
|
|
39
|
+
readonly filePatterns?: readonly string[];
|
|
40
|
+
readonly references?: readonly string[];
|
|
41
|
+
readonly since?: string;
|
|
42
|
+
readonly examples?: readonly RuleExample[];
|
|
43
|
+
}
|
|
44
|
+
/** Complete native record exposed to catalog generation without changing ESLint metadata. */
|
|
45
|
+
interface NativeRuleSpec extends Required<Omit<RuleDocumentation, "since">> {
|
|
46
|
+
readonly engine: "eslint";
|
|
47
|
+
readonly ruleId: string;
|
|
48
|
+
readonly code: null;
|
|
49
|
+
readonly messageIds: readonly string[];
|
|
50
|
+
readonly optionsSchema: object | null;
|
|
51
|
+
readonly since: string | null;
|
|
52
|
+
readonly key: string;
|
|
53
|
+
readonly publicExamples: readonly RuleExample[];
|
|
54
|
+
}
|
|
55
|
+
/** The explicit allowlist projection consumed by generated public documentation. */
|
|
56
|
+
interface PublicRuleSpec {
|
|
57
|
+
readonly engine: "eslint";
|
|
58
|
+
readonly ruleId: string;
|
|
59
|
+
readonly code: null;
|
|
60
|
+
readonly summary: string;
|
|
61
|
+
readonly rationale: string;
|
|
62
|
+
readonly remediation: string;
|
|
63
|
+
readonly category: RuleCategory;
|
|
64
|
+
readonly defaultLevel: DefaultLevel;
|
|
65
|
+
readonly languages: readonly "typescript"[];
|
|
66
|
+
readonly autofix: AutofixPolicy;
|
|
67
|
+
readonly aliases: readonly string[];
|
|
68
|
+
readonly limitations: readonly string[];
|
|
69
|
+
readonly filePatterns: readonly string[];
|
|
70
|
+
readonly references: readonly string[];
|
|
71
|
+
readonly since: string | null;
|
|
72
|
+
readonly messageIds: readonly string[];
|
|
73
|
+
readonly optionsSchema: object | null;
|
|
74
|
+
readonly examples: readonly RuleExample[];
|
|
75
|
+
}
|
|
76
|
+
declare const eslintCreateRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener> & {
|
|
77
|
+
name: string;
|
|
78
|
+
};
|
|
79
|
+
type DocumentedRule<Options extends readonly unknown[], MessageIds extends string> = ReturnType<typeof eslintCreateRule<Options, MessageIds>> & {
|
|
80
|
+
/** Non-enumerable so the public ESLint rule shape remains unchanged. */
|
|
81
|
+
readonly documentation?: NativeRuleSpec;
|
|
82
|
+
};
|
|
83
|
+
/** Serialize only reviewed fields; test-only examples never cross this boundary. */
|
|
84
|
+
declare function publicDocumentation(rules: Readonly<Record<string, {
|
|
85
|
+
readonly documentation?: NativeRuleSpec;
|
|
86
|
+
}>>): readonly PublicRuleSpec[];
|
|
87
|
+
|
|
88
|
+
export { type DocumentedRule as D, publicDocumentation as p };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview _docs — typed source-owned rule documentation and executable examples.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
type RuleCategory = "architecture" | "correctness" | "maintainability" | "performance" | "security" | "style" | "testing";
|
|
9
|
+
type AutofixPolicy = "none" | "safe" | "suggestion";
|
|
10
|
+
type DefaultLevel = "error" | "warning";
|
|
11
|
+
type ExampleOutcome = "match" | "no-match";
|
|
12
|
+
interface ExampleFile {
|
|
13
|
+
readonly path: string;
|
|
14
|
+
readonly source: string;
|
|
15
|
+
}
|
|
16
|
+
/** A reviewed example. It remains private unless `public: true` is explicit. */
|
|
17
|
+
interface RuleExample {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly scenarioId?: string;
|
|
20
|
+
readonly title: string;
|
|
21
|
+
readonly outcome: ExampleOutcome;
|
|
22
|
+
readonly files: readonly ExampleFile[];
|
|
23
|
+
readonly focusPath: string;
|
|
24
|
+
readonly expectedCount: number;
|
|
25
|
+
readonly public?: boolean;
|
|
26
|
+
readonly fixedFiles?: readonly ExampleFile[];
|
|
27
|
+
}
|
|
28
|
+
/** Human-authored fields that cannot be derived from the ESLint rule module. */
|
|
29
|
+
interface RuleDocumentation {
|
|
30
|
+
readonly summary: string;
|
|
31
|
+
readonly rationale: string;
|
|
32
|
+
readonly remediation: string;
|
|
33
|
+
readonly category: RuleCategory;
|
|
34
|
+
readonly defaultLevel?: DefaultLevel;
|
|
35
|
+
readonly languages?: readonly "typescript"[];
|
|
36
|
+
readonly autofix?: AutofixPolicy;
|
|
37
|
+
readonly aliases?: readonly string[];
|
|
38
|
+
readonly limitations?: readonly string[];
|
|
39
|
+
readonly filePatterns?: readonly string[];
|
|
40
|
+
readonly references?: readonly string[];
|
|
41
|
+
readonly since?: string;
|
|
42
|
+
readonly examples?: readonly RuleExample[];
|
|
43
|
+
}
|
|
44
|
+
/** Complete native record exposed to catalog generation without changing ESLint metadata. */
|
|
45
|
+
interface NativeRuleSpec extends Required<Omit<RuleDocumentation, "since">> {
|
|
46
|
+
readonly engine: "eslint";
|
|
47
|
+
readonly ruleId: string;
|
|
48
|
+
readonly code: null;
|
|
49
|
+
readonly messageIds: readonly string[];
|
|
50
|
+
readonly optionsSchema: object | null;
|
|
51
|
+
readonly since: string | null;
|
|
52
|
+
readonly key: string;
|
|
53
|
+
readonly publicExamples: readonly RuleExample[];
|
|
54
|
+
}
|
|
55
|
+
/** The explicit allowlist projection consumed by generated public documentation. */
|
|
56
|
+
interface PublicRuleSpec {
|
|
57
|
+
readonly engine: "eslint";
|
|
58
|
+
readonly ruleId: string;
|
|
59
|
+
readonly code: null;
|
|
60
|
+
readonly summary: string;
|
|
61
|
+
readonly rationale: string;
|
|
62
|
+
readonly remediation: string;
|
|
63
|
+
readonly category: RuleCategory;
|
|
64
|
+
readonly defaultLevel: DefaultLevel;
|
|
65
|
+
readonly languages: readonly "typescript"[];
|
|
66
|
+
readonly autofix: AutofixPolicy;
|
|
67
|
+
readonly aliases: readonly string[];
|
|
68
|
+
readonly limitations: readonly string[];
|
|
69
|
+
readonly filePatterns: readonly string[];
|
|
70
|
+
readonly references: readonly string[];
|
|
71
|
+
readonly since: string | null;
|
|
72
|
+
readonly messageIds: readonly string[];
|
|
73
|
+
readonly optionsSchema: object | null;
|
|
74
|
+
readonly examples: readonly RuleExample[];
|
|
75
|
+
}
|
|
76
|
+
declare const eslintCreateRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener> & {
|
|
77
|
+
name: string;
|
|
78
|
+
};
|
|
79
|
+
type DocumentedRule<Options extends readonly unknown[], MessageIds extends string> = ReturnType<typeof eslintCreateRule<Options, MessageIds>> & {
|
|
80
|
+
/** Non-enumerable so the public ESLint rule shape remains unchanged. */
|
|
81
|
+
readonly documentation?: NativeRuleSpec;
|
|
82
|
+
};
|
|
83
|
+
/** Serialize only reviewed fields; test-only examples never cross this boundary. */
|
|
84
|
+
declare function publicDocumentation(rules: Readonly<Record<string, {
|
|
85
|
+
readonly documentation?: NativeRuleSpec;
|
|
86
|
+
}>>): readonly PublicRuleSpec[];
|
|
87
|
+
|
|
88
|
+
export { type DocumentedRule as D, publicDocumentation as p };
|