@autotelic/plumb 0.3.1 → 0.3.2
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/effect/index.d.ts +3 -0
- package/dist/effect/index.js +56 -0
- package/dist/effect/rules/guarded-op-must-return-effect.d.ts +6 -0
- package/dist/effect/rules/guarded-op-must-return-effect.js +235 -0
- package/dist/effect/rules/guarded-op-must-return-option.d.ts +2 -0
- package/dist/effect/rules/guarded-op-must-return-option.js +88 -0
- package/dist/effect/rules/no-cascading-layer-provide.d.ts +6 -0
- package/dist/effect/rules/no-cascading-layer-provide.js +73 -0
- package/dist/effect/rules/no-decode-unknown-option.d.ts +7 -0
- package/dist/effect/rules/no-decode-unknown-option.js +34 -0
- package/dist/effect/rules/no-direct-browser-storage.d.ts +2 -0
- package/dist/effect/rules/no-direct-browser-storage.js +88 -0
- package/dist/effect/rules/no-direct-fetch.d.ts +2 -0
- package/dist/effect/rules/no-direct-fetch.js +37 -0
- package/dist/effect/rules/no-manual-field-guards.d.ts +6 -0
- package/dist/effect/rules/no-manual-field-guards.js +129 -0
- package/dist/effect/rules/no-nested-layer-provide.d.ts +2 -0
- package/dist/effect/rules/no-nested-layer-provide.js +50 -0
- package/dist/effect/rules/no-schema-class-modeling.d.ts +2 -0
- package/dist/effect/rules/no-schema-class-modeling.js +52 -0
- package/dist/effect/rules/no-service-constructor-imports.d.ts +2 -0
- package/dist/effect/rules/no-service-constructor-imports.js +42 -0
- package/dist/effect/rules/no-silent-error-swallow.d.ts +2 -0
- package/dist/effect/rules/no-silent-error-swallow.js +95 -0
- package/dist/effect/rules/no-static-effect-service-forwarders.d.ts +6 -0
- package/dist/effect/rules/no-static-effect-service-forwarders.js +222 -0
- package/dist/effect/rules/no-try-catch.d.ts +2 -0
- package/dist/effect/rules/no-try-catch.js +30 -0
- package/dist/effect/rules/no-unguarded-json-parse.d.ts +5 -0
- package/dist/effect/rules/no-unguarded-json-parse.js +200 -0
- package/dist/effect/rules/option-core-needs-effect-public.d.ts +5 -0
- package/dist/effect/rules/option-core-needs-effect-public.js +76 -0
- package/dist/effect/rules/prefer-die-for-precondition-defects.d.ts +5 -0
- package/dist/effect/rules/prefer-die-for-precondition-defects.js +112 -0
- package/dist/effect/rules/prefer-effect-gen-for-guard-ladders.d.ts +5 -0
- package/dist/effect/rules/prefer-effect-gen-for-guard-ladders.js +72 -0
- package/dist/effect/rules/prefer-effect-match.d.ts +2 -0
- package/dist/effect/rules/prefer-effect-match.js +74 -0
- package/dist/effect/rules/prefer-effect-predicate-over-boolean-function.d.ts +2 -0
- package/dist/effect/rules/prefer-effect-predicate-over-boolean-function.js +75 -0
- package/dist/effect/rules/prefer-named-guard-predicate.d.ts +2 -0
- package/dist/effect/rules/prefer-named-guard-predicate.js +93 -0
- package/dist/effect/rules/prefer-option-pipeline.d.ts +2 -0
- package/dist/effect/rules/prefer-option-pipeline.js +87 -0
- package/dist/effect/rules/prefer-ordering-match.d.ts +2 -0
- package/dist/effect/rules/prefer-ordering-match.js +135 -0
- package/dist/effect/rules/prefer-tagged-enum.d.ts +2 -0
- package/dist/effect/rules/prefer-tagged-enum.js +66 -0
- package/dist/effect/rules/require-schema-type-derivation.d.ts +7 -0
- package/dist/effect/rules/require-schema-type-derivation.js +80 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +102 -0
- package/dist/meta/index.d.ts +7 -0
- package/{src/meta/index.ts → dist/meta/index.js} +13 -16
- package/dist/meta/rules/no-disable-directives.d.ts +6 -0
- package/dist/meta/rules/no-disable-directives.js +35 -0
- package/dist/meta/rules/no-manual-ancestor-walks.d.ts +2 -0
- package/dist/meta/rules/no-manual-ancestor-walks.js +26 -0
- package/dist/meta/rules/prefer-before-file-scope.d.ts +2 -0
- package/dist/meta/rules/prefer-before-file-scope.js +57 -0
- package/dist/meta/rules/require-create-once.d.ts +2 -0
- package/dist/meta/rules/require-create-once.js +51 -0
- package/dist/meta/rules/require-rule-tester.d.ts +2 -0
- package/dist/meta/rules/require-rule-tester.js +50 -0
- package/dist/rules/no-anonymous-wide-tuples.d.ts +7 -0
- package/dist/rules/no-anonymous-wide-tuples.js +34 -0
- package/dist/rules/no-barrel-export-star.d.ts +2 -0
- package/dist/rules/no-barrel-export-star.js +26 -0
- package/dist/rules/no-boolean-field-signals.d.ts +2 -0
- package/dist/rules/no-boolean-field-signals.js +279 -0
- package/dist/rules/no-builtin-throws.d.ts +6 -0
- package/dist/rules/no-builtin-throws.js +74 -0
- package/dist/rules/no-chained-type-assertions.d.ts +2 -0
- package/dist/rules/no-chained-type-assertions.js +54 -0
- package/dist/rules/no-conditional-empty-object-spread.d.ts +2 -0
- package/dist/rules/no-conditional-empty-object-spread.js +36 -0
- package/dist/rules/no-duplicated-literal-union.d.ts +6 -0
- package/dist/rules/no-duplicated-literal-union.js +62 -0
- package/dist/rules/no-exported-mutable-state.d.ts +7 -0
- package/dist/rules/no-exported-mutable-state.js +104 -0
- package/dist/rules/no-generic-export-names.d.ts +2 -0
- package/dist/rules/no-generic-export-names.js +141 -0
- package/dist/rules/no-impossible-branch-throw.d.ts +2 -0
- package/dist/rules/no-impossible-branch-throw.js +51 -0
- package/dist/rules/no-known-value-widening.d.ts +2 -0
- package/dist/rules/no-known-value-widening.js +176 -0
- package/dist/rules/no-module-mocking.d.ts +2 -0
- package/dist/rules/no-module-mocking.js +90 -0
- package/dist/rules/no-multiple-function-params.d.ts +2 -0
- package/dist/rules/no-multiple-function-params.js +155 -0
- package/dist/rules/no-nondeterministic-core.d.ts +6 -0
- package/dist/rules/no-nondeterministic-core.js +63 -0
- package/dist/rules/no-object-parameters.d.ts +2 -0
- package/dist/rules/no-object-parameters.js +95 -0
- package/dist/rules/no-optional-function-parameters.d.ts +7 -0
- package/dist/rules/no-optional-function-parameters.js +44 -0
- package/dist/rules/no-product-of-state-booleans.d.ts +2 -0
- package/dist/rules/no-product-of-state-booleans.js +79 -0
- package/dist/rules/no-redundant-derived-field.d.ts +6 -0
- package/dist/rules/no-redundant-derived-field.js +194 -0
- package/dist/rules/no-reflect-apply.d.ts +2 -0
- package/dist/rules/no-reflect-apply.js +29 -0
- package/dist/rules/no-reflect-get.d.ts +2 -0
- package/dist/rules/no-reflect-get.js +29 -0
- package/dist/rules/no-reinterpret-cast.d.ts +2 -0
- package/dist/rules/no-reinterpret-cast.js +68 -0
- package/dist/rules/no-runtime-typeof.d.ts +2 -0
- package/dist/rules/no-runtime-typeof.js +54 -0
- package/dist/rules/no-sentinel-comparison-union.d.ts +2 -0
- package/dist/rules/no-sentinel-comparison-union.js +139 -0
- package/dist/rules/no-shape-in-symbol-names.d.ts +2 -0
- package/dist/rules/no-shape-in-symbol-names.js +39 -0
- package/dist/rules/no-single-use-private-functions.d.ts +6 -0
- package/dist/rules/no-single-use-private-functions.js +295 -0
- package/dist/rules/no-stacked-jsdoc-blocks.d.ts +2 -0
- package/dist/rules/no-stacked-jsdoc-blocks.js +50 -0
- package/dist/rules/no-stray-inline-comments.d.ts +2 -0
- package/dist/rules/no-stray-inline-comments.js +74 -0
- package/dist/rules/no-swappable-primitive-params.d.ts +2 -0
- package/dist/rules/no-swappable-primitive-params.js +96 -0
- package/dist/rules/no-tag-ladder-assertions.d.ts +6 -0
- package/dist/rules/no-tag-ladder-assertions.js +63 -0
- package/dist/rules/no-transposed-field-reads.d.ts +8 -0
- package/dist/rules/no-transposed-field-reads.js +101 -0
- package/dist/rules/no-unit-return-validators.d.ts +2 -0
- package/dist/rules/no-unit-return-validators.js +64 -0
- package/dist/rules/no-unknown-parameters.d.ts +2 -0
- package/dist/rules/no-unknown-parameters.js +82 -0
- package/dist/rules/no-unknown-returns.d.ts +2 -0
- package/dist/rules/no-unknown-returns.js +86 -0
- package/dist/rules/no-unknown-type-aliases.d.ts +2 -0
- package/dist/rules/no-unknown-type-aliases.js +64 -0
- package/dist/rules/no-unsafe-dictionary-type.d.ts +2 -0
- package/dist/rules/no-unsafe-dictionary-type.js +116 -0
- package/dist/rules/no-vague-test-filenames.d.ts +2 -0
- package/dist/rules/no-vague-test-filenames.js +61 -0
- package/dist/rules/no-widen-then-assert.d.ts +2 -0
- package/dist/rules/no-widen-then-assert.js +268 -0
- package/dist/rules/prefer-payload-brand.d.ts +2 -0
- package/dist/rules/prefer-payload-brand.js +57 -0
- package/dist/rules/prefer-property-tests.d.ts +5 -0
- package/dist/rules/prefer-property-tests.js +39 -0
- package/dist/rules/require-canonical-stringify-for-identity.d.ts +8 -0
- package/dist/rules/require-canonical-stringify-for-identity.js +72 -0
- package/dist/rules/require-deprecated-tag-for-legacy-comments.d.ts +2 -0
- package/dist/rules/require-deprecated-tag-for-legacy-comments.js +34 -0
- package/dist/rules/require-exhaustive-tag-switch.d.ts +7 -0
- package/dist/rules/require-exhaustive-tag-switch.js +34 -0
- package/dist/rules/require-fc-block-predicate.d.ts +2 -0
- package/dist/rules/require-fc-block-predicate.js +37 -0
- package/dist/rules/require-jsdoc-on-exported.d.ts +2 -0
- package/dist/rules/require-jsdoc-on-exported.js +66 -0
- package/dist/rules/require-published-order.d.ts +2 -0
- package/dist/rules/require-published-order.js +102 -0
- package/dist/rules/require-safety-comment-for-type-assertion.d.ts +2 -0
- package/dist/rules/require-safety-comment-for-type-assertion.js +53 -0
- package/dist/rules/require-sort-comparator.d.ts +7 -0
- package/dist/rules/require-sort-comparator.js +34 -0
- package/dist/rules/test-utils.d.ts +35 -0
- package/dist/rules/test-utils.js +53 -0
- package/{src/shared/ancestors.ts → dist/shared/ancestors.d.ts} +1 -4
- package/dist/shared/ancestors.js +19 -0
- package/dist/shared/child-nodes.d.ts +12 -0
- package/dist/shared/child-nodes.js +26 -0
- package/dist/shared/dictionary-types.d.ts +55 -0
- package/dist/shared/dictionary-types.js +413 -0
- package/{src/shared/is-node.ts → dist/shared/is-node.d.ts} +2 -6
- package/dist/shared/is-node.js +10 -0
- package/dist/shared/lexical-type-parameters.d.ts +12 -0
- package/dist/shared/lexical-type-parameters.js +50 -0
- package/dist/shared/reflect-method.d.ts +15 -0
- package/dist/shared/reflect-method.js +32 -0
- package/{src/shared/rule-options.ts → dist/shared/rule-options.d.ts} +2 -7
- package/dist/shared/rule-options.js +12 -0
- package/{src/shared/structural.ts → dist/shared/structural.d.ts} +17 -44
- package/dist/shared/structural.js +40 -0
- package/{src/testing/index.ts → dist/testing/index.d.ts} +0 -1
- package/dist/testing/index.js +1 -0
- package/dist/testing/testable-rule.d.ts +38 -0
- package/dist/testing/testable-rule.js +70 -0
- package/package.json +7 -6
- package/src/effect/index.ts +0 -59
- package/src/effect/rules/guarded-op-must-return-effect.ts +0 -236
- package/src/effect/rules/guarded-op-must-return-option.ts +0 -97
- package/src/effect/rules/no-cascading-layer-provide.ts +0 -80
- package/src/effect/rules/no-decode-unknown-option.ts +0 -41
- package/src/effect/rules/no-direct-browser-storage.ts +0 -91
- package/src/effect/rules/no-direct-fetch.ts +0 -44
- package/src/effect/rules/no-manual-field-guards.ts +0 -144
- package/src/effect/rules/no-nested-layer-provide.ts +0 -51
- package/src/effect/rules/no-schema-class-modeling.ts +0 -59
- package/src/effect/rules/no-service-constructor-imports.ts +0 -50
- package/src/effect/rules/no-silent-error-swallow.ts +0 -99
- package/src/effect/rules/no-static-effect-service-forwarders.ts +0 -227
- package/src/effect/rules/no-try-catch.ts +0 -32
- package/src/effect/rules/no-unguarded-json-parse.ts +0 -211
- package/src/effect/rules/option-core-needs-effect-public.ts +0 -81
- package/src/effect/rules/prefer-die-for-precondition-defects.ts +0 -118
- package/src/effect/rules/prefer-effect-gen-for-guard-ladders.ts +0 -76
- package/src/effect/rules/prefer-effect-match.ts +0 -78
- package/src/effect/rules/prefer-effect-predicate-over-boolean-function.ts +0 -79
- package/src/effect/rules/prefer-named-guard-predicate.ts +0 -105
- package/src/effect/rules/prefer-option-pipeline.ts +0 -95
- package/src/effect/rules/prefer-ordering-match.ts +0 -152
- package/src/effect/rules/prefer-tagged-enum.ts +0 -68
- package/src/effect/rules/require-schema-type-derivation.ts +0 -83
- package/src/index.ts +0 -106
- package/src/meta/rules/no-disable-directives.ts +0 -38
- package/src/meta/rules/no-manual-ancestor-walks.ts +0 -27
- package/src/meta/rules/prefer-before-file-scope.ts +0 -57
- package/src/meta/rules/require-create-once.ts +0 -51
- package/src/meta/rules/require-rule-tester.ts +0 -57
- package/src/rules/no-anonymous-wide-tuples.ts +0 -38
- package/src/rules/no-barrel-export-star.ts +0 -30
- package/src/rules/no-boolean-field-signals.ts +0 -305
- package/src/rules/no-builtin-throws.ts +0 -83
- package/src/rules/no-chained-type-assertions.ts +0 -65
- package/src/rules/no-conditional-empty-object-spread.ts +0 -42
- package/src/rules/no-duplicated-literal-union.ts +0 -66
- package/src/rules/no-exported-mutable-state.ts +0 -111
- package/src/rules/no-generic-export-names.ts +0 -149
- package/src/rules/no-impossible-branch-throw.ts +0 -55
- package/src/rules/no-known-value-widening.ts +0 -225
- package/src/rules/no-module-mocking.ts +0 -95
- package/src/rules/no-multiple-function-params.ts +0 -192
- package/src/rules/no-nondeterministic-core.ts +0 -73
- package/src/rules/no-object-parameters.ts +0 -127
- package/src/rules/no-optional-function-parameters.ts +0 -49
- package/src/rules/no-product-of-state-booleans.ts +0 -80
- package/src/rules/no-redundant-derived-field.ts +0 -192
- package/src/rules/no-reflect-apply.ts +0 -32
- package/src/rules/no-reflect-get.ts +0 -32
- package/src/rules/no-reinterpret-cast.ts +0 -78
- package/src/rules/no-runtime-typeof.ts +0 -59
- package/src/rules/no-sentinel-comparison-union.ts +0 -148
- package/src/rules/no-shape-in-symbol-names.ts +0 -45
- package/src/rules/no-single-use-private-functions.ts +0 -329
- package/src/rules/no-stacked-jsdoc-blocks.ts +0 -65
- package/src/rules/no-stray-inline-comments.ts +0 -79
- package/src/rules/no-swappable-primitive-params.ts +0 -109
- package/src/rules/no-tag-ladder-assertions.ts +0 -71
- package/src/rules/no-transposed-field-reads.ts +0 -135
- package/src/rules/no-unit-return-validators.ts +0 -65
- package/src/rules/no-unknown-parameters.ts +0 -97
- package/src/rules/no-unknown-returns.ts +0 -120
- package/src/rules/no-unknown-type-aliases.ts +0 -70
- package/src/rules/no-unsafe-dictionary-type.ts +0 -132
- package/src/rules/no-vague-test-filenames.ts +0 -67
- package/src/rules/no-widen-then-assert.ts +0 -345
- package/src/rules/prefer-payload-brand.ts +0 -67
- package/src/rules/prefer-property-tests.ts +0 -43
- package/src/rules/require-canonical-stringify-for-identity.ts +0 -80
- package/src/rules/require-deprecated-tag-for-legacy-comments.ts +0 -45
- package/src/rules/require-exhaustive-tag-switch.ts +0 -42
- package/src/rules/require-fc-block-predicate.ts +0 -42
- package/src/rules/require-jsdoc-on-exported.ts +0 -74
- package/src/rules/require-published-order.ts +0 -109
- package/src/rules/require-safety-comment-for-type-assertion.ts +0 -61
- package/src/rules/require-sort-comparator.ts +0 -41
- package/src/rules/test-utils.ts +0 -68
- package/src/shared/child-nodes.ts +0 -27
- package/src/shared/dictionary-types.ts +0 -524
- package/src/shared/lexical-type-parameters.ts +0 -62
- package/src/shared/reflect-method.ts +0 -41
- package/src/testing/testable-rule.test.ts +0 -68
- package/src/testing/testable-rule.ts +0 -86
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
/**
|
|
3
|
+
* Inline suppression comments hide lint failures from the exact files where
|
|
4
|
+
* enforcement matters most. Fix the code or scope a justified override in the
|
|
5
|
+
* config; do not silence rules line-by-line.
|
|
6
|
+
*/
|
|
7
|
+
export const noDisableDirectivesRule = defineRule({
|
|
8
|
+
meta: {
|
|
9
|
+
type: "problem",
|
|
10
|
+
docs: {
|
|
11
|
+
description: "Disallow `// oxlint-disable` suppression comments; fix the finding or add a justified file-scoped config override instead.",
|
|
12
|
+
},
|
|
13
|
+
messages: {
|
|
14
|
+
suppressionDirective: "Inline suppression comments make findings invisible without making them gone. Prefer fixing the code; if an exception is truly warranted, use a scoped override entry in oxlint.config.ts with a written reason.",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
createOnce(context) {
|
|
18
|
+
let program = null;
|
|
19
|
+
return {
|
|
20
|
+
Program(node) {
|
|
21
|
+
program = node;
|
|
22
|
+
},
|
|
23
|
+
"Program:exit"() {
|
|
24
|
+
if (program === null)
|
|
25
|
+
return;
|
|
26
|
+
for (const comment of context.sourceCode.getAllComments()) {
|
|
27
|
+
if (!/^\s*oxlint-disable\b/u.test(comment.value))
|
|
28
|
+
continue;
|
|
29
|
+
context.report({ node: program, messageId: "suppressionDirective" });
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
/** Hand-rolled `.parent` loops duplicate sourceCode.getAncestors and hide traversal intent. */
|
|
3
|
+
export const noManualAncestorWalksRule = defineRule({
|
|
4
|
+
meta: {
|
|
5
|
+
type: "suggestion",
|
|
6
|
+
docs: {
|
|
7
|
+
description: "Disallow manual `.parent` walks; use `context.sourceCode.getAncestors(node)`.",
|
|
8
|
+
},
|
|
9
|
+
messages: {
|
|
10
|
+
useGetAncestors: "Hand-rolled ancestor walking via `.parent` obscures traversal intent. Use `context.sourceCode.getAncestors(node)` (root-first array) and express the search declaratively.",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
createOnce(context) {
|
|
14
|
+
return {
|
|
15
|
+
MemberExpression(node) {
|
|
16
|
+
if (node.computed)
|
|
17
|
+
return;
|
|
18
|
+
if (node.property.type !== "Identifier")
|
|
19
|
+
return;
|
|
20
|
+
if (node.property.name !== "parent")
|
|
21
|
+
return;
|
|
22
|
+
context.report({ node, messageId: "useGetAncestors" });
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
import { isString, readField } from "../../shared/structural.js";
|
|
3
|
+
/**
|
|
4
|
+
* Property-name reader for visitor properties. The `Property` selector receives
|
|
5
|
+
* Object/Binding/AssignmentTarget properties; all share this structural shape.
|
|
6
|
+
*
|
|
7
|
+
* @param {{ readonly computed: boolean; readonly key: ESTree.Expression | ESTree.PrivateIdentifier }} node - A visited property node.
|
|
8
|
+
* @returns {string | null} The non-computed property's identifier or literal string name.
|
|
9
|
+
*/
|
|
10
|
+
function propertyName(node) {
|
|
11
|
+
if (node.computed)
|
|
12
|
+
return null;
|
|
13
|
+
const key = node.key;
|
|
14
|
+
const name = readField(key, "name");
|
|
15
|
+
if (readField(key, "type") === "Identifier" && isString(name))
|
|
16
|
+
return name;
|
|
17
|
+
const value = readField(key, "value");
|
|
18
|
+
if (readField(key, "type") === "Literal" && isString(value))
|
|
19
|
+
return value;
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
/** File-scoping logic belongs in the `before` hook, not scattered through visitors or `create`. */
|
|
23
|
+
export const preferBeforeFileScopeRule = defineRule({
|
|
24
|
+
meta: {
|
|
25
|
+
type: "suggestion",
|
|
26
|
+
docs: {
|
|
27
|
+
description: "Read `context.filename` only inside a `before` hook; skip the file by returning `false` there.",
|
|
28
|
+
},
|
|
29
|
+
messages: {
|
|
30
|
+
moveToBefore: "File-scoping read of `context.filename` outside `before()`. Do file selection in `before()` and return `false` to skip the file, keeping visitors free of filename checks.",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
createOnce(context) {
|
|
34
|
+
let insideBeforeHook = false;
|
|
35
|
+
return {
|
|
36
|
+
Property(node) {
|
|
37
|
+
if (!insideBeforeHook && propertyName(node) === "before")
|
|
38
|
+
insideBeforeHook = true;
|
|
39
|
+
},
|
|
40
|
+
"Property:exit"(node) {
|
|
41
|
+
if (insideBeforeHook && propertyName(node) === "before")
|
|
42
|
+
insideBeforeHook = false;
|
|
43
|
+
},
|
|
44
|
+
MemberExpression(node) {
|
|
45
|
+
if (insideBeforeHook)
|
|
46
|
+
return;
|
|
47
|
+
if (node.computed)
|
|
48
|
+
return;
|
|
49
|
+
if (node.object.type !== "Identifier" || node.object.name !== "context")
|
|
50
|
+
return;
|
|
51
|
+
if (node.property.type !== "Identifier" || node.property.name !== "filename")
|
|
52
|
+
return;
|
|
53
|
+
context.report({ node, messageId: "moveToBefore" });
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
import { isString } from "../../shared/structural.js";
|
|
3
|
+
/**
|
|
4
|
+
* Static property name of an object property node.
|
|
5
|
+
*
|
|
6
|
+
* @param {ESTree.ObjectProperty} key - The property node to inspect.
|
|
7
|
+
* @returns {string | null} The identifier or literal string name, or null when computed.
|
|
8
|
+
*/
|
|
9
|
+
function propertyName(key) {
|
|
10
|
+
if (key.computed)
|
|
11
|
+
return null;
|
|
12
|
+
if (key.key.type === "Identifier")
|
|
13
|
+
return key.key.name;
|
|
14
|
+
if (key.key.type === "Literal" && isString(key.key.value))
|
|
15
|
+
return key.key.value;
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
/** Rule objects should opt into Oxlint's performant createOnce API, not ESLint's per-file create. */
|
|
19
|
+
export const requireCreateOnceRule = defineRule({
|
|
20
|
+
meta: {
|
|
21
|
+
type: "suggestion",
|
|
22
|
+
docs: {
|
|
23
|
+
description: "Require `createOnce` instead of `create` when authoring Oxlint rules.",
|
|
24
|
+
},
|
|
25
|
+
messages: {
|
|
26
|
+
useCreateOnce: "`create` re-runs per file and blocks Oxlint's Rust-side traversal optimizations. Use `createOnce` (per-file setup belongs in the `before` hook).",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
createOnce(context) {
|
|
30
|
+
const visitObject = (node) => {
|
|
31
|
+
const keys = new Set();
|
|
32
|
+
let createProperty = null;
|
|
33
|
+
for (const property of node.properties) {
|
|
34
|
+
if (property.type !== "Property")
|
|
35
|
+
continue;
|
|
36
|
+
const name = propertyName(property);
|
|
37
|
+
if (name === null)
|
|
38
|
+
continue;
|
|
39
|
+
keys.add(name);
|
|
40
|
+
if (name === "create")
|
|
41
|
+
createProperty = property;
|
|
42
|
+
}
|
|
43
|
+
if (createProperty !== null && keys.has("meta")) {
|
|
44
|
+
context.report({ node: createProperty, messageId: "useCreateOnce" });
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
ObjectExpression: visitObject,
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
const RULE_TEST_FILE = /[/\\](?:rules|effect[/\\]rules|meta[/\\]rules)[/\\][^/\\]+\.test\.[cm]?[jt]sx?$/u;
|
|
3
|
+
/** Tests for lint rules belong in Oxlint's RuleTester: valid/invalid cases with message and span assertions. */
|
|
4
|
+
export const requireRuleTesterRule = defineRule({
|
|
5
|
+
meta: {
|
|
6
|
+
type: "suggestion",
|
|
7
|
+
docs: {
|
|
8
|
+
description: "Require test files co-located with lint rules to drive the rule through `RuleTester` (oxlint/plugins-dev).",
|
|
9
|
+
},
|
|
10
|
+
messages: {
|
|
11
|
+
useRuleTester: "This test file sits next to a lint rule but does not import `RuleTester` from `oxlint/plugins-dev`. Rule behavior should be pinned through valid/invalid cases with message and span assertions.",
|
|
12
|
+
neverRuns: "`RuleTester` is imported but `run()` is never called. Every rule suite must execute `ruleTester.run(...)`.",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
createOnce(context) {
|
|
16
|
+
let program = null;
|
|
17
|
+
let importsRuleTester = false;
|
|
18
|
+
let callsRun = false;
|
|
19
|
+
return {
|
|
20
|
+
before() {
|
|
21
|
+
if (!RULE_TEST_FILE.test(context.filename.replaceAll("\\", "/")))
|
|
22
|
+
return false;
|
|
23
|
+
},
|
|
24
|
+
Program(node) {
|
|
25
|
+
program = node;
|
|
26
|
+
},
|
|
27
|
+
ImportDeclaration(node) {
|
|
28
|
+
const usesRuleTester = node.specifiers.some((specifier) => specifier.type === "ImportSpecifier" && specifier.imported.type === "Identifier" && specifier.imported.name === "RuleTester");
|
|
29
|
+
if (usesRuleTester)
|
|
30
|
+
importsRuleTester = true;
|
|
31
|
+
},
|
|
32
|
+
CallExpression(node) {
|
|
33
|
+
if (node.callee.type === "MemberExpression" &&
|
|
34
|
+
!node.callee.computed &&
|
|
35
|
+
node.callee.property.type === "Identifier" &&
|
|
36
|
+
node.callee.property.name === "run") {
|
|
37
|
+
callsRun = true;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"Program:exit"() {
|
|
41
|
+
if (program === null)
|
|
42
|
+
return;
|
|
43
|
+
if (!importsRuleTester)
|
|
44
|
+
context.report({ node: program, messageId: "useRuleTester" });
|
|
45
|
+
else if (!callsRun)
|
|
46
|
+
context.report({ node: program, messageId: "neverRuns" });
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dense representations are sliceable on any axis because their parts are
|
|
3
|
+
* named. Past two elements, positional tuples hide which position carries
|
|
4
|
+
* which fact: swap-prone, unreadable at call sites, and impossible to
|
|
5
|
+
* slice meaningfully. Give wide tuples a named shape.
|
|
6
|
+
*/
|
|
7
|
+
export declare const noAnonymousWideTuplesRule: import("@oxlint/plugins").Rule;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
import { readField } from "../shared/structural.js";
|
|
3
|
+
/**
|
|
4
|
+
* Dense representations are sliceable on any axis because their parts are
|
|
5
|
+
* named. Past two elements, positional tuples hide which position carries
|
|
6
|
+
* which fact: swap-prone, unreadable at call sites, and impossible to
|
|
7
|
+
* slice meaningfully. Give wide tuples a named shape.
|
|
8
|
+
*/
|
|
9
|
+
export const noAnonymousWideTuplesRule = defineRule({
|
|
10
|
+
meta: {
|
|
11
|
+
type: "suggestion",
|
|
12
|
+
docs: {
|
|
13
|
+
description: "Disallow anonymous tuple types of three or more elements; use a named object so every field's role is explicit.",
|
|
14
|
+
},
|
|
15
|
+
messages: {
|
|
16
|
+
wideTuple: "This {{count}}-element tuple leaves {{count}} unnamed positions whose meaning lives only in the reader's head. Declare a named object (or tagged union) instead so fields are self-describing.",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
createOnce(context) {
|
|
20
|
+
return {
|
|
21
|
+
TSTupleType(node) {
|
|
22
|
+
const elements = readField(node, "elementTypes") ?? [];
|
|
23
|
+
const count = elements.length;
|
|
24
|
+
if (count < 3)
|
|
25
|
+
return;
|
|
26
|
+
context.report({
|
|
27
|
+
node,
|
|
28
|
+
messageId: "wideTuple",
|
|
29
|
+
data: { count: String(count) },
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
/** Barrel `export *` erases the names it forwards, forcing search-driven readers back inside the package. */
|
|
3
|
+
export const noBarrelExportStarRule = defineRule({
|
|
4
|
+
meta: {
|
|
5
|
+
type: "problem",
|
|
6
|
+
docs: {
|
|
7
|
+
description: "Disallow `export * from ...` re-exports because the star erases forwarded names; an agent navigating by text search cannot resolve which module owns a symbol and must re-grep inside the package.",
|
|
8
|
+
},
|
|
9
|
+
messages: {
|
|
10
|
+
erasesForwardedNames: "`export * from '{{source}}'` erases the names it forwards; readers resolving a symbol through this barrel must grep inside the package instead. Re-export the explicit names.",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
createOnce(context) {
|
|
14
|
+
return {
|
|
15
|
+
ExportAllDeclaration(node) {
|
|
16
|
+
if (node.exported !== null && node.exported !== undefined)
|
|
17
|
+
return;
|
|
18
|
+
context.report({
|
|
19
|
+
node,
|
|
20
|
+
messageId: "erasesForwardedNames",
|
|
21
|
+
data: { source: String(node.source.value) },
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
const COMPARISON_OPERATORS = new Set(["===", "!==", "==", "!=", "<", ">", "<=", ">="]);
|
|
3
|
+
const CONSTRUCTOR_NAME = /^(?:make[A-Z]|make$|fromRaw|unsafeMake)/u;
|
|
4
|
+
function parameterAnnotation(parameter) {
|
|
5
|
+
if (parameter.type === "TSParameterProperty") {
|
|
6
|
+
return parameterAnnotation(parameter.parameter);
|
|
7
|
+
}
|
|
8
|
+
if (parameter.type === "RestElement") {
|
|
9
|
+
return parameter.typeAnnotation ?? parameterAnnotation(parameter.argument);
|
|
10
|
+
}
|
|
11
|
+
if (parameter.type === "AssignmentPattern") {
|
|
12
|
+
return parameter.typeAnnotation ?? parameter.left.typeAnnotation;
|
|
13
|
+
}
|
|
14
|
+
return parameter.typeAnnotation;
|
|
15
|
+
}
|
|
16
|
+
function referencedTypeName(type) {
|
|
17
|
+
if (type.type === "TSParenthesizedType")
|
|
18
|
+
return referencedTypeName(type.typeAnnotation);
|
|
19
|
+
if (type.type !== "TSTypeReference" || type.typeName.type !== "Identifier")
|
|
20
|
+
return null;
|
|
21
|
+
return type.typeName.name;
|
|
22
|
+
}
|
|
23
|
+
function isLiteralExpression(expression) {
|
|
24
|
+
if (expression.type === "Literal")
|
|
25
|
+
return true;
|
|
26
|
+
return (expression.type === "UnaryExpression" &&
|
|
27
|
+
expression.operator === "-" &&
|
|
28
|
+
expression.argument.type === "Literal");
|
|
29
|
+
}
|
|
30
|
+
function isParamField(payload) {
|
|
31
|
+
const { expression, paramName } = payload;
|
|
32
|
+
if (expression.type === "PrivateIdentifier")
|
|
33
|
+
return false;
|
|
34
|
+
if (expression.type !== "MemberExpression" || expression.object.type !== "Identifier") {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (expression.object.name !== paramName)
|
|
38
|
+
return false;
|
|
39
|
+
if (expression.computed)
|
|
40
|
+
return expression.property.type === "Literal";
|
|
41
|
+
return expression.property.type === "Identifier" || expression.property.type === "PrivateIdentifier";
|
|
42
|
+
}
|
|
43
|
+
function isFieldSignalBody(payload) {
|
|
44
|
+
const { expression, paramName } = payload;
|
|
45
|
+
if (expression.type === "LogicalExpression") {
|
|
46
|
+
return (isFieldSignalBody({ expression: expression.left, paramName }) &&
|
|
47
|
+
isFieldSignalBody({ expression: expression.right, paramName }));
|
|
48
|
+
}
|
|
49
|
+
if (expression.type === "UnaryExpression" && expression.operator === "!") {
|
|
50
|
+
return isFieldSignalBody({ expression: expression.argument, paramName });
|
|
51
|
+
}
|
|
52
|
+
if (expression.type === "ParenthesizedExpression") {
|
|
53
|
+
return isFieldSignalBody({ expression: expression.expression, paramName });
|
|
54
|
+
}
|
|
55
|
+
if (expression.type === "BinaryExpression" && COMPARISON_OPERATORS.has(expression.operator)) {
|
|
56
|
+
const fieldOnLeft = isParamField({ expression: expression.left, paramName });
|
|
57
|
+
const literalOnRight = isLiteralExpression(expression.right);
|
|
58
|
+
const fieldOnRight = isParamField({ expression: expression.right, paramName });
|
|
59
|
+
const literalOnLeft = isLiteralExpression(expression.left);
|
|
60
|
+
return (fieldOnLeft && literalOnRight) || (fieldOnRight && literalOnLeft);
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build a predicate-analysis candidate when the function reads as a boolean
|
|
66
|
+
* classification derived solely from comparing one typed parameter's fields.
|
|
67
|
+
*
|
|
68
|
+
* @param {PredicateFunction} node - The exported function node under analysis.
|
|
69
|
+
* @returns {PredicateCandidate | null} The candidate, or null when not a field-signal predicate.
|
|
70
|
+
*/
|
|
71
|
+
function candidateFrom(node) {
|
|
72
|
+
if (node.returnType === null || node.returnType === undefined)
|
|
73
|
+
return null;
|
|
74
|
+
const returnType = node.returnType.typeAnnotation;
|
|
75
|
+
if (returnType.type !== "TSBooleanKeyword")
|
|
76
|
+
return null;
|
|
77
|
+
if (node.params.length !== 1)
|
|
78
|
+
return null;
|
|
79
|
+
const firstParam = node.params[0];
|
|
80
|
+
if (firstParam === undefined)
|
|
81
|
+
return null;
|
|
82
|
+
const annotation = parameterAnnotation(firstParam);
|
|
83
|
+
if (annotation === null || annotation === undefined)
|
|
84
|
+
return null;
|
|
85
|
+
const typeName = referencedTypeName(annotation.typeAnnotation);
|
|
86
|
+
if (typeName === null)
|
|
87
|
+
return null;
|
|
88
|
+
let body = null;
|
|
89
|
+
if (node.body !== null && node.body !== undefined) {
|
|
90
|
+
if (node.body.type === "BlockStatement") {
|
|
91
|
+
const only = node.body.body.length === 1 ? node.body.body[0] : undefined;
|
|
92
|
+
if (only !== undefined && only.type === "ReturnStatement" && only.argument !== null) {
|
|
93
|
+
body = only.argument;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
body = node.body;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (body === null)
|
|
101
|
+
return null;
|
|
102
|
+
if (!isFieldSignalBody({
|
|
103
|
+
expression: body,
|
|
104
|
+
paramName: firstParam.type === "Identifier" ? firstParam.name : "",
|
|
105
|
+
})) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return { node, typeName };
|
|
109
|
+
}
|
|
110
|
+
const AUXILIARIES = new Set(["is", "has", "can", "should", "was", "will", "did", "be", "the"]);
|
|
111
|
+
/** Split a camelCase/separator name into lowercase tokens, dropping auxiliary prefixes like `is`/`has`.
|
|
112
|
+
*
|
|
113
|
+
* @param {string} name - The name to tokenise.
|
|
114
|
+
* @returns {string[]} Content-bearing lowercase tokens.
|
|
115
|
+
*/
|
|
116
|
+
function contentTokens(name) {
|
|
117
|
+
return name
|
|
118
|
+
.replaceAll(/([a-z0-9])([A-Z])/gu, "$1 $2")
|
|
119
|
+
.split(/[^a-zA-Z0-9]+/u)
|
|
120
|
+
.map((token) => token.toLowerCase())
|
|
121
|
+
.filter((token) => token.length > 0 && !AUXILIARIES.has(token));
|
|
122
|
+
}
|
|
123
|
+
/** Accept both `{ members }` and flattened `{ body }` shapes for an interface/type-literal body.
|
|
124
|
+
*
|
|
125
|
+
* @param {ESTree.TSInterfaceBody | ESTree.TSTypeLiteral} bodyNode - The declared body node.
|
|
126
|
+
* @returns {ESTree.TSSignature[]} The signature list.
|
|
127
|
+
*/
|
|
128
|
+
function memberList(bodyNode) {
|
|
129
|
+
const members = "body" in bodyNode ? bodyNode.body : bodyNode.members;
|
|
130
|
+
return [...members];
|
|
131
|
+
}
|
|
132
|
+
/** Ban predicate families that re-derive classification, and un-guarded construction. */
|
|
133
|
+
export const noBooleanFieldSignalsRule = defineRule({
|
|
134
|
+
meta: {
|
|
135
|
+
type: "problem",
|
|
136
|
+
docs: {
|
|
137
|
+
description: "Disallow families of exported predicates over one type that re-test the same fields, constructors that produce un-guarded values, and boolean state products on declared types; classify (parse) once.",
|
|
138
|
+
},
|
|
139
|
+
messages: {
|
|
140
|
+
reportPredicate: "Predicates over `{{type}}` each re-derive classification from the same field comparisons. Classify the value once into a named union (or comparable structure) and derive the predicates from it.",
|
|
141
|
+
booleanFieldSignals: "Predicates over `{{type}}` each re-derive classification from the same field comparisons. Classify the value once into a named union (or comparable structure) and derive the predicates from it.",
|
|
142
|
+
unguardedConstructor: "`{{type}}` is constructed directly by `make` yet inspected by a predicate family. Make the constructor a parser (normalise or return Option) so invalid states can't be produced.",
|
|
143
|
+
booleanStateProduct: "`{{name}}` carries {{count}} boolean {{kind}} admitting invalid combinations. Classify once into a named union over that state so impossible combinations can't be represented, and derive any predicates from it.",
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
createOnce(context) {
|
|
147
|
+
const pending = new Map();
|
|
148
|
+
const reported = new Set();
|
|
149
|
+
const constructors = new Map();
|
|
150
|
+
const reportPredicate = (candidate) => {
|
|
151
|
+
context.report({
|
|
152
|
+
node: candidate.node,
|
|
153
|
+
messageId: "booleanFieldSignals",
|
|
154
|
+
data: { type: candidate.typeName },
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
const flushConstructors = (typeName) => {
|
|
158
|
+
const list = constructors.get(typeName);
|
|
159
|
+
if (list === undefined)
|
|
160
|
+
return;
|
|
161
|
+
for (const node of list) {
|
|
162
|
+
context.report({ node, messageId: "unguardedConstructor", data: { type: typeName } });
|
|
163
|
+
}
|
|
164
|
+
constructors.delete(typeName);
|
|
165
|
+
};
|
|
166
|
+
const recordPredicate = (candidate) => {
|
|
167
|
+
if (candidate === null)
|
|
168
|
+
return;
|
|
169
|
+
if (reported.has(candidate.typeName)) {
|
|
170
|
+
reportPredicate(candidate);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const first = pending.get(candidate.typeName);
|
|
174
|
+
if (first !== undefined) {
|
|
175
|
+
reportPredicate(first);
|
|
176
|
+
reportPredicate(candidate);
|
|
177
|
+
reported.add(candidate.typeName);
|
|
178
|
+
pending.delete(candidate.typeName);
|
|
179
|
+
flushConstructors(candidate.typeName);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
pending.set(candidate.typeName, candidate);
|
|
183
|
+
};
|
|
184
|
+
const recordConstructor = (typeName, node) => {
|
|
185
|
+
if (typeName === null)
|
|
186
|
+
return;
|
|
187
|
+
if (reported.has(typeName)) {
|
|
188
|
+
context.report({ node, messageId: "unguardedConstructor", data: { type: typeName } });
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const list = constructors.get(typeName) ?? [];
|
|
192
|
+
list.push(node);
|
|
193
|
+
constructors.set(typeName, list);
|
|
194
|
+
};
|
|
195
|
+
const checkDeclaredBody = (reportNode, members, typeName) => {
|
|
196
|
+
const booleanNames = members.flatMap((member) => {
|
|
197
|
+
if (member.type !== "TSPropertySignature")
|
|
198
|
+
return [];
|
|
199
|
+
if (member.typeAnnotation?.typeAnnotation.type !== "TSBooleanKeyword")
|
|
200
|
+
return [];
|
|
201
|
+
return member.key.type === "Identifier" ? [member.key.name] : [];
|
|
202
|
+
});
|
|
203
|
+
if (booleanNames.length >= 3) {
|
|
204
|
+
context.report({
|
|
205
|
+
node: reportNode,
|
|
206
|
+
messageId: "booleanStateProduct",
|
|
207
|
+
data: { name: typeName, count: String(booleanNames.length), kind: "flags" },
|
|
208
|
+
});
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
for (let i = 0; i < booleanNames.length; i += 1) {
|
|
212
|
+
for (let j = i + 1; j < booleanNames.length; j += 1) {
|
|
213
|
+
const first = contentTokens(booleanNames[i] ?? "");
|
|
214
|
+
const second = contentTokens(booleanNames[j] ?? "");
|
|
215
|
+
const shared = first.find((token) => second.includes(token));
|
|
216
|
+
if (shared === undefined)
|
|
217
|
+
continue;
|
|
218
|
+
context.report({
|
|
219
|
+
node: reportNode,
|
|
220
|
+
messageId: "booleanStateProduct",
|
|
221
|
+
data: { name: `${booleanNames[i]}/${booleanNames[j]}`, count: "2", kind: `flags over \`${shared}\`` },
|
|
222
|
+
});
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const handle = (name, fn, rawNode) => {
|
|
228
|
+
const firstParameter = fn.params[0];
|
|
229
|
+
const boundParameter = firstParameter === undefined
|
|
230
|
+
? null
|
|
231
|
+
: firstParameter.type === "Identifier"
|
|
232
|
+
? firstParameter.name
|
|
233
|
+
: firstParameter.type === "AssignmentPattern" && firstParameter.left.type === "Identifier"
|
|
234
|
+
? firstParameter.left.name
|
|
235
|
+
: null;
|
|
236
|
+
if (boundParameter !== null)
|
|
237
|
+
recordPredicate(candidateFrom(fn));
|
|
238
|
+
const declaredReturn = fn.returnType === null || fn.returnType === undefined
|
|
239
|
+
? null
|
|
240
|
+
: referencedTypeName(fn.returnType.typeAnnotation);
|
|
241
|
+
const ctorReturn = CONSTRUCTOR_NAME.test(name) ? declaredReturn : null;
|
|
242
|
+
if (ctorReturn !== null &&
|
|
243
|
+
(fn.type === "FunctionDeclaration" || fn.type === "FunctionExpression") &&
|
|
244
|
+
fn.id !== null) {
|
|
245
|
+
recordConstructor(ctorReturn, fn);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
return {
|
|
249
|
+
ExportNamedDeclaration(node) {
|
|
250
|
+
const declaration = node.declaration;
|
|
251
|
+
if (declaration === null)
|
|
252
|
+
return;
|
|
253
|
+
if (declaration.type === "FunctionDeclaration") {
|
|
254
|
+
if (declaration.id !== null)
|
|
255
|
+
handle(declaration.id.name, declaration, declaration);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (declaration.type !== "VariableDeclaration")
|
|
259
|
+
return;
|
|
260
|
+
for (const declarator of declaration.declarations) {
|
|
261
|
+
const init = declarator.init;
|
|
262
|
+
if (init === null || init === undefined || init.type !== "ArrowFunctionExpression")
|
|
263
|
+
continue;
|
|
264
|
+
if (declarator.id.type !== "Identifier")
|
|
265
|
+
continue;
|
|
266
|
+
handle(declarator.id.name, init, declarator);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
TSInterfaceDeclaration(node) {
|
|
270
|
+
checkDeclaredBody(node, memberList(node.body), node.id.type === "Identifier" ? node.id.name : "anonymous interface");
|
|
271
|
+
},
|
|
272
|
+
TSTypeAliasDeclaration(node) {
|
|
273
|
+
if (node.typeAnnotation.type !== "TSTypeLiteral")
|
|
274
|
+
return;
|
|
275
|
+
checkDeclaredBody(node, node.typeAnnotation.members, node.id.name);
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
},
|
|
279
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flag throwing generic built-in errors at call sites that should instead throw
|
|
3
|
+
* a project-defined tagged error carrying its evidence structurally (e.g.
|
|
4
|
+
* Data.TaggedError with operation/value/domain fields plus a rendered message).
|
|
5
|
+
*/
|
|
6
|
+
export declare const noBuiltinThrowsRule: import("@oxlint/plugins").Rule;
|