@autotelic/plumb 0.6.0 → 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/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.js +2 -2
- package/dist/effect/rules/no-raw-error-forwarding.d.ts +4 -0
- package/dist/effect/rules/no-raw-error-forwarding.js +7 -2
- 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 +8 -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.js +2 -2
- 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
package/README.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# plumb
|
|
2
2
|
|
|
3
|
-
Opinionated [Oxlint](https://oxc.rs) rules that keep TypeScript *true*: a plumb line for your codebase.
|
|
3
|
+
Opinionated [Oxlint](https://oxc.rs) rules that keep TypeScript *true*: a plumb line for your codebase. The plugins also run under ESLint (see [Using Plumb with ESLint](#using-plumb-with-eslint)).
|
|
4
4
|
|
|
5
5
|
## Plugins
|
|
6
6
|
|
|
7
|
-
- **`plumb`**: generic rules that reject low-evidence and low-signal implementation patterns (
|
|
8
|
-
- **`plumb-effect`**: opt-in rules for Effect service and Layer architecture (
|
|
7
|
+
- **`plumb`**: generic rules that reject low-evidence and low-signal implementation patterns (49 rules).
|
|
8
|
+
- **`plumb-effect`**: opt-in rules for Effect service and Layer architecture (26 rules). Enable only in repos that depend on `effect`.
|
|
9
|
+
- **`plumb-react`**: opt-in React composition rules (4 rules). Enable only in React repos.
|
|
10
|
+
- **`plumb-ui`**: opt-in catalog rules (1 rule). Reads cutlist's generated manifest; `no-deprecated-parts` reports an import of a part whose authored intent marks it `deprecated`, naming the recorded replacement. Fails open when the manifest is missing or malformed; `cutlist build --check` is the gate that keeps it current.
|
|
11
|
+
- **`plumb/configs`**: shared rule sets (`plumbRecommendedRules`, `plumbEffectRecommendedRules`, `plumbReactRecommendedRules`) that enable every rule in a plugin at `error`, for either linter.
|
|
9
12
|
- **`plumb/testing`**: RuleTester lifecycle adapter (`testableRule`, `wireRuleTester`, `createTester`) so `createOnce` rules with `before`/`after` hooks test correctly under the ESLint-compatible `create` path.
|
|
10
13
|
|
|
11
14
|
## Consuming
|
|
@@ -32,16 +35,86 @@ rules: {
|
|
|
32
35
|
},
|
|
33
36
|
```
|
|
34
37
|
|
|
35
|
-
If your setup does not resolve package exports for plugin specifiers, point directly at the
|
|
38
|
+
If your setup does not resolve package exports for plugin specifiers, point directly at the compiled files instead (the package ships `dist/` only):
|
|
36
39
|
|
|
37
40
|
```ts
|
|
38
41
|
jsPlugins: [
|
|
39
|
-
{ name: "plumb", specifier: "./node_modules/@autotelic/plumb/
|
|
40
|
-
{ name: "plumb-effect", specifier: "./node_modules/@autotelic/plumb/
|
|
42
|
+
{ name: "plumb", specifier: "./node_modules/@autotelic/plumb/dist/index.js" },
|
|
43
|
+
{ name: "plumb-effect", specifier: "./node_modules/@autotelic/plumb/dist/effect/index.js" },
|
|
41
44
|
],
|
|
42
45
|
ignorePatterns: ["node_modules/**"],
|
|
43
46
|
```
|
|
44
47
|
|
|
48
|
+
### 3. Or enable whole plugins with the shared rule sets
|
|
49
|
+
|
|
50
|
+
Each rule set enables every rule in its plugin at `error`, and grows automatically when a release adds rules. Spread it into `rules`, then override individual rules after it. This needs a JS/TS config (`oxlint.config.ts`), since `.oxlintrc.json` can't import modules.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
// oxlint.config.ts
|
|
54
|
+
import { defineConfig } from "oxlint";
|
|
55
|
+
import { plumbRecommendedRules, plumbEffectRecommendedRules } from "@autotelic/plumb/configs";
|
|
56
|
+
|
|
57
|
+
export default defineConfig({
|
|
58
|
+
jsPlugins: [
|
|
59
|
+
{ name: "plumb", specifier: "@autotelic/plumb" },
|
|
60
|
+
{ name: "plumb-effect", specifier: "@autotelic/plumb/effect" },
|
|
61
|
+
],
|
|
62
|
+
rules: {
|
|
63
|
+
...plumbRecommendedRules,
|
|
64
|
+
...plumbEffectRecommendedRules,
|
|
65
|
+
"plumb/require-jsdoc-on-exported": "off",
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The rule ids assume each plugin is registered under its own name: `plumb`, `plumb-effect`, `plumb-react`.
|
|
71
|
+
|
|
72
|
+
### 4. Catalog rules (`plumb-ui`)
|
|
73
|
+
|
|
74
|
+
`plumb-ui` is separate from the recommended sets because it needs a generated manifest. Point it at the file `cutlist build` writes:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
// oxlint.config.ts
|
|
78
|
+
jsPlugins: [{ name: "plumb-ui", specifier: "@autotelic/plumb/ui" }],
|
|
79
|
+
rules: {
|
|
80
|
+
"plumb-ui/no-deprecated-parts": [
|
|
81
|
+
"error",
|
|
82
|
+
{ manifest: "tools/ui-catalog/plumb-ui.config.json" },
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The manifest option is a path or an already-decoded manifest object; it defaults to `tools/ui-catalog/plumb-ui.config.json`. A part is a promise: the catalog records `status: deprecated` and `useInstead`, and the rule makes an unmigrated import visible at the call site. If the manifest cannot be read, the rule reports nothing rather than inventing a migration.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
## Using Plumb with ESLint
|
|
91
|
+
|
|
92
|
+
Every plugin is ESLint-compatible, so the same rules run under ESLint with the same findings. Use this where Oxlint can't parse the files: Astro, Vue and Svelte templates. Pair ESLint's framework parser with `@typescript-eslint/parser` for the script parts, and keep Oxlint for plain TypeScript if you want its speed.
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
// eslint.config.js
|
|
96
|
+
import astroParser from "astro-eslint-parser";
|
|
97
|
+
import tsParser from "@typescript-eslint/parser";
|
|
98
|
+
import plumb from "@autotelic/plumb";
|
|
99
|
+
import { plumbRecommendedRules } from "@autotelic/plumb/configs";
|
|
100
|
+
|
|
101
|
+
export default [
|
|
102
|
+
{
|
|
103
|
+
files: ["**/*.astro"],
|
|
104
|
+
languageOptions: {
|
|
105
|
+
parser: astroParser,
|
|
106
|
+
parserOptions: { parser: tsParser, extraFileExtensions: [".astro"] },
|
|
107
|
+
},
|
|
108
|
+
plugins: { plumb },
|
|
109
|
+
rules: { ...plumbRecommendedRules },
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Vue (`vue-eslint-parser`) and Svelte (`svelte-eslint-parser`) work the same way: swap the parser and file glob. Register the plugins under the same names as in Oxlint so rule ids, and the shared rule sets, line up across both linters.
|
|
115
|
+
|
|
116
|
+
If you type-check an `eslint.config.ts`, the plugin objects need a cast: Oxlint's `Plugin` type allows `meta.fixable: null`, which ESLint's type doesn't. The runtime objects are what ESLint expects.
|
|
117
|
+
|
|
45
118
|
## Updating
|
|
46
119
|
|
|
47
120
|
```sh
|
|
@@ -50,11 +123,11 @@ pnpm up @autotelic/plumb # bump to the latest published version
|
|
|
50
123
|
|
|
51
124
|
## Releasing (maintainers)
|
|
52
125
|
|
|
53
|
-
Releases publish to public npm automatically when a GitHub Release is published; the `Publish` workflow runs `pnpm check
|
|
126
|
+
Releases publish to public npm automatically when a GitHub Release is published; the `Publish` workflow runs `pnpm check` and `pnpm build`, then runs `npm publish` authenticated with the `NPM_PUBLISH_TOKEN` repository secret.
|
|
54
127
|
|
|
55
128
|
1. Update `version` in `package.json` and merge.
|
|
56
129
|
2. Create a GitHub Release for `vX.Y.Z`.
|
|
57
|
-
3. The workflow publishes to npmjs; verify
|
|
130
|
+
3. The workflow publishes to npmjs; verify the package version on npm.
|
|
58
131
|
|
|
59
132
|
## Development
|
|
60
133
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Plugin } from "@oxlint/plugins";
|
|
2
|
+
/** The parts of a plugin a shared rule set is derived from. */
|
|
3
|
+
type RuleSetSource = Pick<Plugin, "meta" | "rules">;
|
|
4
|
+
/** Every rule a plugin ships, enabled at `error` under the plugin's own name.
|
|
5
|
+
*
|
|
6
|
+
* The keys assume the plugin is registered under `meta.name` (`plumb`,
|
|
7
|
+
* `plumb-effect`, `plumb-react`), in `jsPlugins` for Oxlint or `plugins` for
|
|
8
|
+
* ESLint. The result drops straight into either linter's `rules` object.
|
|
9
|
+
*
|
|
10
|
+
* @param {RuleSetSource} plugin - The plugin whose rules to enable.
|
|
11
|
+
* @returns {Readonly<Record<string, "error">>} Namespaced rule ids mapped to `error`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function recommendedRulesFor(plugin: RuleSetSource): Readonly<Record<string, "error">>;
|
|
14
|
+
/** Every rule a plugin ships, at the severity its own `meta.type` asks for.
|
|
15
|
+
*
|
|
16
|
+
* A `problem` is an error; a `suggestion` (or any other type) is a warning. Same
|
|
17
|
+
* namespacing as {@link recommendedRulesFor}, so the two are interchangeable in a
|
|
18
|
+
* config that wants the split rather than a flat `error`.
|
|
19
|
+
*
|
|
20
|
+
* @param {RuleSetSource} plugin - The plugin whose rules to enable.
|
|
21
|
+
* @returns {Readonly<Record<string, "error" | "warn">>} Namespaced rule ids mapped to severity.
|
|
22
|
+
*/
|
|
23
|
+
export declare function rulesByMetaTypeFor(plugin: RuleSetSource): Readonly<Record<string, "error" | "warn">>;
|
|
24
|
+
/** Every `plumb` rule at `error`. */
|
|
25
|
+
export declare const plumbRecommendedRules: Readonly<Record<string, "error">>;
|
|
26
|
+
/** Every `plumb-effect` rule at `error`; enable only in repos that depend on `effect`. */
|
|
27
|
+
export declare const plumbEffectRecommendedRules: Readonly<Record<string, "error">>;
|
|
28
|
+
/** Every `plumb-react` rule at `error`; enable only in React repos. */
|
|
29
|
+
export declare const plumbReactRecommendedRules: Readonly<Record<string, "error">>;
|
|
30
|
+
/** Every `plumb` rule at the severity its own metadata asks for. */
|
|
31
|
+
export declare const plumbRulesByMetaType: Readonly<Record<string, "error" | "warn">>;
|
|
32
|
+
/** Every `plumb-effect` rule at the severity its own metadata asks for. */
|
|
33
|
+
export declare const plumbEffectRulesByMetaType: Readonly<Record<string, "error" | "warn">>;
|
|
34
|
+
/** Every `plumb-react` rule at the severity its own metadata asks for. */
|
|
35
|
+
export declare const plumbReactRulesByMetaType: Readonly<Record<string, "error" | "warn">>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import plumbPlugin from "../index.js";
|
|
2
|
+
import plumbEffectPlugin from "../effect/index.js";
|
|
3
|
+
import plumbReactPlugin from "../react/index.js";
|
|
4
|
+
/** Every rule a plugin ships, enabled at `error` under the plugin's own name.
|
|
5
|
+
*
|
|
6
|
+
* The keys assume the plugin is registered under `meta.name` (`plumb`,
|
|
7
|
+
* `plumb-effect`, `plumb-react`), in `jsPlugins` for Oxlint or `plugins` for
|
|
8
|
+
* ESLint. The result drops straight into either linter's `rules` object.
|
|
9
|
+
*
|
|
10
|
+
* @param {RuleSetSource} plugin - The plugin whose rules to enable.
|
|
11
|
+
* @returns {Readonly<Record<string, "error">>} Namespaced rule ids mapped to `error`.
|
|
12
|
+
*/
|
|
13
|
+
export function recommendedRulesFor(plugin) {
|
|
14
|
+
const name = plugin.meta?.name ?? "";
|
|
15
|
+
return Object.fromEntries(Object.keys(plugin.rules).map((rule) => [`${name}/${rule}`, "error"]));
|
|
16
|
+
}
|
|
17
|
+
/** The severity a rule's own metadata asks for: a `problem` is an error, anything else a warning.
|
|
18
|
+
*
|
|
19
|
+
* This mirrors how Oxlint's own categories and the Effect language service's presets
|
|
20
|
+
* split their rulebooks, so a rule that merely suggests a shape does not fail a build
|
|
21
|
+
* the way a rule that catches a defect does.
|
|
22
|
+
*
|
|
23
|
+
* @param {unknown} rule - A rule definition from a plugin's `rules` record.
|
|
24
|
+
* @returns {"error" | "warn"} The severity for that rule.
|
|
25
|
+
*/
|
|
26
|
+
function severityOfMetaType(rule) {
|
|
27
|
+
const type = rule.meta?.type;
|
|
28
|
+
return type === "problem" ? "error" : "warn";
|
|
29
|
+
}
|
|
30
|
+
/** Every rule a plugin ships, at the severity its own `meta.type` asks for.
|
|
31
|
+
*
|
|
32
|
+
* A `problem` is an error; a `suggestion` (or any other type) is a warning. Same
|
|
33
|
+
* namespacing as {@link recommendedRulesFor}, so the two are interchangeable in a
|
|
34
|
+
* config that wants the split rather than a flat `error`.
|
|
35
|
+
*
|
|
36
|
+
* @param {RuleSetSource} plugin - The plugin whose rules to enable.
|
|
37
|
+
* @returns {Readonly<Record<string, "error" | "warn">>} Namespaced rule ids mapped to severity.
|
|
38
|
+
*/
|
|
39
|
+
export function rulesByMetaTypeFor(plugin) {
|
|
40
|
+
const name = plugin.meta?.name ?? "";
|
|
41
|
+
return Object.fromEntries(Object.entries(plugin.rules).map(([rule, definition]) => [
|
|
42
|
+
`${name}/${rule}`,
|
|
43
|
+
severityOfMetaType(definition),
|
|
44
|
+
]));
|
|
45
|
+
}
|
|
46
|
+
/** Every `plumb` rule at `error`. */
|
|
47
|
+
export const plumbRecommendedRules = recommendedRulesFor(plumbPlugin);
|
|
48
|
+
/** Every `plumb-effect` rule at `error`; enable only in repos that depend on `effect`. */
|
|
49
|
+
export const plumbEffectRecommendedRules = recommendedRulesFor(plumbEffectPlugin);
|
|
50
|
+
/** Every `plumb-react` rule at `error`; enable only in React repos. */
|
|
51
|
+
export const plumbReactRecommendedRules = recommendedRulesFor(plumbReactPlugin);
|
|
52
|
+
/** Every `plumb` rule at the severity its own metadata asks for. */
|
|
53
|
+
export const plumbRulesByMetaType = rulesByMetaTypeFor(plumbPlugin);
|
|
54
|
+
/** Every `plumb-effect` rule at the severity its own metadata asks for. */
|
|
55
|
+
export const plumbEffectRulesByMetaType = rulesByMetaTypeFor(plumbEffectPlugin);
|
|
56
|
+
/** Every `plumb-react` rule at the severity its own metadata asks for. */
|
|
57
|
+
export const plumbReactRulesByMetaType = rulesByMetaTypeFor(plumbReactPlugin);
|
|
@@ -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
|
/** Whether the member chain ends in the Option namespace, e.g. `Option` or `O`.
|
|
5
5
|
*
|
|
6
6
|
* @param {ESTree.Expression | ESTree.Super} node - The callee object to inspect.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { isString } from "../../shared/structural.js";
|
|
3
3
|
const PROVISION_METHODS = new Set(["provide", "provideMerge"]);
|
|
4
|
-
const TEST_FILE =
|
|
4
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
|
|
5
5
|
/** Multiple provision stages in one pipe entangle dependency tiers; combine independent layers or name each stage.
|
|
6
6
|
*
|
|
7
7
|
* Import tracking covers local names bound to the `Layer` export of
|
|
@@ -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
|
/**
|
|
4
4
|
* decodeUnknownOption collapses every schema mismatch into None, discarding
|
|
5
5
|
* the issue tree that explains why decoding failed. Prefer adapters that keep
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { ancestorsOf } from "../../shared/ancestors.js";
|
|
3
3
|
import { isString } from "../../shared/structural.js";
|
|
4
|
-
const TEST_FILE =
|
|
4
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
|
|
5
5
|
const BANNED_STORAGE = new Set(["indexedDB", "localStorage", "sessionStorage"]);
|
|
6
6
|
/**
|
|
7
7
|
* The banned-storage global named by an identifier, if any.
|
|
@@ -39,8 +39,8 @@ export const noDirectBrowserStorageRule = defineRule({
|
|
|
39
39
|
if (name === null)
|
|
40
40
|
return;
|
|
41
41
|
const chain = ancestorsOf(context.sourceCode, node);
|
|
42
|
-
const parent = chain
|
|
43
|
-
const grandparent = chain
|
|
42
|
+
const parent = chain.at(-1);
|
|
43
|
+
const grandparent = chain.at(-2);
|
|
44
44
|
if (parent === undefined)
|
|
45
45
|
return;
|
|
46
46
|
if (parent.type === "MemberExpression") {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
|
-
const TEST_FILE =
|
|
2
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
|
|
3
3
|
/** Bare `fetch` reaches past the application boundary un-injected; require a client service. */
|
|
4
4
|
export const noDirectFetchRule = defineRule({
|
|
5
5
|
meta: {
|
|
@@ -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
|
function calleeName(node) {
|
|
5
5
|
const callee = node.callee;
|
|
6
6
|
if (callee.type === "MemberExpression" && callee.property.type === "Identifier") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { firstOptionRecord } from "../../shared/rule-options.js";
|
|
3
3
|
import { isString } from "../../shared/structural.js";
|
|
4
|
-
const TEST_FILE =
|
|
4
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
|
|
5
5
|
/** Object names that suggest external input: request bodies, params, etc. */
|
|
6
6
|
const DEFAULT_INPUT_NAMES = new Set([
|
|
7
7
|
"body",
|
|
@@ -73,7 +73,7 @@ export const noNullishDefaultOnPartialInputRule = defineRule({
|
|
|
73
73
|
inputNames.delete(name);
|
|
74
74
|
return {
|
|
75
75
|
before() {
|
|
76
|
-
if (TEST_FILE.test(context.filename.replaceAll("
|
|
76
|
+
if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
|
|
77
77
|
return false;
|
|
78
78
|
},
|
|
79
79
|
LogicalExpression(node) {
|
|
@@ -8,5 +8,9 @@
|
|
|
8
8
|
* structured evidence as fields, rendering its message from those fields. The
|
|
9
9
|
* error then flows through Effect's typed error channel instead of being
|
|
10
10
|
* stringified at every boundary.
|
|
11
|
+
*
|
|
12
|
+
* The catch-param stack is emptied in `before`: it is balanced by `CatchClause`
|
|
13
|
+
* enter/exit, but a file whose parse bails out never reaches the exit, and an empty
|
|
14
|
+
* stack at file start is the invariant every other per-file rule keeps.
|
|
11
15
|
*/
|
|
12
16
|
export declare const noRawErrorForwardingRule: import("@oxlint/plugins").Rule;
|
|
@@ -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
|
/** Error properties that carry internal details and must not be forwarded raw. */
|
|
5
5
|
const ERROR_PROPS = new Set(["message", "stack"]);
|
|
6
6
|
/**
|
|
@@ -50,6 +50,10 @@ function isLoggingCall(sourceCode, node) {
|
|
|
50
50
|
* structured evidence as fields, rendering its message from those fields. The
|
|
51
51
|
* error then flows through Effect's typed error channel instead of being
|
|
52
52
|
* stringified at every boundary.
|
|
53
|
+
*
|
|
54
|
+
* The catch-param stack is emptied in `before`: it is balanced by `CatchClause`
|
|
55
|
+
* enter/exit, but a file whose parse bails out never reaches the exit, and an empty
|
|
56
|
+
* stack at file start is the invariant every other per-file rule keeps.
|
|
53
57
|
*/
|
|
54
58
|
export const noRawErrorForwardingRule = defineRule({
|
|
55
59
|
meta: {
|
|
@@ -65,7 +69,8 @@ export const noRawErrorForwardingRule = defineRule({
|
|
|
65
69
|
const catchParamStack = [];
|
|
66
70
|
return {
|
|
67
71
|
before() {
|
|
68
|
-
|
|
72
|
+
catchParamStack.length = 0;
|
|
73
|
+
if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
|
|
69
74
|
return false;
|
|
70
75
|
},
|
|
71
76
|
CatchClause(node) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { ancestorsOf } from "../../shared/ancestors.js";
|
|
3
3
|
import { isString } from "../../shared/structural.js";
|
|
4
|
-
const TEST_FILE =
|
|
4
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
|
|
5
5
|
/** Computed or plain property name on a member expression.
|
|
6
6
|
*
|
|
7
7
|
* @param {ESTree.MemberExpression} member - The member expression node.
|
|
@@ -37,17 +37,18 @@ function localNameOf(specifier) {
|
|
|
37
37
|
: undefined;
|
|
38
38
|
}
|
|
39
39
|
/** Whether the call site sits inside a `static` class property initializer.
|
|
40
|
+
*
|
|
41
|
+
* Walks from the node outward, since `ancestorsOf` is outermost-first and `Program` would
|
|
42
|
+
* otherwise be the first node seen.
|
|
40
43
|
*
|
|
41
44
|
* @param {SourceCode} sourceCode - The rule's source-code accessor.
|
|
42
45
|
* @param {ESTree.Node} node - The call expression being visited.
|
|
43
46
|
* @returns {boolean} True when enclosed by a static property definition.
|
|
44
47
|
*/
|
|
45
48
|
function inStaticClassField(sourceCode, node) {
|
|
46
|
-
for (const current of ancestorsOf(sourceCode, node)) {
|
|
49
|
+
for (const current of [...ancestorsOf(sourceCode, node)].reverse()) {
|
|
47
50
|
if (current.type === "PropertyDefinition")
|
|
48
51
|
return current.static === true;
|
|
49
|
-
if (current.type === "Program")
|
|
50
|
-
return false;
|
|
51
52
|
}
|
|
52
53
|
return false;
|
|
53
54
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
|
-
const TEST_FILE =
|
|
2
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
|
|
3
3
|
/** Raw `try`/`catch` detours failures around the typed error channel; route them through `Effect.try` instead. */
|
|
4
4
|
export const noTryCatchRule = defineRule({
|
|
5
5
|
meta: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { ancestorsOf } from "../../shared/ancestors.js";
|
|
3
3
|
import { readField } from "../../shared/structural.js";
|
|
4
|
-
const TEST_FILE =
|
|
4
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
|
|
5
5
|
const commentOwnerKinds = new Set([
|
|
6
6
|
"ExpressionStatement",
|
|
7
7
|
"ReturnStatement",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
|
-
const TEST_FILE =
|
|
2
|
+
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
|
|
3
3
|
/** The exported name declared by this statement, if any.
|
|
4
4
|
*
|
|
5
5
|
* @param {ESTree.Node} node - The export or declaration statement.
|
|
@@ -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?$|\/test\//u;
|
|
5
5
|
/** Unwrap a tuple element to the type node it contributes to the annotation walk.
|
|
6
6
|
*
|
|
7
7
|
* @param {ESTree.TSTupleElement} element - Tuple element node.
|
|
@@ -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 LADDER_THRESHOLD = 3;
|
|
5
5
|
/** Whether this call is an Effect combinator chained in the flatMap/map ladder family.
|
|
6
6
|
*
|
|
@@ -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
|
@@ -48,6 +48,10 @@ import { noOptionalFunctionParametersRule } from "./rules/no-optional-function-p
|
|
|
48
48
|
import { noSingleUsePrivateFunctionsRule } from "./rules/no-single-use-private-functions.js";
|
|
49
49
|
import { noMutableEnvironmentCaptureRule } from "./rules/no-mutable-environment-capture.js";
|
|
50
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";
|
|
51
55
|
/** Generic Oxlint rules that reject low-evidence and low-signal implementation patterns. */
|
|
52
56
|
const plumbPlugin = eslintCompatPlugin({
|
|
53
57
|
meta: { name: "plumb" },
|
|
@@ -101,6 +105,10 @@ const plumbPlugin = eslintCompatPlugin({
|
|
|
101
105
|
"no-single-use-private-functions": noSingleUsePrivateFunctionsRule,
|
|
102
106
|
"no-mutable-environment-capture": noMutableEnvironmentCaptureRule,
|
|
103
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,
|
|
104
112
|
},
|
|
105
113
|
});
|
|
106
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
|