@sarj/eslint-plugin 18.3.1 → 19.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/README.md +3 -3
- package/dist/catalog.js +6590 -0
- package/dist/chunk-KBGBBVAC.js +35295 -0
- package/dist/index.js +3 -39104
- package/dist/rule-examples.js +117 -262
- package/package.json +22 -52
- package/dist/_docs-d31-QA2S.d.cts +0 -170
- package/dist/_docs-d31-QA2S.d.ts +0 -170
- package/dist/index.cjs +0 -39103
- package/dist/index.d.cts +0 -766
- package/dist/index.d.ts +0 -766
- package/dist/rule-examples.cjs +0 -331
- package/dist/rule-examples.d.cts +0 -15
- package/dist/rule-examples.d.ts +0 -15
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { ESLintUtils, JSONSchema, TSESLint, TSESTree } from '@typescript-eslint/utils';
|
|
2
|
-
import { Linter, JSRuleDefinition } from 'eslint';
|
|
3
|
-
import { RuleDefinition, RuleVisitor } from '@eslint/core';
|
|
4
|
-
|
|
5
|
-
/** @fileoverview _eslint-rule — native TypeScript rule contexts and owned option metadata. */
|
|
6
|
-
|
|
7
|
-
type NativeJavaScriptSource = Parameters<JSRuleDefinition["create"]>[0]["sourceCode"];
|
|
8
|
-
type TypeScriptSourceCode = Pick<TSESLint.SourceCode, Exclude<Extract<keyof TSESLint.SourceCode, keyof NativeJavaScriptSource>, "visitorKeys">> & Pick<NativeJavaScriptSource, "visitorKeys"> & Pick<NativeJavaScriptSource, Exclude<keyof NativeJavaScriptSource, keyof TSESLint.SourceCode>>;
|
|
9
|
-
type NativeRuleListener = {
|
|
10
|
-
[Selector in keyof TSESLint.RuleListener as string extends Selector ? never : number extends Selector ? never : Selector]: TSESLint.RuleListener[Selector];
|
|
11
|
-
} & RuleVisitor;
|
|
12
|
-
type Definition<Options extends readonly unknown[], MessageIds extends string> = RuleDefinition<{
|
|
13
|
-
LangOptions: Linter.LanguageOptions;
|
|
14
|
-
ExtRuleDocs: Record<string, unknown>;
|
|
15
|
-
RuleOptions: [...Options];
|
|
16
|
-
MessageIds: MessageIds;
|
|
17
|
-
Code: TypeScriptSourceCode;
|
|
18
|
-
Node: TSESTree.Node | TSESTree.Token;
|
|
19
|
-
Visitor: NativeRuleListener;
|
|
20
|
-
}>;
|
|
21
|
-
type EngineRuleContext<MessageIds extends string, Options extends readonly unknown[]> = Parameters<Definition<Options, MessageIds>["create"]>[0];
|
|
22
|
-
type OwnedMetadata<Options extends readonly unknown[], MessageIds extends string> = Omit<ESLintUtils.RuleWithMetaAndName<Options, MessageIds>["meta"], "schema" | "defaultOptions" | "docs"> & {
|
|
23
|
-
docs: ESLintUtils.RuleWithMetaAndName<Options, MessageIds>["meta"]["docs"] & {
|
|
24
|
-
url: string;
|
|
25
|
-
};
|
|
26
|
-
schema: JSONSchema.JSONSchema4 | JSONSchema.JSONSchema4[];
|
|
27
|
-
defaultOptions?: [...Options];
|
|
28
|
-
};
|
|
29
|
-
interface NativeRule<Options extends readonly unknown[], MessageIds extends string> {
|
|
30
|
-
name: string;
|
|
31
|
-
defaultOptions: Readonly<Options> | undefined;
|
|
32
|
-
meta: OwnedMetadata<Options, MessageIds>;
|
|
33
|
-
create(context: EngineRuleContext<MessageIds, Options>): NativeRuleListener;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @fileoverview _trackable-rule — observe rule prerequisites and completed native execution without altering diagnostics.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
type RuleExecutionState = "ran" | "skipped" | "untracked" | "failed";
|
|
41
|
-
interface RuleExecution {
|
|
42
|
-
readonly ruleId: string;
|
|
43
|
-
readonly filePath: string;
|
|
44
|
-
readonly execution: RuleExecutionState;
|
|
45
|
-
readonly requiresTypeInformation: boolean | null;
|
|
46
|
-
readonly reason?: string;
|
|
47
|
-
}
|
|
48
|
-
interface RuleExecutionTracker {
|
|
49
|
-
finish(): readonly RuleExecution[];
|
|
50
|
-
}
|
|
51
|
-
/** Tracking is opt-in and bound to the exact rule instance used by the engine. */
|
|
52
|
-
declare function trackableRule<Options extends readonly unknown[], MessageIds extends string>(rule: NativeRule<Options, MessageIds>, requiresTypeInformation: boolean | null): NativeRule<Options, MessageIds> & {
|
|
53
|
-
trackExecution(): RuleExecutionTracker;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @fileoverview _docs — typed source-owned rule documentation and executable examples.
|
|
58
|
-
*
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
type RuleCategory = "architecture" | "correctness" | "maintainability" | "performance" | "security" | "style" | "testing";
|
|
62
|
-
type AutofixPolicy = "none" | "safe" | "suggestion";
|
|
63
|
-
type DefaultLevel = "error" | "warning";
|
|
64
|
-
type ExampleOutcome = "match" | "no-match";
|
|
65
|
-
interface ExampleFile {
|
|
66
|
-
readonly path: string;
|
|
67
|
-
readonly source: string;
|
|
68
|
-
}
|
|
69
|
-
interface ExamplePoint {
|
|
70
|
-
readonly line: number;
|
|
71
|
-
readonly column: number;
|
|
72
|
-
}
|
|
73
|
-
interface ExampleLocation extends ExamplePoint {
|
|
74
|
-
readonly end?: ExamplePoint;
|
|
75
|
-
}
|
|
76
|
-
interface SuggestionExpectation {
|
|
77
|
-
readonly messageId: string;
|
|
78
|
-
readonly output: string;
|
|
79
|
-
}
|
|
80
|
-
interface DiagnosticExpectation {
|
|
81
|
-
readonly messageId: string;
|
|
82
|
-
readonly message: string;
|
|
83
|
-
readonly location: ExampleLocation;
|
|
84
|
-
readonly automaticFix: boolean;
|
|
85
|
-
readonly suggestions: readonly SuggestionExpectation[];
|
|
86
|
-
}
|
|
87
|
-
/** A reviewed example. It remains private unless `public: true` is explicit. */
|
|
88
|
-
interface RuleExample<Options extends readonly unknown[] = readonly unknown[]> {
|
|
89
|
-
readonly ruleOptions?: Readonly<Options>;
|
|
90
|
-
readonly installedDependencies?: readonly {
|
|
91
|
-
readonly module: string;
|
|
92
|
-
readonly version: string;
|
|
93
|
-
}[];
|
|
94
|
-
readonly id: string;
|
|
95
|
-
readonly scenarioId?: string;
|
|
96
|
-
readonly title: string;
|
|
97
|
-
readonly outcome: ExampleOutcome;
|
|
98
|
-
readonly files: readonly ExampleFile[];
|
|
99
|
-
readonly focusPath: string;
|
|
100
|
-
readonly expectedCount: number;
|
|
101
|
-
readonly expectedDiagnostics?: readonly DiagnosticExpectation[];
|
|
102
|
-
readonly public?: boolean;
|
|
103
|
-
readonly fixedFiles?: readonly ExampleFile[];
|
|
104
|
-
}
|
|
105
|
-
type PublicRuleExample = Omit<RuleExample, "expectedDiagnostics">;
|
|
106
|
-
/** Human-authored fields that cannot be derived from the ESLint rule module. */
|
|
107
|
-
interface RuleDocumentation<Options extends readonly unknown[] = readonly unknown[]> {
|
|
108
|
-
readonly summary: string;
|
|
109
|
-
readonly rationale: string;
|
|
110
|
-
readonly remediation: string;
|
|
111
|
-
readonly category: RuleCategory;
|
|
112
|
-
/** Omission/null preserves undeclared prerequisites rather than assuming a syntax-only detector. */
|
|
113
|
-
readonly requiresTypeInformation?: boolean | null;
|
|
114
|
-
/** Source package roots whose imported APIs establish provenance; these are not plugin dependencies. */
|
|
115
|
-
readonly runtimeImports?: readonly string[];
|
|
116
|
-
readonly defaultLevel?: DefaultLevel;
|
|
117
|
-
readonly languages?: readonly "typescript"[];
|
|
118
|
-
readonly autofix?: AutofixPolicy;
|
|
119
|
-
readonly aliases?: readonly string[];
|
|
120
|
-
readonly limitations?: readonly string[];
|
|
121
|
-
readonly filePatterns?: readonly string[];
|
|
122
|
-
readonly references?: readonly string[];
|
|
123
|
-
readonly since?: string;
|
|
124
|
-
readonly examples?: readonly RuleExample<Options>[];
|
|
125
|
-
}
|
|
126
|
-
/** Complete native record exposed to catalog generation without changing ESLint metadata. */
|
|
127
|
-
interface NativeRuleSpec extends Required<Omit<RuleDocumentation, "since">> {
|
|
128
|
-
readonly engine: "eslint";
|
|
129
|
-
readonly ruleId: string;
|
|
130
|
-
readonly code: null;
|
|
131
|
-
readonly messageIds: readonly string[];
|
|
132
|
-
readonly optionsSchema: object | null;
|
|
133
|
-
readonly since: string | null;
|
|
134
|
-
readonly key: string;
|
|
135
|
-
readonly publicExamples: readonly RuleExample[];
|
|
136
|
-
}
|
|
137
|
-
/** The explicit allowlist projection consumed by generated public documentation. */
|
|
138
|
-
interface PublicRuleSpec {
|
|
139
|
-
readonly engine: "eslint";
|
|
140
|
-
readonly ruleId: string;
|
|
141
|
-
readonly code: null;
|
|
142
|
-
readonly summary: string;
|
|
143
|
-
readonly rationale: string;
|
|
144
|
-
readonly remediation: string;
|
|
145
|
-
readonly category: RuleCategory;
|
|
146
|
-
readonly requiresTypeInformation: boolean | null;
|
|
147
|
-
readonly runtimeImports: readonly string[];
|
|
148
|
-
readonly defaultLevel: DefaultLevel;
|
|
149
|
-
readonly languages: readonly "typescript"[];
|
|
150
|
-
readonly autofix: AutofixPolicy;
|
|
151
|
-
readonly aliases: readonly string[];
|
|
152
|
-
readonly limitations: readonly string[];
|
|
153
|
-
readonly filePatterns: readonly string[];
|
|
154
|
-
readonly references: readonly string[];
|
|
155
|
-
readonly since: string | null;
|
|
156
|
-
readonly messageIds: readonly string[];
|
|
157
|
-
readonly optionsSchema: object | null;
|
|
158
|
-
readonly examples: readonly PublicRuleExample[];
|
|
159
|
-
}
|
|
160
|
-
type DocumentedRule<Options extends readonly unknown[], MessageIds extends string> = ReturnType<typeof trackableRule<Options, MessageIds>> & {
|
|
161
|
-
/** Non-enumerable so the public ESLint rule shape remains unchanged. */
|
|
162
|
-
readonly documentation?: NativeRuleSpec;
|
|
163
|
-
};
|
|
164
|
-
/** Serialize only reviewed fields; test-only examples never cross this boundary. */
|
|
165
|
-
declare function publicDocumentation(rules: Readonly<Record<string, {
|
|
166
|
-
readonly documentation?: NativeRuleSpec;
|
|
167
|
-
}>>): readonly PublicRuleSpec[];
|
|
168
|
-
|
|
169
|
-
export { publicDocumentation as p };
|
|
170
|
-
export type { DocumentedRule as D, ExampleFile as E, RuleExample as R };
|
package/dist/_docs-d31-QA2S.d.ts
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { ESLintUtils, JSONSchema, TSESLint, TSESTree } from '@typescript-eslint/utils';
|
|
2
|
-
import { Linter, JSRuleDefinition } from 'eslint';
|
|
3
|
-
import { RuleDefinition, RuleVisitor } from '@eslint/core';
|
|
4
|
-
|
|
5
|
-
/** @fileoverview _eslint-rule — native TypeScript rule contexts and owned option metadata. */
|
|
6
|
-
|
|
7
|
-
type NativeJavaScriptSource = Parameters<JSRuleDefinition["create"]>[0]["sourceCode"];
|
|
8
|
-
type TypeScriptSourceCode = Pick<TSESLint.SourceCode, Exclude<Extract<keyof TSESLint.SourceCode, keyof NativeJavaScriptSource>, "visitorKeys">> & Pick<NativeJavaScriptSource, "visitorKeys"> & Pick<NativeJavaScriptSource, Exclude<keyof NativeJavaScriptSource, keyof TSESLint.SourceCode>>;
|
|
9
|
-
type NativeRuleListener = {
|
|
10
|
-
[Selector in keyof TSESLint.RuleListener as string extends Selector ? never : number extends Selector ? never : Selector]: TSESLint.RuleListener[Selector];
|
|
11
|
-
} & RuleVisitor;
|
|
12
|
-
type Definition<Options extends readonly unknown[], MessageIds extends string> = RuleDefinition<{
|
|
13
|
-
LangOptions: Linter.LanguageOptions;
|
|
14
|
-
ExtRuleDocs: Record<string, unknown>;
|
|
15
|
-
RuleOptions: [...Options];
|
|
16
|
-
MessageIds: MessageIds;
|
|
17
|
-
Code: TypeScriptSourceCode;
|
|
18
|
-
Node: TSESTree.Node | TSESTree.Token;
|
|
19
|
-
Visitor: NativeRuleListener;
|
|
20
|
-
}>;
|
|
21
|
-
type EngineRuleContext<MessageIds extends string, Options extends readonly unknown[]> = Parameters<Definition<Options, MessageIds>["create"]>[0];
|
|
22
|
-
type OwnedMetadata<Options extends readonly unknown[], MessageIds extends string> = Omit<ESLintUtils.RuleWithMetaAndName<Options, MessageIds>["meta"], "schema" | "defaultOptions" | "docs"> & {
|
|
23
|
-
docs: ESLintUtils.RuleWithMetaAndName<Options, MessageIds>["meta"]["docs"] & {
|
|
24
|
-
url: string;
|
|
25
|
-
};
|
|
26
|
-
schema: JSONSchema.JSONSchema4 | JSONSchema.JSONSchema4[];
|
|
27
|
-
defaultOptions?: [...Options];
|
|
28
|
-
};
|
|
29
|
-
interface NativeRule<Options extends readonly unknown[], MessageIds extends string> {
|
|
30
|
-
name: string;
|
|
31
|
-
defaultOptions: Readonly<Options> | undefined;
|
|
32
|
-
meta: OwnedMetadata<Options, MessageIds>;
|
|
33
|
-
create(context: EngineRuleContext<MessageIds, Options>): NativeRuleListener;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @fileoverview _trackable-rule — observe rule prerequisites and completed native execution without altering diagnostics.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
type RuleExecutionState = "ran" | "skipped" | "untracked" | "failed";
|
|
41
|
-
interface RuleExecution {
|
|
42
|
-
readonly ruleId: string;
|
|
43
|
-
readonly filePath: string;
|
|
44
|
-
readonly execution: RuleExecutionState;
|
|
45
|
-
readonly requiresTypeInformation: boolean | null;
|
|
46
|
-
readonly reason?: string;
|
|
47
|
-
}
|
|
48
|
-
interface RuleExecutionTracker {
|
|
49
|
-
finish(): readonly RuleExecution[];
|
|
50
|
-
}
|
|
51
|
-
/** Tracking is opt-in and bound to the exact rule instance used by the engine. */
|
|
52
|
-
declare function trackableRule<Options extends readonly unknown[], MessageIds extends string>(rule: NativeRule<Options, MessageIds>, requiresTypeInformation: boolean | null): NativeRule<Options, MessageIds> & {
|
|
53
|
-
trackExecution(): RuleExecutionTracker;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @fileoverview _docs — typed source-owned rule documentation and executable examples.
|
|
58
|
-
*
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
type RuleCategory = "architecture" | "correctness" | "maintainability" | "performance" | "security" | "style" | "testing";
|
|
62
|
-
type AutofixPolicy = "none" | "safe" | "suggestion";
|
|
63
|
-
type DefaultLevel = "error" | "warning";
|
|
64
|
-
type ExampleOutcome = "match" | "no-match";
|
|
65
|
-
interface ExampleFile {
|
|
66
|
-
readonly path: string;
|
|
67
|
-
readonly source: string;
|
|
68
|
-
}
|
|
69
|
-
interface ExamplePoint {
|
|
70
|
-
readonly line: number;
|
|
71
|
-
readonly column: number;
|
|
72
|
-
}
|
|
73
|
-
interface ExampleLocation extends ExamplePoint {
|
|
74
|
-
readonly end?: ExamplePoint;
|
|
75
|
-
}
|
|
76
|
-
interface SuggestionExpectation {
|
|
77
|
-
readonly messageId: string;
|
|
78
|
-
readonly output: string;
|
|
79
|
-
}
|
|
80
|
-
interface DiagnosticExpectation {
|
|
81
|
-
readonly messageId: string;
|
|
82
|
-
readonly message: string;
|
|
83
|
-
readonly location: ExampleLocation;
|
|
84
|
-
readonly automaticFix: boolean;
|
|
85
|
-
readonly suggestions: readonly SuggestionExpectation[];
|
|
86
|
-
}
|
|
87
|
-
/** A reviewed example. It remains private unless `public: true` is explicit. */
|
|
88
|
-
interface RuleExample<Options extends readonly unknown[] = readonly unknown[]> {
|
|
89
|
-
readonly ruleOptions?: Readonly<Options>;
|
|
90
|
-
readonly installedDependencies?: readonly {
|
|
91
|
-
readonly module: string;
|
|
92
|
-
readonly version: string;
|
|
93
|
-
}[];
|
|
94
|
-
readonly id: string;
|
|
95
|
-
readonly scenarioId?: string;
|
|
96
|
-
readonly title: string;
|
|
97
|
-
readonly outcome: ExampleOutcome;
|
|
98
|
-
readonly files: readonly ExampleFile[];
|
|
99
|
-
readonly focusPath: string;
|
|
100
|
-
readonly expectedCount: number;
|
|
101
|
-
readonly expectedDiagnostics?: readonly DiagnosticExpectation[];
|
|
102
|
-
readonly public?: boolean;
|
|
103
|
-
readonly fixedFiles?: readonly ExampleFile[];
|
|
104
|
-
}
|
|
105
|
-
type PublicRuleExample = Omit<RuleExample, "expectedDiagnostics">;
|
|
106
|
-
/** Human-authored fields that cannot be derived from the ESLint rule module. */
|
|
107
|
-
interface RuleDocumentation<Options extends readonly unknown[] = readonly unknown[]> {
|
|
108
|
-
readonly summary: string;
|
|
109
|
-
readonly rationale: string;
|
|
110
|
-
readonly remediation: string;
|
|
111
|
-
readonly category: RuleCategory;
|
|
112
|
-
/** Omission/null preserves undeclared prerequisites rather than assuming a syntax-only detector. */
|
|
113
|
-
readonly requiresTypeInformation?: boolean | null;
|
|
114
|
-
/** Source package roots whose imported APIs establish provenance; these are not plugin dependencies. */
|
|
115
|
-
readonly runtimeImports?: readonly string[];
|
|
116
|
-
readonly defaultLevel?: DefaultLevel;
|
|
117
|
-
readonly languages?: readonly "typescript"[];
|
|
118
|
-
readonly autofix?: AutofixPolicy;
|
|
119
|
-
readonly aliases?: readonly string[];
|
|
120
|
-
readonly limitations?: readonly string[];
|
|
121
|
-
readonly filePatterns?: readonly string[];
|
|
122
|
-
readonly references?: readonly string[];
|
|
123
|
-
readonly since?: string;
|
|
124
|
-
readonly examples?: readonly RuleExample<Options>[];
|
|
125
|
-
}
|
|
126
|
-
/** Complete native record exposed to catalog generation without changing ESLint metadata. */
|
|
127
|
-
interface NativeRuleSpec extends Required<Omit<RuleDocumentation, "since">> {
|
|
128
|
-
readonly engine: "eslint";
|
|
129
|
-
readonly ruleId: string;
|
|
130
|
-
readonly code: null;
|
|
131
|
-
readonly messageIds: readonly string[];
|
|
132
|
-
readonly optionsSchema: object | null;
|
|
133
|
-
readonly since: string | null;
|
|
134
|
-
readonly key: string;
|
|
135
|
-
readonly publicExamples: readonly RuleExample[];
|
|
136
|
-
}
|
|
137
|
-
/** The explicit allowlist projection consumed by generated public documentation. */
|
|
138
|
-
interface PublicRuleSpec {
|
|
139
|
-
readonly engine: "eslint";
|
|
140
|
-
readonly ruleId: string;
|
|
141
|
-
readonly code: null;
|
|
142
|
-
readonly summary: string;
|
|
143
|
-
readonly rationale: string;
|
|
144
|
-
readonly remediation: string;
|
|
145
|
-
readonly category: RuleCategory;
|
|
146
|
-
readonly requiresTypeInformation: boolean | null;
|
|
147
|
-
readonly runtimeImports: readonly string[];
|
|
148
|
-
readonly defaultLevel: DefaultLevel;
|
|
149
|
-
readonly languages: readonly "typescript"[];
|
|
150
|
-
readonly autofix: AutofixPolicy;
|
|
151
|
-
readonly aliases: readonly string[];
|
|
152
|
-
readonly limitations: readonly string[];
|
|
153
|
-
readonly filePatterns: readonly string[];
|
|
154
|
-
readonly references: readonly string[];
|
|
155
|
-
readonly since: string | null;
|
|
156
|
-
readonly messageIds: readonly string[];
|
|
157
|
-
readonly optionsSchema: object | null;
|
|
158
|
-
readonly examples: readonly PublicRuleExample[];
|
|
159
|
-
}
|
|
160
|
-
type DocumentedRule<Options extends readonly unknown[], MessageIds extends string> = ReturnType<typeof trackableRule<Options, MessageIds>> & {
|
|
161
|
-
/** Non-enumerable so the public ESLint rule shape remains unchanged. */
|
|
162
|
-
readonly documentation?: NativeRuleSpec;
|
|
163
|
-
};
|
|
164
|
-
/** Serialize only reviewed fields; test-only examples never cross this boundary. */
|
|
165
|
-
declare function publicDocumentation(rules: Readonly<Record<string, {
|
|
166
|
-
readonly documentation?: NativeRuleSpec;
|
|
167
|
-
}>>): readonly PublicRuleSpec[];
|
|
168
|
-
|
|
169
|
-
export { publicDocumentation as p };
|
|
170
|
-
export type { DocumentedRule as D, ExampleFile as E, RuleExample as R };
|