@sarj/eslint-plugin 18.0.5 → 18.1.3
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-CzrWp3w7.d.cts → _docs-d31-QA2S.d.cts} +28 -15
- package/dist/{_docs-CzrWp3w7.d.ts → _docs-d31-QA2S.d.ts} +28 -15
- package/dist/index.cjs +4437 -3702
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4440 -3699
- package/dist/rule-examples.d.cts +1 -1
- package/dist/rule-examples.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ESLintUtils, TSESLint, TSESTree
|
|
1
|
+
import { ESLintUtils, JSONSchema, TSESLint, TSESTree } from '@typescript-eslint/utils';
|
|
2
2
|
import { Linter, JSRuleDefinition } from 'eslint';
|
|
3
3
|
import { RuleDefinition, RuleVisitor } from '@eslint/core';
|
|
4
4
|
|
|
@@ -19,18 +19,6 @@ type Definition<Options extends readonly unknown[], MessageIds extends string> =
|
|
|
19
19
|
Visitor: NativeRuleListener;
|
|
20
20
|
}>;
|
|
21
21
|
type EngineRuleContext<MessageIds extends string, Options extends readonly unknown[]> = Parameters<Definition<Options, MessageIds>["create"]>[0];
|
|
22
|
-
type NativeRuleContext<MessageIds extends string, Options extends readonly unknown[]> = Omit<EngineRuleContext<MessageIds, Options>, "options"> & {
|
|
23
|
-
readonly options: Readonly<Partial<Options>>;
|
|
24
|
-
};
|
|
25
|
-
type NativeRuleConfiguration<Options extends readonly unknown[], MessageIds extends string> = Omit<ESLintUtils.RuleWithMetaAndName<Options, MessageIds>, "create"> & {
|
|
26
|
-
create(this: void, context: NativeRuleContext<MessageIds, Options>, options: Readonly<Options>): NativeRuleListener;
|
|
27
|
-
} & (readonly [] extends Options ? unknown : {
|
|
28
|
-
readonly defaultOptions: Readonly<Options>;
|
|
29
|
-
} | {
|
|
30
|
-
readonly meta: {
|
|
31
|
-
readonly defaultOptions: Readonly<Options>;
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
22
|
type OwnedMetadata<Options extends readonly unknown[], MessageIds extends string> = Omit<ESLintUtils.RuleWithMetaAndName<Options, MessageIds>["meta"], "schema" | "defaultOptions" | "docs"> & {
|
|
35
23
|
docs: ESLintUtils.RuleWithMetaAndName<Options, MessageIds>["meta"]["docs"] & {
|
|
36
24
|
url: string;
|
|
@@ -44,7 +32,26 @@ interface NativeRule<Options extends readonly unknown[], MessageIds extends stri
|
|
|
44
32
|
meta: OwnedMetadata<Options, MessageIds>;
|
|
45
33
|
create(context: EngineRuleContext<MessageIds, Options>): NativeRuleListener;
|
|
46
34
|
}
|
|
47
|
-
|
|
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
|
+
};
|
|
48
55
|
|
|
49
56
|
/**
|
|
50
57
|
* @fileoverview _docs — typed source-owned rule documentation and executable examples.
|
|
@@ -102,6 +109,10 @@ interface RuleDocumentation<Options extends readonly unknown[] = readonly unknow
|
|
|
102
109
|
readonly rationale: string;
|
|
103
110
|
readonly remediation: string;
|
|
104
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[];
|
|
105
116
|
readonly defaultLevel?: DefaultLevel;
|
|
106
117
|
readonly languages?: readonly "typescript"[];
|
|
107
118
|
readonly autofix?: AutofixPolicy;
|
|
@@ -132,6 +143,8 @@ interface PublicRuleSpec {
|
|
|
132
143
|
readonly rationale: string;
|
|
133
144
|
readonly remediation: string;
|
|
134
145
|
readonly category: RuleCategory;
|
|
146
|
+
readonly requiresTypeInformation: boolean | null;
|
|
147
|
+
readonly runtimeImports: readonly string[];
|
|
135
148
|
readonly defaultLevel: DefaultLevel;
|
|
136
149
|
readonly languages: readonly "typescript"[];
|
|
137
150
|
readonly autofix: AutofixPolicy;
|
|
@@ -144,7 +157,7 @@ interface PublicRuleSpec {
|
|
|
144
157
|
readonly optionsSchema: object | null;
|
|
145
158
|
readonly examples: readonly PublicRuleExample[];
|
|
146
159
|
}
|
|
147
|
-
type DocumentedRule<Options extends readonly unknown[], MessageIds extends string> = ReturnType<typeof
|
|
160
|
+
type DocumentedRule<Options extends readonly unknown[], MessageIds extends string> = ReturnType<typeof trackableRule<Options, MessageIds>> & {
|
|
148
161
|
/** Non-enumerable so the public ESLint rule shape remains unchanged. */
|
|
149
162
|
readonly documentation?: NativeRuleSpec;
|
|
150
163
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ESLintUtils, TSESLint, TSESTree
|
|
1
|
+
import { ESLintUtils, JSONSchema, TSESLint, TSESTree } from '@typescript-eslint/utils';
|
|
2
2
|
import { Linter, JSRuleDefinition } from 'eslint';
|
|
3
3
|
import { RuleDefinition, RuleVisitor } from '@eslint/core';
|
|
4
4
|
|
|
@@ -19,18 +19,6 @@ type Definition<Options extends readonly unknown[], MessageIds extends string> =
|
|
|
19
19
|
Visitor: NativeRuleListener;
|
|
20
20
|
}>;
|
|
21
21
|
type EngineRuleContext<MessageIds extends string, Options extends readonly unknown[]> = Parameters<Definition<Options, MessageIds>["create"]>[0];
|
|
22
|
-
type NativeRuleContext<MessageIds extends string, Options extends readonly unknown[]> = Omit<EngineRuleContext<MessageIds, Options>, "options"> & {
|
|
23
|
-
readonly options: Readonly<Partial<Options>>;
|
|
24
|
-
};
|
|
25
|
-
type NativeRuleConfiguration<Options extends readonly unknown[], MessageIds extends string> = Omit<ESLintUtils.RuleWithMetaAndName<Options, MessageIds>, "create"> & {
|
|
26
|
-
create(this: void, context: NativeRuleContext<MessageIds, Options>, options: Readonly<Options>): NativeRuleListener;
|
|
27
|
-
} & (readonly [] extends Options ? unknown : {
|
|
28
|
-
readonly defaultOptions: Readonly<Options>;
|
|
29
|
-
} | {
|
|
30
|
-
readonly meta: {
|
|
31
|
-
readonly defaultOptions: Readonly<Options>;
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
22
|
type OwnedMetadata<Options extends readonly unknown[], MessageIds extends string> = Omit<ESLintUtils.RuleWithMetaAndName<Options, MessageIds>["meta"], "schema" | "defaultOptions" | "docs"> & {
|
|
35
23
|
docs: ESLintUtils.RuleWithMetaAndName<Options, MessageIds>["meta"]["docs"] & {
|
|
36
24
|
url: string;
|
|
@@ -44,7 +32,26 @@ interface NativeRule<Options extends readonly unknown[], MessageIds extends stri
|
|
|
44
32
|
meta: OwnedMetadata<Options, MessageIds>;
|
|
45
33
|
create(context: EngineRuleContext<MessageIds, Options>): NativeRuleListener;
|
|
46
34
|
}
|
|
47
|
-
|
|
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
|
+
};
|
|
48
55
|
|
|
49
56
|
/**
|
|
50
57
|
* @fileoverview _docs — typed source-owned rule documentation and executable examples.
|
|
@@ -102,6 +109,10 @@ interface RuleDocumentation<Options extends readonly unknown[] = readonly unknow
|
|
|
102
109
|
readonly rationale: string;
|
|
103
110
|
readonly remediation: string;
|
|
104
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[];
|
|
105
116
|
readonly defaultLevel?: DefaultLevel;
|
|
106
117
|
readonly languages?: readonly "typescript"[];
|
|
107
118
|
readonly autofix?: AutofixPolicy;
|
|
@@ -132,6 +143,8 @@ interface PublicRuleSpec {
|
|
|
132
143
|
readonly rationale: string;
|
|
133
144
|
readonly remediation: string;
|
|
134
145
|
readonly category: RuleCategory;
|
|
146
|
+
readonly requiresTypeInformation: boolean | null;
|
|
147
|
+
readonly runtimeImports: readonly string[];
|
|
135
148
|
readonly defaultLevel: DefaultLevel;
|
|
136
149
|
readonly languages: readonly "typescript"[];
|
|
137
150
|
readonly autofix: AutofixPolicy;
|
|
@@ -144,7 +157,7 @@ interface PublicRuleSpec {
|
|
|
144
157
|
readonly optionsSchema: object | null;
|
|
145
158
|
readonly examples: readonly PublicRuleExample[];
|
|
146
159
|
}
|
|
147
|
-
type DocumentedRule<Options extends readonly unknown[], MessageIds extends string> = ReturnType<typeof
|
|
160
|
+
type DocumentedRule<Options extends readonly unknown[], MessageIds extends string> = ReturnType<typeof trackableRule<Options, MessageIds>> & {
|
|
148
161
|
/** Non-enumerable so the public ESLint rule shape remains unchanged. */
|
|
149
162
|
readonly documentation?: NativeRuleSpec;
|
|
150
163
|
};
|