@autotelic/plumb 0.5.2 → 0.6.1
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 +81 -8
- package/dist/configs/recommended-rules.d.ts +36 -0
- package/dist/configs/recommended-rules.js +57 -0
- package/dist/effect/index.js +4 -0
- package/dist/effect/rules/guarded-op-must-return-effect.js +1 -1
- package/dist/effect/rules/no-cascading-layer-provide.js +1 -1
- package/dist/effect/rules/no-decode-unknown-option.js +1 -1
- package/dist/effect/rules/no-direct-browser-storage.js +3 -3
- package/dist/effect/rules/no-direct-fetch.js +1 -1
- package/dist/effect/rules/no-manual-field-guards.js +1 -1
- package/dist/effect/rules/no-nested-layer-provide.js +1 -1
- package/dist/effect/rules/no-nullish-default-on-partial-input.d.ts +13 -0
- package/dist/effect/rules/no-nullish-default-on-partial-input.js +109 -0
- package/dist/effect/rules/no-raw-error-forwarding.d.ts +16 -0
- package/dist/effect/rules/no-raw-error-forwarding.js +108 -0
- package/dist/effect/rules/no-silent-error-swallow.js +1 -1
- package/dist/effect/rules/no-static-effect-service-forwarders.js +5 -4
- package/dist/effect/rules/no-try-catch.js +1 -1
- package/dist/effect/rules/no-unguarded-json-parse.js +1 -1
- package/dist/effect/rules/option-core-needs-effect-public.js +1 -1
- package/dist/effect/rules/prefer-die-for-precondition-defects.js +1 -1
- package/dist/effect/rules/prefer-effect-gen-for-guard-ladders.js +1 -1
- package/dist/effect/rules/prefer-effect-match.js +2 -2
- package/dist/effect/rules/prefer-effect-predicate-over-boolean-function.js +1 -1
- package/dist/effect/rules/prefer-named-guard-predicate.js +1 -1
- package/dist/effect/rules/prefer-option-pipeline.js +13 -12
- package/dist/effect/rules/prefer-ordering-match.js +1 -1
- package/dist/effect/rules/prefer-tagged-enum.js +1 -1
- package/dist/effect/rules/require-schema-type-derivation.d.ts +8 -2
- package/dist/effect/rules/require-schema-type-derivation.js +14 -4
- package/dist/index.js +10 -0
- package/dist/react/rules/require-dot-notation-exports.js +1 -1
- package/dist/react/rules/require-guarded-context-hook.js +1 -1
- package/dist/react/rules/require-tripartite-context.js +1 -1
- package/dist/react/rules/use-encapsulation.js +1 -1
- package/dist/rules/no-adapter-in-values.d.ts +12 -0
- package/dist/rules/no-adapter-in-values.js +110 -0
- package/dist/rules/no-builtin-throws.js +1 -1
- package/dist/rules/no-duplicated-literal-union.d.ts +7 -0
- package/dist/rules/no-duplicated-literal-union.js +5 -1
- package/dist/rules/no-generic-export-names.js +1 -1
- package/dist/rules/no-multiple-function-params.js +26 -12
- package/dist/rules/no-mutable-environment-capture.js +2 -2
- package/dist/rules/no-nondeterministic-core.js +1 -1
- package/dist/rules/no-nullable-value-field.d.ts +16 -0
- package/dist/rules/no-nullable-value-field.js +117 -0
- package/dist/rules/no-optional-function-parameters.js +1 -1
- package/dist/rules/no-row-coercion.d.ts +13 -0
- package/dist/rules/no-row-coercion.js +135 -0
- package/dist/rules/no-single-use-private-functions.js +1 -1
- package/dist/rules/no-sql-string-interpolation.d.ts +7 -0
- package/dist/rules/no-sql-string-interpolation.js +62 -0
- package/dist/rules/no-stray-inline-comments.js +1 -1
- package/dist/rules/no-string-instant.d.ts +15 -0
- package/dist/rules/no-string-instant.js +108 -0
- package/dist/rules/no-swappable-primitive-params.js +1 -1
- package/dist/rules/no-tag-ladder-assertions.js +1 -1
- package/dist/rules/no-vague-test-filenames.js +1 -1
- package/dist/rules/prefer-property-tests.d.ts +5 -0
- package/dist/rules/prefer-property-tests.js +7 -0
- package/dist/rules/require-jsdoc-on-exported.js +1 -1
- package/dist/shared/ancestors.d.ts +1 -1
- package/dist/shared/ancestors.js +1 -1
- package/dist/shared/values-path.d.ts +12 -0
- package/dist/shared/values-path.js +56 -0
- package/dist/src/configs/recommended-rules.d.ts +20 -0
- package/dist/src/configs/recommended-rules.js +22 -0
- package/dist/src/effect/index.d.ts +3 -0
- package/dist/src/effect/index.js +60 -0
- package/dist/src/effect/rules/guarded-op-must-return-effect.d.ts +6 -0
- package/dist/src/effect/rules/guarded-op-must-return-effect.js +235 -0
- package/dist/src/effect/rules/guarded-op-must-return-option.d.ts +2 -0
- package/dist/src/effect/rules/guarded-op-must-return-option.js +88 -0
- package/dist/src/effect/rules/no-cascading-layer-provide.d.ts +6 -0
- package/dist/src/effect/rules/no-cascading-layer-provide.js +73 -0
- package/dist/src/effect/rules/no-decode-unknown-option.d.ts +7 -0
- package/dist/src/effect/rules/no-decode-unknown-option.js +34 -0
- package/dist/src/effect/rules/no-direct-browser-storage.d.ts +2 -0
- package/dist/src/effect/rules/no-direct-browser-storage.js +88 -0
- package/dist/src/effect/rules/no-direct-fetch.d.ts +2 -0
- package/dist/src/effect/rules/no-direct-fetch.js +37 -0
- package/dist/src/effect/rules/no-manual-field-guards.d.ts +6 -0
- package/dist/src/effect/rules/no-manual-field-guards.js +129 -0
- package/dist/src/effect/rules/no-nested-layer-provide.d.ts +2 -0
- package/dist/src/effect/rules/no-nested-layer-provide.js +50 -0
- package/dist/src/effect/rules/no-nullish-default-on-partial-input.d.ts +13 -0
- package/dist/src/effect/rules/no-nullish-default-on-partial-input.js +109 -0
- package/dist/src/effect/rules/no-raw-error-forwarding.d.ts +12 -0
- package/dist/src/effect/rules/no-raw-error-forwarding.js +103 -0
- package/dist/src/effect/rules/no-schema-class-modeling.d.ts +2 -0
- package/dist/src/effect/rules/no-schema-class-modeling.js +52 -0
- package/dist/src/effect/rules/no-service-constructor-imports.d.ts +2 -0
- package/dist/src/effect/rules/no-service-constructor-imports.js +42 -0
- package/dist/src/effect/rules/no-silent-error-swallow.d.ts +2 -0
- package/dist/src/effect/rules/no-silent-error-swallow.js +95 -0
- package/dist/src/effect/rules/no-static-effect-service-forwarders.d.ts +6 -0
- package/dist/src/effect/rules/no-static-effect-service-forwarders.js +222 -0
- package/dist/src/effect/rules/no-try-catch.d.ts +2 -0
- package/dist/src/effect/rules/no-try-catch.js +30 -0
- package/dist/src/effect/rules/no-unguarded-json-parse.d.ts +5 -0
- package/dist/src/effect/rules/no-unguarded-json-parse.js +200 -0
- package/dist/src/effect/rules/option-core-needs-effect-public.d.ts +5 -0
- package/dist/src/effect/rules/option-core-needs-effect-public.js +76 -0
- package/dist/src/effect/rules/prefer-die-for-precondition-defects.d.ts +5 -0
- package/dist/src/effect/rules/prefer-die-for-precondition-defects.js +112 -0
- package/dist/src/effect/rules/prefer-effect-gen-for-guard-ladders.d.ts +5 -0
- package/dist/src/effect/rules/prefer-effect-gen-for-guard-ladders.js +72 -0
- package/dist/src/effect/rules/prefer-effect-match.d.ts +2 -0
- package/dist/src/effect/rules/prefer-effect-match.js +74 -0
- package/dist/src/effect/rules/prefer-effect-predicate-over-boolean-function.d.ts +2 -0
- package/dist/src/effect/rules/prefer-effect-predicate-over-boolean-function.js +75 -0
- package/dist/src/effect/rules/prefer-named-guard-predicate.d.ts +2 -0
- package/dist/src/effect/rules/prefer-named-guard-predicate.js +93 -0
- package/dist/src/effect/rules/prefer-option-pipeline.d.ts +2 -0
- package/dist/src/effect/rules/prefer-option-pipeline.js +87 -0
- package/dist/src/effect/rules/prefer-ordering-match.d.ts +2 -0
- package/dist/src/effect/rules/prefer-ordering-match.js +135 -0
- package/dist/src/effect/rules/prefer-tagged-enum.d.ts +2 -0
- package/dist/src/effect/rules/prefer-tagged-enum.js +66 -0
- package/dist/src/effect/rules/require-schema-type-derivation.d.ts +7 -0
- package/dist/src/effect/rules/require-schema-type-derivation.js +80 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +106 -0
- package/dist/src/meta/index.d.ts +7 -0
- package/dist/src/meta/index.js +22 -0
- package/dist/src/meta/rules/no-disable-directives.d.ts +6 -0
- package/dist/src/meta/rules/no-disable-directives.js +35 -0
- package/dist/src/meta/rules/no-manual-ancestor-walks.d.ts +2 -0
- package/dist/src/meta/rules/no-manual-ancestor-walks.js +26 -0
- package/dist/src/meta/rules/prefer-before-file-scope.d.ts +2 -0
- package/dist/src/meta/rules/prefer-before-file-scope.js +57 -0
- package/dist/src/meta/rules/require-create-once.d.ts +2 -0
- package/dist/src/meta/rules/require-create-once.js +51 -0
- package/dist/src/meta/rules/require-rule-tester.d.ts +2 -0
- package/dist/src/meta/rules/require-rule-tester.js +50 -0
- package/dist/src/react/index.d.ts +3 -0
- package/dist/src/react/index.js +16 -0
- package/dist/src/react/role.d.ts +23 -0
- package/dist/src/react/role.js +30 -0
- package/dist/src/react/rules/require-dot-notation-exports.d.ts +27 -0
- package/dist/src/react/rules/require-dot-notation-exports.js +144 -0
- package/dist/src/react/rules/require-guarded-context-hook.d.ts +19 -0
- package/dist/src/react/rules/require-guarded-context-hook.js +167 -0
- package/dist/src/react/rules/require-tripartite-context.d.ts +17 -0
- package/dist/src/react/rules/require-tripartite-context.js +160 -0
- package/dist/src/react/rules/use-encapsulation.d.ts +22 -0
- package/dist/src/react/rules/use-encapsulation.js +97 -0
- package/dist/src/rules/no-anonymous-wide-tuples.d.ts +7 -0
- package/dist/src/rules/no-anonymous-wide-tuples.js +34 -0
- package/dist/src/rules/no-barrel-export-star.d.ts +2 -0
- package/dist/src/rules/no-barrel-export-star.js +26 -0
- package/dist/src/rules/no-boolean-field-signals.d.ts +2 -0
- package/dist/src/rules/no-boolean-field-signals.js +279 -0
- package/dist/src/rules/no-builtin-throws.d.ts +6 -0
- package/dist/src/rules/no-builtin-throws.js +74 -0
- package/dist/src/rules/no-chained-type-assertions.d.ts +2 -0
- package/dist/src/rules/no-chained-type-assertions.js +54 -0
- package/dist/src/rules/no-conditional-empty-object-spread.d.ts +2 -0
- package/dist/src/rules/no-conditional-empty-object-spread.js +36 -0
- package/dist/src/rules/no-duplicated-literal-union.d.ts +6 -0
- package/dist/src/rules/no-duplicated-literal-union.js +66 -0
- package/dist/src/rules/no-exported-mutable-state.d.ts +7 -0
- package/dist/src/rules/no-exported-mutable-state.js +104 -0
- package/dist/src/rules/no-generic-export-names.d.ts +2 -0
- package/dist/src/rules/no-generic-export-names.js +141 -0
- package/dist/src/rules/no-impossible-branch-throw.d.ts +2 -0
- package/dist/src/rules/no-impossible-branch-throw.js +51 -0
- package/dist/src/rules/no-known-value-widening.d.ts +2 -0
- package/dist/src/rules/no-known-value-widening.js +176 -0
- package/dist/src/rules/no-module-mocking.d.ts +2 -0
- package/dist/src/rules/no-module-mocking.js +90 -0
- package/dist/src/rules/no-multiple-function-params.d.ts +2 -0
- package/dist/src/rules/no-multiple-function-params.js +155 -0
- package/dist/src/rules/no-mutable-environment-capture.d.ts +7 -0
- package/dist/src/rules/no-mutable-environment-capture.js +134 -0
- package/dist/src/rules/no-nondeterministic-core.d.ts +6 -0
- package/dist/src/rules/no-nondeterministic-core.js +63 -0
- package/dist/src/rules/no-object-parameters.d.ts +2 -0
- package/dist/src/rules/no-object-parameters.js +95 -0
- package/dist/src/rules/no-optional-function-parameters.d.ts +7 -0
- package/dist/src/rules/no-optional-function-parameters.js +44 -0
- package/dist/src/rules/no-product-of-state-booleans.d.ts +2 -0
- package/dist/src/rules/no-product-of-state-booleans.js +79 -0
- package/dist/src/rules/no-redundant-derived-field.d.ts +6 -0
- package/dist/src/rules/no-redundant-derived-field.js +194 -0
- package/dist/src/rules/no-reflect-apply.d.ts +2 -0
- package/dist/src/rules/no-reflect-apply.js +29 -0
- package/dist/src/rules/no-reflect-get.d.ts +2 -0
- package/dist/src/rules/no-reflect-get.js +29 -0
- package/dist/src/rules/no-reinterpret-cast.d.ts +2 -0
- package/dist/src/rules/no-reinterpret-cast.js +68 -0
- package/dist/src/rules/no-runtime-typeof.d.ts +2 -0
- package/dist/src/rules/no-runtime-typeof.js +54 -0
- package/dist/src/rules/no-sentinel-comparison-union.d.ts +2 -0
- package/dist/src/rules/no-sentinel-comparison-union.js +139 -0
- package/dist/src/rules/no-shape-in-symbol-names.d.ts +2 -0
- package/dist/src/rules/no-shape-in-symbol-names.js +39 -0
- package/dist/src/rules/no-single-use-private-functions.d.ts +17 -0
- package/dist/src/rules/no-single-use-private-functions.js +419 -0
- package/dist/src/rules/no-sql-string-interpolation.d.ts +7 -0
- package/dist/src/rules/no-sql-string-interpolation.js +62 -0
- package/dist/src/rules/no-stacked-jsdoc-blocks.d.ts +2 -0
- package/dist/src/rules/no-stacked-jsdoc-blocks.js +50 -0
- package/dist/src/rules/no-stray-inline-comments.d.ts +2 -0
- package/dist/src/rules/no-stray-inline-comments.js +74 -0
- package/dist/src/rules/no-swappable-primitive-params.d.ts +2 -0
- package/dist/src/rules/no-swappable-primitive-params.js +96 -0
- package/dist/src/rules/no-tag-ladder-assertions.d.ts +6 -0
- package/dist/src/rules/no-tag-ladder-assertions.js +63 -0
- package/dist/src/rules/no-transposed-field-reads.d.ts +8 -0
- package/dist/src/rules/no-transposed-field-reads.js +101 -0
- package/dist/src/rules/no-unit-return-validators.d.ts +2 -0
- package/dist/src/rules/no-unit-return-validators.js +64 -0
- package/dist/src/rules/no-unknown-parameters.d.ts +2 -0
- package/dist/src/rules/no-unknown-parameters.js +82 -0
- package/dist/src/rules/no-unknown-returns.d.ts +2 -0
- package/dist/src/rules/no-unknown-returns.js +86 -0
- package/dist/src/rules/no-unknown-type-aliases.d.ts +2 -0
- package/dist/src/rules/no-unknown-type-aliases.js +64 -0
- package/dist/src/rules/no-unsafe-dictionary-type.d.ts +2 -0
- package/dist/src/rules/no-unsafe-dictionary-type.js +116 -0
- package/dist/src/rules/no-vague-test-filenames.d.ts +2 -0
- package/dist/src/rules/no-vague-test-filenames.js +61 -0
- package/dist/src/rules/no-widen-then-assert.d.ts +2 -0
- package/dist/src/rules/no-widen-then-assert.js +268 -0
- package/dist/src/rules/prefer-payload-brand.d.ts +2 -0
- package/dist/src/rules/prefer-payload-brand.js +57 -0
- package/dist/src/rules/prefer-property-tests.d.ts +5 -0
- package/dist/src/rules/prefer-property-tests.js +39 -0
- package/dist/src/rules/require-canonical-stringify-for-identity.d.ts +8 -0
- package/dist/src/rules/require-canonical-stringify-for-identity.js +72 -0
- package/dist/src/rules/require-deprecated-tag-for-legacy-comments.d.ts +2 -0
- package/dist/src/rules/require-deprecated-tag-for-legacy-comments.js +34 -0
- package/dist/src/rules/require-exhaustive-tag-switch.d.ts +7 -0
- package/dist/src/rules/require-exhaustive-tag-switch.js +34 -0
- package/dist/src/rules/require-fc-block-predicate.d.ts +2 -0
- package/dist/src/rules/require-fc-block-predicate.js +37 -0
- package/dist/src/rules/require-jsdoc-on-exported.d.ts +2 -0
- package/dist/src/rules/require-jsdoc-on-exported.js +66 -0
- package/dist/src/rules/require-published-order.d.ts +2 -0
- package/dist/src/rules/require-published-order.js +102 -0
- package/dist/src/rules/require-safety-comment-for-type-assertion.d.ts +2 -0
- package/dist/src/rules/require-safety-comment-for-type-assertion.js +53 -0
- package/dist/src/rules/require-sort-comparator.d.ts +7 -0
- package/dist/src/rules/require-sort-comparator.js +34 -0
- package/dist/src/rules/test-utils.d.ts +35 -0
- package/dist/src/rules/test-utils.js +53 -0
- package/dist/src/shared/ancestors.d.ts +18 -0
- package/dist/src/shared/ancestors.js +19 -0
- package/dist/src/shared/child-nodes.d.ts +12 -0
- package/dist/src/shared/child-nodes.js +26 -0
- package/dist/src/shared/dictionary-types.d.ts +55 -0
- package/dist/src/shared/dictionary-types.js +413 -0
- package/dist/src/shared/is-node.d.ts +9 -0
- package/dist/src/shared/is-node.js +10 -0
- package/dist/src/shared/lexical-type-parameters.d.ts +12 -0
- package/dist/src/shared/lexical-type-parameters.js +50 -0
- package/dist/src/shared/reflect-method.d.ts +15 -0
- package/dist/src/shared/reflect-method.js +32 -0
- package/dist/src/shared/rule-options.d.ts +18 -0
- package/dist/src/shared/rule-options.js +12 -0
- package/dist/src/shared/structural.d.ts +54 -0
- package/dist/src/shared/structural.js +40 -0
- package/dist/src/testing/index.d.ts +2 -0
- package/dist/src/testing/index.js +1 -0
- package/dist/src/testing/testable-rule.d.ts +39 -0
- package/dist/src/testing/testable-rule.js +84 -0
- package/dist/src/ui/index.d.ts +12 -0
- package/dist/src/ui/index.js +18 -0
- package/dist/src/ui/manifest.d.ts +34 -0
- package/dist/src/ui/manifest.js +75 -0
- package/dist/src/ui/rules/no-deprecated-parts.d.ts +3 -0
- package/dist/src/ui/rules/no-deprecated-parts.js +131 -0
- package/dist/testing/testable-rule.d.ts +6 -5
- package/dist/testing/testable-rule.js +20 -6
- package/dist/ui/index.d.ts +12 -0
- package/dist/ui/index.js +18 -0
- package/dist/ui/manifest.d.ts +49 -0
- package/dist/ui/manifest.js +90 -0
- package/dist/ui/rules/no-deprecated-parts.d.ts +3 -0
- package/dist/ui/rules/no-deprecated-parts.js +172 -0
- package/package.json +20 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { ancestorsOf } from "../../shared/ancestors.js";
|
|
3
|
-
const TEST_FILE =
|
|
3
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
|
|
4
4
|
const EQUALITY_OPERATORS = new Set(["==", "===", "!=", "!=="]);
|
|
5
5
|
/**
|
|
6
6
|
* Whether the expression is a literal operand (literal or brace-less template).
|
|
@@ -49,7 +49,7 @@ export const preferEffectMatchRule = defineRule({
|
|
|
49
49
|
return false;
|
|
50
50
|
},
|
|
51
51
|
ConditionalExpression(node) {
|
|
52
|
-
const parent = ancestorsOf(context.sourceCode, node)
|
|
52
|
+
const parent = ancestorsOf(context.sourceCode, node).at(-1);
|
|
53
53
|
if (parent?.type === "ConditionalExpression") {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
|
-
const TEST_FILE =
|
|
2
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
3
3
|
function parameterAnnotation(parameter) {
|
|
4
4
|
if (parameter.type === "TSParameterProperty") {
|
|
5
5
|
return parameterAnnotation(parameter.parameter);
|
|
@@ -2,7 +2,7 @@ import { defineRule } from "@oxlint/plugins";
|
|
|
2
2
|
import { childNodes } from "../../shared/child-nodes.js";
|
|
3
3
|
import { readField } from "../../shared/structural.js";
|
|
4
4
|
const PREDICATE_NAME = /^is[A-Z]/u;
|
|
5
|
-
const TEST_FILE =
|
|
5
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
6
6
|
/** True for a logical chain (>= 2 operands) whose every leaf is a domain-predicate call.
|
|
7
7
|
*
|
|
8
8
|
* @param {ESTree.Expression} expression - The guard test expression.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { childNodes } from "../../shared/child-nodes.js";
|
|
3
3
|
import { readField } from "../../shared/structural.js";
|
|
4
|
-
const TEST_FILE =
|
|
4
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
5
5
|
/**
|
|
6
6
|
* Count Option.none() returns in this function's own body. Nested scopes belong to
|
|
7
|
-
* themselves, and loop bodies hold algorithmic exits rather than guard scatters.
|
|
7
|
+
* themselves, and loop bodies hold algorithmic exits rather than guard scatters. Every
|
|
8
|
+
* other node is descended into: returning early on a block body counted zero.
|
|
8
9
|
*
|
|
9
10
|
* @param {ESTree.Node} body - The function body to walk.
|
|
10
11
|
* @returns {number} Number of direct `Option.none()` return exits.
|
|
@@ -23,16 +24,16 @@ function countDirectNoneReturns(body) {
|
|
|
23
24
|
node.type === "DoWhileStatement") {
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
|
-
if (node.type
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
if (node.type === "ReturnStatement") {
|
|
28
|
+
const argument = node.argument;
|
|
29
|
+
if (argument?.type === "CallExpression" &&
|
|
30
|
+
argument.callee.type === "MemberExpression" &&
|
|
31
|
+
argument.callee.object.type === "Identifier" &&
|
|
32
|
+
argument.callee.object.name === "Option" &&
|
|
33
|
+
argument.callee.property.type === "Identifier" &&
|
|
34
|
+
argument.callee.property.name === "none")
|
|
35
|
+
count += 1;
|
|
36
|
+
}
|
|
36
37
|
for (const child of childNodes(node))
|
|
37
38
|
visit(child);
|
|
38
39
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
|
-
const TEST_FILE =
|
|
2
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
3
3
|
const ORDERING_OPERATORS = new Set(["<", ">", "<=", ">=", "===", "=="]);
|
|
4
4
|
function isZeroLiteral(expression) {
|
|
5
5
|
return (expression !== null &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { isRecordObject, isString } from "../../shared/structural.js";
|
|
3
|
-
const TEST_FILE =
|
|
3
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
4
4
|
/** Whether a type-literal member declares a literal-typed `_tag` property.
|
|
5
5
|
*
|
|
6
6
|
* @param {ESTree.Node} member - A member of a type literal.
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Single source of truth: once a Schema exists, it is the canonical shape.
|
|
3
3
|
* A hand-written twin type drifts from it silently: derive the static side
|
|
4
|
-
* with `Schema.Type<typeof x>` so identical data can only have one declared
|
|
5
|
-
*
|
|
4
|
+
* with `Schema.Type<typeof x>` so identical data can only have one declared form.
|
|
5
|
+
*
|
|
6
|
+
* Per-file state, reset in `before`: the maps describe one file's declarations, so a
|
|
7
|
+
* run never reports an interface in `b.ts` against a schema declared in `a.ts` -- at
|
|
8
|
+
* line 1, citing a name the file does not contain -- or answers differently depending
|
|
9
|
+
* on the order files were visited. An interface with a heritage clause is skipped for
|
|
10
|
+
* the same reason: `interface X extends Schema.Type<typeof XSchema>` is the fix this
|
|
11
|
+
* rule asks for, not the twin it reports.
|
|
6
12
|
*/
|
|
7
13
|
export declare const requireSchemaTypeDerivationRule: import("@oxlint/plugins").Rule;
|
|
@@ -15,7 +15,7 @@ function isSchemaStructCall(expression) {
|
|
|
15
15
|
if (callee.property.type !== "Identifier" || !STRUCT_PROPERTIES.has(callee.property.name))
|
|
16
16
|
return false;
|
|
17
17
|
const object = callee.object;
|
|
18
|
-
return
|
|
18
|
+
return object.type === "Identifier" && /schema$/iu.test(object.name);
|
|
19
19
|
}
|
|
20
20
|
/** Fold a declared name to its stem so `RationalSchema`/`rational` and `rationalSchema` collide.
|
|
21
21
|
*
|
|
@@ -29,8 +29,14 @@ function normaliseName(name) {
|
|
|
29
29
|
/**
|
|
30
30
|
* Single source of truth: once a Schema exists, it is the canonical shape.
|
|
31
31
|
* A hand-written twin type drifts from it silently: derive the static side
|
|
32
|
-
* with `Schema.Type<typeof x>` so identical data can only have one declared
|
|
33
|
-
*
|
|
32
|
+
* with `Schema.Type<typeof x>` so identical data can only have one declared form.
|
|
33
|
+
*
|
|
34
|
+
* Per-file state, reset in `before`: the maps describe one file's declarations, so a
|
|
35
|
+
* run never reports an interface in `b.ts` against a schema declared in `a.ts` -- at
|
|
36
|
+
* line 1, citing a name the file does not contain -- or answers differently depending
|
|
37
|
+
* on the order files were visited. An interface with a heritage clause is skipped for
|
|
38
|
+
* the same reason: `interface X extends Schema.Type<typeof XSchema>` is the fix this
|
|
39
|
+
* rule asks for, not the twin it reports.
|
|
34
40
|
*/
|
|
35
41
|
export const requireSchemaTypeDerivationRule = defineRule({
|
|
36
42
|
meta: {
|
|
@@ -46,6 +52,10 @@ export const requireSchemaTypeDerivationRule = defineRule({
|
|
|
46
52
|
const schemas = new Map();
|
|
47
53
|
const typeAliases = new Map();
|
|
48
54
|
return {
|
|
55
|
+
before() {
|
|
56
|
+
schemas.clear();
|
|
57
|
+
typeAliases.clear();
|
|
58
|
+
},
|
|
49
59
|
VariableDeclarator(node) {
|
|
50
60
|
if (node.id.type !== "Identifier" || node.init === null || node.init === undefined)
|
|
51
61
|
return;
|
|
@@ -59,7 +69,7 @@ export const requireSchemaTypeDerivationRule = defineRule({
|
|
|
59
69
|
typeAliases.set(normaliseName(node.id.name), { node, name: node.id.name });
|
|
60
70
|
},
|
|
61
71
|
TSInterfaceDeclaration(node) {
|
|
62
|
-
if (node.id.type !== "Identifier")
|
|
72
|
+
if (node.id.type !== "Identifier" || node.extends.length > 0)
|
|
63
73
|
return;
|
|
64
74
|
typeAliases.set(normaliseName(node.id.name), { node, name: node.id.name });
|
|
65
75
|
},
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,11 @@ import { noMultipleFunctionParamsRule } from "./rules/no-multiple-function-param
|
|
|
47
47
|
import { noOptionalFunctionParametersRule } from "./rules/no-optional-function-parameters.js";
|
|
48
48
|
import { noSingleUsePrivateFunctionsRule } from "./rules/no-single-use-private-functions.js";
|
|
49
49
|
import { noMutableEnvironmentCaptureRule } from "./rules/no-mutable-environment-capture.js";
|
|
50
|
+
import { noSqlStringInterpolationRule } from "./rules/no-sql-string-interpolation.js";
|
|
51
|
+
import { noAdapterInValuesRule } from "./rules/no-adapter-in-values.js";
|
|
52
|
+
import { noNullableValueFieldRule } from "./rules/no-nullable-value-field.js";
|
|
53
|
+
import { noRowCoercionRule } from "./rules/no-row-coercion.js";
|
|
54
|
+
import { noStringInstantRule } from "./rules/no-string-instant.js";
|
|
50
55
|
/** Generic Oxlint rules that reject low-evidence and low-signal implementation patterns. */
|
|
51
56
|
const plumbPlugin = eslintCompatPlugin({
|
|
52
57
|
meta: { name: "plumb" },
|
|
@@ -99,6 +104,11 @@ const plumbPlugin = eslintCompatPlugin({
|
|
|
99
104
|
"no-optional-function-parameters": noOptionalFunctionParametersRule,
|
|
100
105
|
"no-single-use-private-functions": noSingleUsePrivateFunctionsRule,
|
|
101
106
|
"no-mutable-environment-capture": noMutableEnvironmentCaptureRule,
|
|
107
|
+
"no-sql-string-interpolation": noSqlStringInterpolationRule,
|
|
108
|
+
"no-adapter-in-values": noAdapterInValuesRule,
|
|
109
|
+
"no-nullable-value-field": noNullableValueFieldRule,
|
|
110
|
+
"no-row-coercion": noRowCoercionRule,
|
|
111
|
+
"no-string-instant": noStringInstantRule,
|
|
102
112
|
},
|
|
103
113
|
});
|
|
104
114
|
export default plumbPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { isString } from "../../shared/structural.js";
|
|
3
3
|
import { hookFamily, isProviderName } from "../role.js";
|
|
4
|
-
const TEST_FILE =
|
|
4
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
5
5
|
/**
|
|
6
6
|
* Whether a component family (a Provider plus a useXxx hook sharing one family
|
|
7
7
|
* name) must carry a dot-notation aggregate export. The useXxx hook is the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { ancestorsOf } from "../../shared/ancestors.js";
|
|
3
3
|
import { isHookName } from "../role.js";
|
|
4
|
-
const TEST_FILE =
|
|
4
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
5
5
|
/**
|
|
6
6
|
* Whether a custom context hook that reads context must be reported for
|
|
7
7
|
* lacking a guard against a missing Provider.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { isString } from "../../shared/structural.js";
|
|
3
|
-
const TEST_FILE =
|
|
3
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
4
4
|
/** The three required keys of a context value type. */
|
|
5
5
|
const REQUIRED_KEYS = ["state", "actions", "meta"];
|
|
6
6
|
/**
|
|
@@ -2,7 +2,7 @@ import { defineRule } from "@oxlint/plugins";
|
|
|
2
2
|
import { ancestorsOf } from "../../shared/ancestors.js";
|
|
3
3
|
import { readField } from "../../shared/structural.js";
|
|
4
4
|
import { isProviderName } from "../role.js";
|
|
5
|
-
const TEST_FILE =
|
|
5
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
6
6
|
/** Pattern identifying custom hooks (names starting with `use`). */
|
|
7
7
|
const HOOK_PATTERN = /^use/u;
|
|
8
8
|
/** React's built-in hooks that must not be used directly inside components. */
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Whether an import is a cost-driven dependency the values stratum may not hold.
|
|
2
|
+
*
|
|
3
|
+
* @param {string} specifier - The import specifier.
|
|
4
|
+
* @returns {boolean} True when it is a query builder, a driver or an adapter path.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isAdapter(specifier: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The values stratum depends on nothing internal. A `Money` that can import the
|
|
9
|
+
* query builder is not a value: it is a row with a reassuring name, and the
|
|
10
|
+
* next author will put a `where` clause in it.
|
|
11
|
+
*/
|
|
12
|
+
export declare const noAdapterInValuesRule: import("@oxlint/plugins").Rule;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
import { inValuesPath } from "../shared/values-path.js";
|
|
3
|
+
/**
|
|
4
|
+
* Packages that put a value on a database, a socket or a request.
|
|
5
|
+
*
|
|
6
|
+
* A DECLARED vocabulary, like the `node:` builtins in `dependency-fit`: which
|
|
7
|
+
* driver a repository chose is a fact about the adapter, and the packages that
|
|
8
|
+
* can be one are a closed list. A repository with an in-house client adds its
|
|
9
|
+
* path to the rule's `paths` option rather than teaching the rule a new name.
|
|
10
|
+
*/
|
|
11
|
+
const ADAPTER_PACKAGES = new Set([
|
|
12
|
+
"@hapi/hapi",
|
|
13
|
+
"@nestjs/common",
|
|
14
|
+
"@prisma/client",
|
|
15
|
+
"better-sqlite3",
|
|
16
|
+
"drizzle-orm",
|
|
17
|
+
"express",
|
|
18
|
+
"fastify",
|
|
19
|
+
"hono",
|
|
20
|
+
"knex",
|
|
21
|
+
"koa",
|
|
22
|
+
"kysely",
|
|
23
|
+
"mongodb",
|
|
24
|
+
"mysql",
|
|
25
|
+
"mysql2",
|
|
26
|
+
"pg",
|
|
27
|
+
"postgres",
|
|
28
|
+
"prisma",
|
|
29
|
+
"sequelize",
|
|
30
|
+
"slonik",
|
|
31
|
+
"sqlite3",
|
|
32
|
+
"typeorm",
|
|
33
|
+
]);
|
|
34
|
+
/** Path fragments that name an adapter or a query module inside the repository. */
|
|
35
|
+
const ADAPTER_PATH_SEGMENTS = new Set(["adapter", "adapters", "db", "database", "queries", "query", "repository", "repositories"]);
|
|
36
|
+
/** The package a specifier names, so `knex/lib/query` is still `knex`.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} specifier - An import specifier.
|
|
39
|
+
* @returns {string} The package name, or the specifier when it is relative.
|
|
40
|
+
*/
|
|
41
|
+
function packageOf(specifier) {
|
|
42
|
+
const parts = specifier.split("/");
|
|
43
|
+
const [first, second] = parts;
|
|
44
|
+
if (first === undefined)
|
|
45
|
+
return specifier;
|
|
46
|
+
return first.startsWith("@") && second !== undefined ? `${first}/${second}` : first;
|
|
47
|
+
}
|
|
48
|
+
/** Whether an import is a cost-driven dependency the values stratum may not hold.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} specifier - The import specifier.
|
|
51
|
+
* @returns {boolean} True when it is a query builder, a driver or an adapter path.
|
|
52
|
+
*/
|
|
53
|
+
export function isAdapter(specifier) {
|
|
54
|
+
if (ADAPTER_PACKAGES.has(packageOf(specifier)))
|
|
55
|
+
return true;
|
|
56
|
+
if (!specifier.startsWith(".") && !specifier.startsWith("/"))
|
|
57
|
+
return false;
|
|
58
|
+
const segments = specifier.replaceAll("\\", "/").split("/");
|
|
59
|
+
return segments.some((segment) => ADAPTER_PATH_SEGMENTS.has(segment));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The values stratum depends on nothing internal. A `Money` that can import the
|
|
63
|
+
* query builder is not a value: it is a row with a reassuring name, and the
|
|
64
|
+
* next author will put a `where` clause in it.
|
|
65
|
+
*/
|
|
66
|
+
export const noAdapterInValuesRule = defineRule({
|
|
67
|
+
meta: {
|
|
68
|
+
type: "problem",
|
|
69
|
+
docs: {
|
|
70
|
+
description: "Disallow imports of query builders, database drivers, HTTP frameworks and query modules from a declared values path.",
|
|
71
|
+
},
|
|
72
|
+
messages: {
|
|
73
|
+
adapterInValues: "`{{specifier}}` belongs to the adapter, not to a value. The domain depends on nothing internal: move this import to the derivation or edge that reads it.",
|
|
74
|
+
},
|
|
75
|
+
schema: [
|
|
76
|
+
{
|
|
77
|
+
type: "object",
|
|
78
|
+
properties: {
|
|
79
|
+
paths: { type: "array", items: { type: "string" } },
|
|
80
|
+
},
|
|
81
|
+
additionalProperties: false,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
defaultOptions: [{}],
|
|
85
|
+
},
|
|
86
|
+
createOnce(context) {
|
|
87
|
+
function check(specifier, node) {
|
|
88
|
+
if (specifier === null || specifier === undefined)
|
|
89
|
+
return;
|
|
90
|
+
if (!isAdapter(specifier))
|
|
91
|
+
return;
|
|
92
|
+
context.report({ node, messageId: "adapterInValues", data: { specifier } });
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
before() {
|
|
96
|
+
if (!inValuesPath(context.filename, context.options))
|
|
97
|
+
return false;
|
|
98
|
+
},
|
|
99
|
+
ImportDeclaration(node) {
|
|
100
|
+
check(node.source.value, node);
|
|
101
|
+
},
|
|
102
|
+
ExportAllDeclaration(node) {
|
|
103
|
+
check(node.source.value, node);
|
|
104
|
+
},
|
|
105
|
+
ExportNamedDeclaration(node) {
|
|
106
|
+
check(node.source?.value, node);
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { firstOptionRecord } from "../shared/rule-options.js";
|
|
3
3
|
import { isRecordObject, isString } from "../shared/structural.js";
|
|
4
|
-
const TEST_FILE =
|
|
4
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
5
5
|
/** Generic built-in errors: untyped, prose-only, and invisible to tag-based handling. */
|
|
6
6
|
const BUILTIN_ERRORS = new Set([
|
|
7
7
|
"Error",
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import type { ESTree } from "@oxlint/plugins";
|
|
2
|
+
/** Sorted string-literal members of a union annotation, or null if it isn't one.
|
|
3
|
+
*
|
|
4
|
+
* @param {ESTree.TSType} annotation - The annotation to inspect.
|
|
5
|
+
* @returns {string[] | null} Sorted literal members, or null when not a literal union.
|
|
6
|
+
*/
|
|
7
|
+
export declare function literalUnionKey(annotation: ESTree.TSType): string[] | null;
|
|
1
8
|
/**
|
|
2
9
|
* One fact, one place: a set of variants declared twice drifts the moment
|
|
3
10
|
* someone adds a member to one copy. Declare each variant set once and
|
|
@@ -5,7 +5,7 @@ import { isRecordObject, isString } from "../shared/structural.js";
|
|
|
5
5
|
* @param {ESTree.TSType} annotation - The annotation to inspect.
|
|
6
6
|
* @returns {string[] | null} Sorted literal members, or null when not a literal union.
|
|
7
7
|
*/
|
|
8
|
-
function literalUnionKey(annotation) {
|
|
8
|
+
export function literalUnionKey(annotation) {
|
|
9
9
|
const types = annotation.type === "TSUnionType" ? annotation.types : [annotation];
|
|
10
10
|
const literals = [];
|
|
11
11
|
for (const member of types) {
|
|
@@ -36,6 +36,10 @@ export const noDuplicatedLiteralUnionRule = defineRule({
|
|
|
36
36
|
const seen = new Map();
|
|
37
37
|
const duplicates = new Map();
|
|
38
38
|
return {
|
|
39
|
+
before() {
|
|
40
|
+
seen.clear();
|
|
41
|
+
duplicates.clear();
|
|
42
|
+
},
|
|
39
43
|
TSTypeAliasDeclaration(node) {
|
|
40
44
|
const key = literalUnionKey(node.typeAnnotation);
|
|
41
45
|
if (key === null)
|
|
@@ -38,7 +38,7 @@ const GENERIC_TERMS = new Set([
|
|
|
38
38
|
"temp",
|
|
39
39
|
"tmp",
|
|
40
40
|
]);
|
|
41
|
-
const TEST_FILE =
|
|
41
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
42
42
|
/** Split an identifier into its words across camelCase and separators.
|
|
43
43
|
*
|
|
44
44
|
* @param {string} name - Identifier or filename stem to split.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { readField } from "../shared/structural.js";
|
|
3
3
|
import { ancestorsOf } from "../shared/ancestors.js";
|
|
4
|
-
const TEST_FILE =
|
|
4
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
5
5
|
const DEFAULT_MAX_PARAMS = 1;
|
|
6
6
|
/** Conventional HTTP method handler names, exempt inside framework route files. */
|
|
7
7
|
const HTTP_METHOD_NAMES = new Set([
|
|
@@ -15,19 +15,28 @@ const HTTP_METHOD_NAMES = new Set([
|
|
|
15
15
|
]);
|
|
16
16
|
const DEFAULT_ROUTE_BASENAMES = new Set(["route.ts", "route.tsx"]);
|
|
17
17
|
function parentOf(sourceCode, node) {
|
|
18
|
-
return ancestorsOf(sourceCode, node)
|
|
18
|
+
return ancestorsOf(sourceCode, node).at(-1) ?? null;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Functions the module owns: declarations and named bindings, not callbacks.
|
|
22
22
|
*
|
|
23
|
+
* A function nested inside another function is a closure — its arity is local, not part of
|
|
24
|
+
* the module's surface, so the rule does not apply. (`ancestorsOf` is outermost-first.)
|
|
25
|
+
*
|
|
23
26
|
* @param {SourceCode} sourceCode - The rule's source-code accessor.
|
|
24
27
|
* @param {ESTree.Node} node - The visited function-like node.
|
|
25
28
|
* @returns {boolean} True when the module owns the function's arity.
|
|
26
29
|
*/
|
|
27
30
|
function isOwnedFunction(sourceCode, node) {
|
|
31
|
+
const chain = ancestorsOf(sourceCode, node);
|
|
32
|
+
const nested = chain.some((ancestor) => ancestor.type === "FunctionDeclaration" ||
|
|
33
|
+
ancestor.type === "FunctionExpression" ||
|
|
34
|
+
ancestor.type === "ArrowFunctionExpression");
|
|
35
|
+
if (nested)
|
|
36
|
+
return false;
|
|
28
37
|
if (node.type === "FunctionDeclaration")
|
|
29
38
|
return true;
|
|
30
|
-
const parent =
|
|
39
|
+
const parent = chain.at(-1) ?? null;
|
|
31
40
|
if (parent === null)
|
|
32
41
|
return false;
|
|
33
42
|
const parentType = parent.type;
|
|
@@ -57,11 +66,15 @@ function isExemptRouteHandler(payload) {
|
|
|
57
66
|
const parent = parentOf(payload.sourceCode, payload.node);
|
|
58
67
|
return parent !== null && parent.type === "ExportNamedDeclaration";
|
|
59
68
|
}
|
|
60
|
-
/** Primitive annotations transpose silently; structural ones fail the compiler. */
|
|
61
|
-
const PRIMITIVE_TYPE_TEXT = /^(?:string|number|bigint|boolean|unknown|any|null|undefined|void)$/u;
|
|
62
69
|
/**
|
|
63
|
-
* Whether every positional parameter carries a distinct
|
|
64
|
-
*
|
|
70
|
+
* Whether every positional parameter carries a distinct annotated type: transposing such
|
|
71
|
+
* arguments is a compile error, so ordering needs no guard. Distinctness is the test, not
|
|
72
|
+
* primitive-versus-structural: `(name: string, count: number)` is as safe as
|
|
73
|
+
* `(left: Node, right: Node)` is unsafe, and only a repeated type transposes silently.
|
|
74
|
+
*
|
|
75
|
+
* A default value wraps the identifier in an `AssignmentPattern`; the annotation lives on
|
|
76
|
+
* the left. Treating a defaulted parameter as unannotated made every function with a default
|
|
77
|
+
* look unsafe.
|
|
65
78
|
*
|
|
66
79
|
* @param {SourceCode} sourceCode - The rule's source-code accessor.
|
|
67
80
|
* @param {ReadonlyArray<ESTree.ParamPattern>} params - The parameter list to inspect.
|
|
@@ -70,13 +83,14 @@ const PRIMITIVE_TYPE_TEXT = /^(?:string|number|bigint|boolean|unknown|any|null|u
|
|
|
70
83
|
function transpositionSafe(sourceCode, params) {
|
|
71
84
|
const texts = [];
|
|
72
85
|
for (const param of params) {
|
|
73
|
-
|
|
86
|
+
const identifier = param.type === "AssignmentPattern" ? param.left : param;
|
|
87
|
+
if (identifier.type !== "Identifier")
|
|
74
88
|
return false;
|
|
75
|
-
const annotation =
|
|
89
|
+
const annotation = identifier.typeAnnotation;
|
|
76
90
|
if (annotation === null || annotation === undefined)
|
|
77
91
|
return false;
|
|
78
92
|
const text = sourceCode.getText(annotation.typeAnnotation).replaceAll(" ", "");
|
|
79
|
-
if (text === ""
|
|
93
|
+
if (text === "")
|
|
80
94
|
return false;
|
|
81
95
|
texts.push(text);
|
|
82
96
|
}
|
|
@@ -87,10 +101,10 @@ export const noMultipleFunctionParamsRule = defineRule({
|
|
|
87
101
|
meta: {
|
|
88
102
|
type: "problem",
|
|
89
103
|
docs: {
|
|
90
|
-
description: "Disallow owned functions with more than one positional parameter; collapse multiple inputs into a single named payload object so transposed
|
|
104
|
+
description: "Disallow owned functions with more than one positional parameter unless every parameter has a distinct annotated type; collapse multiple inputs into a single named payload object so a transposed argument fails the compiler.",
|
|
91
105
|
},
|
|
92
106
|
messages: {
|
|
93
|
-
multipleParams: "`{{name}}` takes {{count}} positional parameters. Accept a single named payload object instead;
|
|
107
|
+
multipleParams: "`{{name}}` takes {{count}} positional parameters without distinct types. Accept a single named payload object instead; two parameters of the same type transpose silently.",
|
|
94
108
|
},
|
|
95
109
|
},
|
|
96
110
|
createOnce(context) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { ancestorsOf } from "../shared/ancestors.js";
|
|
3
|
-
const TEST_FILE =
|
|
3
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
4
4
|
/**
|
|
5
5
|
* Whether the identifier sits inside a type annotation rather than a value position.
|
|
6
6
|
*
|
|
@@ -25,7 +25,7 @@ function isTypePosition(sourceCode, identifier) {
|
|
|
25
25
|
function functionName(node, sourceCode) {
|
|
26
26
|
if (node.type === "FunctionDeclaration" && node.id !== null)
|
|
27
27
|
return node.id.name;
|
|
28
|
-
const parent = ancestorsOf(sourceCode, node)
|
|
28
|
+
const parent = ancestorsOf(sourceCode, node).at(-1);
|
|
29
29
|
if (parent !== undefined) {
|
|
30
30
|
if (parent.type === "VariableDeclarator" && parent.id.type === "Identifier")
|
|
31
31
|
return parent.id.name;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
const NONDETERMINISTIC_MEMBERS = new Set(["getRandomValues", "random", "randomUUID", "now"]);
|
|
3
|
-
const TEST_FILE =
|
|
3
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
|
|
4
4
|
function memberChain(node) {
|
|
5
5
|
if (node.type === "MemberExpression" && !node.computed) {
|
|
6
6
|
return [...memberChain(node.object), node.property.type === "Identifier" ? node.property.name : ""];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a constructor chain admits an absent value.
|
|
3
|
+
*
|
|
4
|
+
* @param {ReadonlyArray<string>} names - The names in the field's chain.
|
|
5
|
+
* @returns {boolean} True when one of them makes the field absent.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hasAbsence(names: ReadonlyArray<string>): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* A value is certain, or it is not a value.
|
|
10
|
+
*
|
|
11
|
+
* Nullability from a `left join` is a retrieval artifact. When it becomes a
|
|
12
|
+
* field of the concept, the concept starts saying the business is unsure about
|
|
13
|
+
* something it knows. The partiality belongs in the derivation that read the
|
|
14
|
+
* row, and the exception ("this field is absent by nature") needs a comment.
|
|
15
|
+
*/
|
|
16
|
+
export declare const noNullableValueFieldRule: import("@oxlint/plugins").Rule;
|