@autotelic/plumb 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rules/require-deprecated-tag-for-legacy-comments.js +1 -1
- package/package.json +18 -18
- package/dist/src/configs/recommended-rules.d.ts +0 -20
- package/dist/src/configs/recommended-rules.js +0 -22
- package/dist/src/effect/index.d.ts +0 -3
- package/dist/src/effect/index.js +0 -60
- package/dist/src/effect/rules/guarded-op-must-return-effect.d.ts +0 -6
- package/dist/src/effect/rules/guarded-op-must-return-effect.js +0 -235
- package/dist/src/effect/rules/guarded-op-must-return-option.d.ts +0 -2
- package/dist/src/effect/rules/guarded-op-must-return-option.js +0 -88
- package/dist/src/effect/rules/no-cascading-layer-provide.d.ts +0 -6
- package/dist/src/effect/rules/no-cascading-layer-provide.js +0 -73
- package/dist/src/effect/rules/no-decode-unknown-option.d.ts +0 -7
- package/dist/src/effect/rules/no-decode-unknown-option.js +0 -34
- package/dist/src/effect/rules/no-direct-browser-storage.d.ts +0 -2
- package/dist/src/effect/rules/no-direct-browser-storage.js +0 -88
- package/dist/src/effect/rules/no-direct-fetch.d.ts +0 -2
- package/dist/src/effect/rules/no-direct-fetch.js +0 -37
- package/dist/src/effect/rules/no-manual-field-guards.d.ts +0 -6
- package/dist/src/effect/rules/no-manual-field-guards.js +0 -129
- package/dist/src/effect/rules/no-nested-layer-provide.d.ts +0 -2
- package/dist/src/effect/rules/no-nested-layer-provide.js +0 -50
- package/dist/src/effect/rules/no-nullish-default-on-partial-input.d.ts +0 -13
- package/dist/src/effect/rules/no-nullish-default-on-partial-input.js +0 -109
- package/dist/src/effect/rules/no-raw-error-forwarding.d.ts +0 -12
- package/dist/src/effect/rules/no-raw-error-forwarding.js +0 -103
- package/dist/src/effect/rules/no-schema-class-modeling.d.ts +0 -2
- package/dist/src/effect/rules/no-schema-class-modeling.js +0 -52
- package/dist/src/effect/rules/no-service-constructor-imports.d.ts +0 -2
- package/dist/src/effect/rules/no-service-constructor-imports.js +0 -42
- package/dist/src/effect/rules/no-silent-error-swallow.d.ts +0 -2
- package/dist/src/effect/rules/no-silent-error-swallow.js +0 -95
- package/dist/src/effect/rules/no-static-effect-service-forwarders.d.ts +0 -6
- package/dist/src/effect/rules/no-static-effect-service-forwarders.js +0 -222
- package/dist/src/effect/rules/no-try-catch.d.ts +0 -2
- package/dist/src/effect/rules/no-try-catch.js +0 -30
- package/dist/src/effect/rules/no-unguarded-json-parse.d.ts +0 -5
- package/dist/src/effect/rules/no-unguarded-json-parse.js +0 -200
- package/dist/src/effect/rules/option-core-needs-effect-public.d.ts +0 -5
- package/dist/src/effect/rules/option-core-needs-effect-public.js +0 -76
- package/dist/src/effect/rules/prefer-die-for-precondition-defects.d.ts +0 -5
- package/dist/src/effect/rules/prefer-die-for-precondition-defects.js +0 -112
- package/dist/src/effect/rules/prefer-effect-gen-for-guard-ladders.d.ts +0 -5
- package/dist/src/effect/rules/prefer-effect-gen-for-guard-ladders.js +0 -72
- package/dist/src/effect/rules/prefer-effect-match.d.ts +0 -2
- package/dist/src/effect/rules/prefer-effect-match.js +0 -74
- package/dist/src/effect/rules/prefer-effect-predicate-over-boolean-function.d.ts +0 -2
- package/dist/src/effect/rules/prefer-effect-predicate-over-boolean-function.js +0 -75
- package/dist/src/effect/rules/prefer-named-guard-predicate.d.ts +0 -2
- package/dist/src/effect/rules/prefer-named-guard-predicate.js +0 -93
- package/dist/src/effect/rules/prefer-option-pipeline.d.ts +0 -2
- package/dist/src/effect/rules/prefer-option-pipeline.js +0 -87
- package/dist/src/effect/rules/prefer-ordering-match.d.ts +0 -2
- package/dist/src/effect/rules/prefer-ordering-match.js +0 -135
- package/dist/src/effect/rules/prefer-tagged-enum.d.ts +0 -2
- package/dist/src/effect/rules/prefer-tagged-enum.js +0 -66
- package/dist/src/effect/rules/require-schema-type-derivation.d.ts +0 -7
- package/dist/src/effect/rules/require-schema-type-derivation.js +0 -80
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.js +0 -106
- package/dist/src/meta/index.d.ts +0 -7
- package/dist/src/meta/index.js +0 -22
- package/dist/src/meta/rules/no-disable-directives.d.ts +0 -6
- package/dist/src/meta/rules/no-disable-directives.js +0 -35
- package/dist/src/meta/rules/no-manual-ancestor-walks.d.ts +0 -2
- package/dist/src/meta/rules/no-manual-ancestor-walks.js +0 -26
- package/dist/src/meta/rules/prefer-before-file-scope.d.ts +0 -2
- package/dist/src/meta/rules/prefer-before-file-scope.js +0 -57
- package/dist/src/meta/rules/require-create-once.d.ts +0 -2
- package/dist/src/meta/rules/require-create-once.js +0 -51
- package/dist/src/meta/rules/require-rule-tester.d.ts +0 -2
- package/dist/src/meta/rules/require-rule-tester.js +0 -50
- package/dist/src/react/index.d.ts +0 -3
- package/dist/src/react/index.js +0 -16
- package/dist/src/react/role.d.ts +0 -23
- package/dist/src/react/role.js +0 -30
- package/dist/src/react/rules/require-dot-notation-exports.d.ts +0 -27
- package/dist/src/react/rules/require-dot-notation-exports.js +0 -144
- package/dist/src/react/rules/require-guarded-context-hook.d.ts +0 -19
- package/dist/src/react/rules/require-guarded-context-hook.js +0 -167
- package/dist/src/react/rules/require-tripartite-context.d.ts +0 -17
- package/dist/src/react/rules/require-tripartite-context.js +0 -160
- package/dist/src/react/rules/use-encapsulation.d.ts +0 -22
- package/dist/src/react/rules/use-encapsulation.js +0 -97
- package/dist/src/rules/no-anonymous-wide-tuples.d.ts +0 -7
- package/dist/src/rules/no-anonymous-wide-tuples.js +0 -34
- package/dist/src/rules/no-barrel-export-star.d.ts +0 -2
- package/dist/src/rules/no-barrel-export-star.js +0 -26
- package/dist/src/rules/no-boolean-field-signals.d.ts +0 -2
- package/dist/src/rules/no-boolean-field-signals.js +0 -279
- package/dist/src/rules/no-builtin-throws.d.ts +0 -6
- package/dist/src/rules/no-builtin-throws.js +0 -74
- package/dist/src/rules/no-chained-type-assertions.d.ts +0 -2
- package/dist/src/rules/no-chained-type-assertions.js +0 -54
- package/dist/src/rules/no-conditional-empty-object-spread.d.ts +0 -2
- package/dist/src/rules/no-conditional-empty-object-spread.js +0 -36
- package/dist/src/rules/no-duplicated-literal-union.d.ts +0 -6
- package/dist/src/rules/no-duplicated-literal-union.js +0 -66
- package/dist/src/rules/no-exported-mutable-state.d.ts +0 -7
- package/dist/src/rules/no-exported-mutable-state.js +0 -104
- package/dist/src/rules/no-generic-export-names.d.ts +0 -2
- package/dist/src/rules/no-generic-export-names.js +0 -141
- package/dist/src/rules/no-impossible-branch-throw.d.ts +0 -2
- package/dist/src/rules/no-impossible-branch-throw.js +0 -51
- package/dist/src/rules/no-known-value-widening.d.ts +0 -2
- package/dist/src/rules/no-known-value-widening.js +0 -176
- package/dist/src/rules/no-module-mocking.d.ts +0 -2
- package/dist/src/rules/no-module-mocking.js +0 -90
- package/dist/src/rules/no-multiple-function-params.d.ts +0 -2
- package/dist/src/rules/no-multiple-function-params.js +0 -155
- package/dist/src/rules/no-mutable-environment-capture.d.ts +0 -7
- package/dist/src/rules/no-mutable-environment-capture.js +0 -134
- package/dist/src/rules/no-nondeterministic-core.d.ts +0 -6
- package/dist/src/rules/no-nondeterministic-core.js +0 -63
- package/dist/src/rules/no-object-parameters.d.ts +0 -2
- package/dist/src/rules/no-object-parameters.js +0 -95
- package/dist/src/rules/no-optional-function-parameters.d.ts +0 -7
- package/dist/src/rules/no-optional-function-parameters.js +0 -44
- package/dist/src/rules/no-product-of-state-booleans.d.ts +0 -2
- package/dist/src/rules/no-product-of-state-booleans.js +0 -79
- package/dist/src/rules/no-redundant-derived-field.d.ts +0 -6
- package/dist/src/rules/no-redundant-derived-field.js +0 -194
- package/dist/src/rules/no-reflect-apply.d.ts +0 -2
- package/dist/src/rules/no-reflect-apply.js +0 -29
- package/dist/src/rules/no-reflect-get.d.ts +0 -2
- package/dist/src/rules/no-reflect-get.js +0 -29
- package/dist/src/rules/no-reinterpret-cast.d.ts +0 -2
- package/dist/src/rules/no-reinterpret-cast.js +0 -68
- package/dist/src/rules/no-runtime-typeof.d.ts +0 -2
- package/dist/src/rules/no-runtime-typeof.js +0 -54
- package/dist/src/rules/no-sentinel-comparison-union.d.ts +0 -2
- package/dist/src/rules/no-sentinel-comparison-union.js +0 -139
- package/dist/src/rules/no-shape-in-symbol-names.d.ts +0 -2
- package/dist/src/rules/no-shape-in-symbol-names.js +0 -39
- package/dist/src/rules/no-single-use-private-functions.d.ts +0 -17
- package/dist/src/rules/no-single-use-private-functions.js +0 -419
- package/dist/src/rules/no-sql-string-interpolation.d.ts +0 -7
- package/dist/src/rules/no-sql-string-interpolation.js +0 -62
- package/dist/src/rules/no-stacked-jsdoc-blocks.d.ts +0 -2
- package/dist/src/rules/no-stacked-jsdoc-blocks.js +0 -50
- package/dist/src/rules/no-stray-inline-comments.d.ts +0 -2
- package/dist/src/rules/no-stray-inline-comments.js +0 -74
- package/dist/src/rules/no-swappable-primitive-params.d.ts +0 -2
- package/dist/src/rules/no-swappable-primitive-params.js +0 -96
- package/dist/src/rules/no-tag-ladder-assertions.d.ts +0 -6
- package/dist/src/rules/no-tag-ladder-assertions.js +0 -63
- package/dist/src/rules/no-transposed-field-reads.d.ts +0 -8
- package/dist/src/rules/no-transposed-field-reads.js +0 -101
- package/dist/src/rules/no-unit-return-validators.d.ts +0 -2
- package/dist/src/rules/no-unit-return-validators.js +0 -64
- package/dist/src/rules/no-unknown-parameters.d.ts +0 -2
- package/dist/src/rules/no-unknown-parameters.js +0 -82
- package/dist/src/rules/no-unknown-returns.d.ts +0 -2
- package/dist/src/rules/no-unknown-returns.js +0 -86
- package/dist/src/rules/no-unknown-type-aliases.d.ts +0 -2
- package/dist/src/rules/no-unknown-type-aliases.js +0 -64
- package/dist/src/rules/no-unsafe-dictionary-type.d.ts +0 -2
- package/dist/src/rules/no-unsafe-dictionary-type.js +0 -116
- package/dist/src/rules/no-vague-test-filenames.d.ts +0 -2
- package/dist/src/rules/no-vague-test-filenames.js +0 -61
- package/dist/src/rules/no-widen-then-assert.d.ts +0 -2
- package/dist/src/rules/no-widen-then-assert.js +0 -268
- package/dist/src/rules/prefer-payload-brand.d.ts +0 -2
- package/dist/src/rules/prefer-payload-brand.js +0 -57
- package/dist/src/rules/prefer-property-tests.d.ts +0 -5
- package/dist/src/rules/prefer-property-tests.js +0 -39
- package/dist/src/rules/require-canonical-stringify-for-identity.d.ts +0 -8
- package/dist/src/rules/require-canonical-stringify-for-identity.js +0 -72
- package/dist/src/rules/require-deprecated-tag-for-legacy-comments.d.ts +0 -2
- package/dist/src/rules/require-deprecated-tag-for-legacy-comments.js +0 -34
- package/dist/src/rules/require-exhaustive-tag-switch.d.ts +0 -7
- package/dist/src/rules/require-exhaustive-tag-switch.js +0 -34
- package/dist/src/rules/require-fc-block-predicate.d.ts +0 -2
- package/dist/src/rules/require-fc-block-predicate.js +0 -37
- package/dist/src/rules/require-jsdoc-on-exported.d.ts +0 -2
- package/dist/src/rules/require-jsdoc-on-exported.js +0 -66
- package/dist/src/rules/require-published-order.d.ts +0 -2
- package/dist/src/rules/require-published-order.js +0 -102
- package/dist/src/rules/require-safety-comment-for-type-assertion.d.ts +0 -2
- package/dist/src/rules/require-safety-comment-for-type-assertion.js +0 -53
- package/dist/src/rules/require-sort-comparator.d.ts +0 -7
- package/dist/src/rules/require-sort-comparator.js +0 -34
- package/dist/src/rules/test-utils.d.ts +0 -35
- package/dist/src/rules/test-utils.js +0 -53
- package/dist/src/shared/ancestors.d.ts +0 -18
- package/dist/src/shared/ancestors.js +0 -19
- package/dist/src/shared/child-nodes.d.ts +0 -12
- package/dist/src/shared/child-nodes.js +0 -26
- package/dist/src/shared/dictionary-types.d.ts +0 -55
- package/dist/src/shared/dictionary-types.js +0 -413
- package/dist/src/shared/is-node.d.ts +0 -9
- package/dist/src/shared/is-node.js +0 -10
- package/dist/src/shared/lexical-type-parameters.d.ts +0 -12
- package/dist/src/shared/lexical-type-parameters.js +0 -50
- package/dist/src/shared/reflect-method.d.ts +0 -15
- package/dist/src/shared/reflect-method.js +0 -32
- package/dist/src/shared/rule-options.d.ts +0 -18
- package/dist/src/shared/rule-options.js +0 -12
- package/dist/src/shared/structural.d.ts +0 -54
- package/dist/src/shared/structural.js +0 -40
- package/dist/src/testing/index.d.ts +0 -2
- package/dist/src/testing/index.js +0 -1
- package/dist/src/testing/testable-rule.d.ts +0 -39
- package/dist/src/testing/testable-rule.js +0 -84
- package/dist/src/ui/index.d.ts +0 -12
- package/dist/src/ui/index.js +0 -18
- package/dist/src/ui/manifest.d.ts +0 -34
- package/dist/src/ui/manifest.js +0 -75
- package/dist/src/ui/rules/no-deprecated-parts.d.ts +0 -3
- package/dist/src/ui/rules/no-deprecated-parts.js +0 -131
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createTester, testableRule, wireRuleTester } from "./testable-rule.js";
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { RuleTester } from "oxlint/plugins-dev";
|
|
2
|
-
import type { Rule } from "@oxlint/plugins";
|
|
3
|
-
/**
|
|
4
|
-
* Structural surface of a test runner, satisfied by vitest's `describe`/`it`/
|
|
5
|
-
* `it.only` (and by jest/mocha equivalents).
|
|
6
|
-
*/
|
|
7
|
-
export interface TestRunner {
|
|
8
|
-
describe: (name: string, fn: () => void) => void;
|
|
9
|
-
it: (name: string, fn: () => void) => void;
|
|
10
|
-
itOnly?: (name: string, fn: () => void) => void;
|
|
11
|
-
}
|
|
12
|
-
/** Bind a test runner's hooks to RuleTester's statics.
|
|
13
|
-
*
|
|
14
|
-
* Call once at module scope of a test file (or setup file) before running suites.
|
|
15
|
-
*
|
|
16
|
-
* @param {TestRunner} runner - The ambient runner's hooks.
|
|
17
|
-
*/
|
|
18
|
-
export declare function wireRuleTester(runner: TestRunner): void;
|
|
19
|
-
/** A tester instance bound to the wired runner.
|
|
20
|
-
*
|
|
21
|
-
* @returns {RuleTester} A fresh RuleTester.
|
|
22
|
-
*/
|
|
23
|
-
export declare function createTester(): RuleTester;
|
|
24
|
-
/**
|
|
25
|
-
* Adapt a `createOnce` rule for Oxlint's RuleTester.
|
|
26
|
-
*
|
|
27
|
-
* RuleTester drives rules through their ESLint-compatible `create` method and
|
|
28
|
-
* does not understand `before`/`after` lifecycle hooks. Like native Oxlint, the
|
|
29
|
-
* adapter invokes `createOnce` once and reuses its visitors for every linted
|
|
30
|
-
* file, so state a rule forgets to reset in `before` leaks between test cases
|
|
31
|
-
* exactly as it would leak between files in a real run. It also honours the
|
|
32
|
-
* skip contract (`before` returning `false` skips the file), and chains the
|
|
33
|
-
* rule's own `Program:exit` visitor with the after hook instead of clobbering it.
|
|
34
|
-
*
|
|
35
|
-
* @param {CreateOnceRule | Rule} rule - The createOnce-style rule to adapt. A
|
|
36
|
-
* rule already in ESLint-style passes through untouched.
|
|
37
|
-
* @returns {Rule} An ESLint-compatible rule with an identical per-file lifecycle.
|
|
38
|
-
*/
|
|
39
|
-
export declare function testableRule(rule: Rule): Rule;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { RuleTester } from "oxlint/plugins-dev";
|
|
2
|
-
/** Narrow to the createOnce surface the tester adapts.
|
|
3
|
-
*
|
|
4
|
-
* @param {Rule} rule - The rule to test.
|
|
5
|
-
* @returns {boolean} True when the rule carries a createOnce factory.
|
|
6
|
-
*/
|
|
7
|
-
function isCreateOnceRule(rule) {
|
|
8
|
-
return "createOnce" in rule;
|
|
9
|
-
}
|
|
10
|
-
/** Bind a test runner's hooks to RuleTester's statics.
|
|
11
|
-
*
|
|
12
|
-
* Call once at module scope of a test file (or setup file) before running suites.
|
|
13
|
-
*
|
|
14
|
-
* @param {TestRunner} runner - The ambient runner's hooks.
|
|
15
|
-
*/
|
|
16
|
-
export function wireRuleTester(runner) {
|
|
17
|
-
RuleTester.describe = runner.describe;
|
|
18
|
-
RuleTester.it = runner.it;
|
|
19
|
-
if (runner.itOnly !== undefined) {
|
|
20
|
-
RuleTester.itOnly = runner.itOnly;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/** A tester instance bound to the wired runner.
|
|
24
|
-
*
|
|
25
|
-
* @returns {RuleTester} A fresh RuleTester.
|
|
26
|
-
*/
|
|
27
|
-
export function createTester() {
|
|
28
|
-
return new RuleTester();
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Adapt a `createOnce` rule for Oxlint's RuleTester.
|
|
32
|
-
*
|
|
33
|
-
* RuleTester drives rules through their ESLint-compatible `create` method and
|
|
34
|
-
* does not understand `before`/`after` lifecycle hooks. Like native Oxlint, the
|
|
35
|
-
* adapter invokes `createOnce` once and reuses its visitors for every linted
|
|
36
|
-
* file, so state a rule forgets to reset in `before` leaks between test cases
|
|
37
|
-
* exactly as it would leak between files in a real run. It also honours the
|
|
38
|
-
* skip contract (`before` returning `false` skips the file), and chains the
|
|
39
|
-
* rule's own `Program:exit` visitor with the after hook instead of clobbering it.
|
|
40
|
-
*
|
|
41
|
-
* @param {CreateOnceRule | Rule} rule - The createOnce-style rule to adapt. A
|
|
42
|
-
* rule already in ESLint-style passes through untouched.
|
|
43
|
-
* @returns {Rule} An ESLint-compatible rule with an identical per-file lifecycle.
|
|
44
|
-
*/
|
|
45
|
-
export function testableRule(rule) {
|
|
46
|
-
if (!isCreateOnceRule(rule))
|
|
47
|
-
return rule;
|
|
48
|
-
let currentContext;
|
|
49
|
-
const sharedContext = new Proxy({}, {
|
|
50
|
-
get(_target, key) {
|
|
51
|
-
// SAFETY: the proxy stands in for the per-file context, so every key
|
|
52
|
-
// read is a key of that context.
|
|
53
|
-
const value = currentContext[key];
|
|
54
|
-
return value instanceof Function ? value.bind(currentContext) : value;
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
let hooks;
|
|
58
|
-
const adapter = {
|
|
59
|
-
meta: rule.meta,
|
|
60
|
-
create(context) {
|
|
61
|
-
currentContext = context;
|
|
62
|
-
// SAFETY: the proxy forwards every read to the current file's context.
|
|
63
|
-
hooks ??= rule.createOnce(sharedContext);
|
|
64
|
-
const { after, before, ...visitor } = hooks;
|
|
65
|
-
// SAFETY: visitor fragments come from this plugin's own createOnce
|
|
66
|
-
// contract; method keys map one-to-one onto the tester's call shape.
|
|
67
|
-
const visitors = visitor;
|
|
68
|
-
const skip = before !== undefined && before() === false;
|
|
69
|
-
if (skip)
|
|
70
|
-
return {};
|
|
71
|
-
const previousExit = visitors["Program:exit"];
|
|
72
|
-
return {
|
|
73
|
-
...visitors,
|
|
74
|
-
"Program:exit"(...callArguments) {
|
|
75
|
-
previousExit?.(...callArguments);
|
|
76
|
-
after?.();
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
// SAFETY: the adapter reproduces Rule's meta/create surface; its visitors
|
|
82
|
-
// are the createOnce fragments the tester already consumes.
|
|
83
|
-
return adapter;
|
|
84
|
-
}
|
package/dist/src/ui/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { noDeprecatedPartsRule } from "./rules/no-deprecated-parts.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Rules that read the catalog's lint manifest.
|
|
4
|
-
*
|
|
5
|
-
* These are separate from `plumb-react` because they need a second input — the generated
|
|
6
|
-
* manifest — and a repository without a catalog should not enable them. A rule here is a
|
|
7
|
-
* lookup, never a second analysis: cutlist already decided which part is deprecated and
|
|
8
|
-
* what replaces it.
|
|
9
|
-
*/
|
|
10
|
-
declare const plumbUiPlugin: import("@oxlint/plugins").Plugin;
|
|
11
|
-
export default plumbUiPlugin;
|
|
12
|
-
export { noDeprecatedPartsRule };
|
package/dist/src/ui/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { eslintCompatPlugin } from "@oxlint/plugins";
|
|
2
|
-
import { noDeprecatedPartsRule } from "./rules/no-deprecated-parts.js";
|
|
3
|
-
/**
|
|
4
|
-
* Rules that read the catalog's lint manifest.
|
|
5
|
-
*
|
|
6
|
-
* These are separate from `plumb-react` because they need a second input — the generated
|
|
7
|
-
* manifest — and a repository without a catalog should not enable them. A rule here is a
|
|
8
|
-
* lookup, never a second analysis: cutlist already decided which part is deprecated and
|
|
9
|
-
* what replaces it.
|
|
10
|
-
*/
|
|
11
|
-
const plumbUiPlugin = eslintCompatPlugin({
|
|
12
|
-
meta: { name: "plumb-ui" },
|
|
13
|
-
rules: {
|
|
14
|
-
"no-deprecated-parts": noDeprecatedPartsRule,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
export default plumbUiPlugin;
|
|
18
|
-
export { noDeprecatedPartsRule };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/** Where a part is in its life. */
|
|
2
|
-
export type UiPartStatus = "stable" | "beta" | "experimental" | "deprecated";
|
|
3
|
-
/** The subset of a manifest component the deprecation rule reads. */
|
|
4
|
-
export interface UiPart {
|
|
5
|
-
readonly path: string;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly exports?: ReadonlyArray<string>;
|
|
8
|
-
readonly status?: UiPartStatus;
|
|
9
|
-
readonly useInstead?: ReadonlyArray<string>;
|
|
10
|
-
}
|
|
11
|
-
/** A manifest, reduced to the parts the rule can act on. */
|
|
12
|
-
export interface UiManifest {
|
|
13
|
-
readonly components: ReadonlyArray<UiPart>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Read one component, or `undefined` when it cannot be identified.
|
|
17
|
-
*
|
|
18
|
-
* `tier`, `owners`, `props` and `tags` are required by the manifest schema but not by
|
|
19
|
-
* this rule. Requiring them here would make a hand-written fixture verbose for no gain,
|
|
20
|
-
* and the rule's question is only "who is deprecated, and what replaces it".
|
|
21
|
-
*/
|
|
22
|
-
export declare function decodeUiPart(value: unknown): UiPart | undefined;
|
|
23
|
-
/** Read a manifest, or `undefined` when it is not one. */
|
|
24
|
-
export declare function decodeUiManifest(value: unknown): UiManifest | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Read a manifest from disk, degrading to `undefined`.
|
|
27
|
-
*
|
|
28
|
-
* A missing or malformed manifest is not a lint error: the rule goes quiet, exactly as
|
|
29
|
-
* every other manifest reader in this workspace does. `cutlist build --check` is the
|
|
30
|
-
* gate that makes a stale manifest loud.
|
|
31
|
-
*/
|
|
32
|
-
export declare function readUiManifest(path: string): UiManifest | undefined;
|
|
33
|
-
/** Resolve a configured path against the process working directory. */
|
|
34
|
-
export declare function manifestAt(path: string): UiManifest | undefined;
|
package/dist/src/ui/manifest.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
const STATUSES = ["stable", "beta", "experimental", "deprecated"];
|
|
4
|
-
function isRecord(value) {
|
|
5
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
|
-
}
|
|
7
|
-
function str(value) {
|
|
8
|
-
return typeof value === "string" ? value : undefined;
|
|
9
|
-
}
|
|
10
|
-
function strings(value) {
|
|
11
|
-
if (!Array.isArray(value))
|
|
12
|
-
return undefined;
|
|
13
|
-
if (!value.every((entry) => typeof entry === "string"))
|
|
14
|
-
return undefined;
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
function status(value) {
|
|
18
|
-
return STATUSES.find((entry) => entry === value);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Read one component, or `undefined` when it cannot be identified.
|
|
22
|
-
*
|
|
23
|
-
* `tier`, `owners`, `props` and `tags` are required by the manifest schema but not by
|
|
24
|
-
* this rule. Requiring them here would make a hand-written fixture verbose for no gain,
|
|
25
|
-
* and the rule's question is only "who is deprecated, and what replaces it".
|
|
26
|
-
*/
|
|
27
|
-
export function decodeUiPart(value) {
|
|
28
|
-
if (!isRecord(value))
|
|
29
|
-
return undefined;
|
|
30
|
-
const path = str(value.path);
|
|
31
|
-
const name = str(value.name);
|
|
32
|
-
if (path === undefined || name === undefined)
|
|
33
|
-
return undefined;
|
|
34
|
-
const exports = strings(value.exports);
|
|
35
|
-
const partStatus = status(value.status);
|
|
36
|
-
const useInstead = strings(value.useInstead);
|
|
37
|
-
return {
|
|
38
|
-
path,
|
|
39
|
-
name,
|
|
40
|
-
...(exports === undefined ? {} : { exports }),
|
|
41
|
-
...(partStatus === undefined ? {} : { status: partStatus }),
|
|
42
|
-
...(useInstead === undefined ? {} : { useInstead }),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/** Read a manifest, or `undefined` when it is not one. */
|
|
46
|
-
export function decodeUiManifest(value) {
|
|
47
|
-
if (!isRecord(value) || !Array.isArray(value.components))
|
|
48
|
-
return undefined;
|
|
49
|
-
const components = [];
|
|
50
|
-
for (const entry of value.components) {
|
|
51
|
-
const part = decodeUiPart(entry);
|
|
52
|
-
if (part !== undefined)
|
|
53
|
-
components.push(part);
|
|
54
|
-
}
|
|
55
|
-
return { components };
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Read a manifest from disk, degrading to `undefined`.
|
|
59
|
-
*
|
|
60
|
-
* A missing or malformed manifest is not a lint error: the rule goes quiet, exactly as
|
|
61
|
-
* every other manifest reader in this workspace does. `cutlist build --check` is the
|
|
62
|
-
* gate that makes a stale manifest loud.
|
|
63
|
-
*/
|
|
64
|
-
export function readUiManifest(path) {
|
|
65
|
-
try {
|
|
66
|
-
return decodeUiManifest(JSON.parse(readFileSync(path, "utf8")));
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/** Resolve a configured path against the process working directory. */
|
|
73
|
-
export function manifestAt(path) {
|
|
74
|
-
return readUiManifest(resolve(process.cwd(), path));
|
|
75
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { defineRule } from "@oxlint/plugins";
|
|
2
|
-
import { firstOptionRecord } from "../../shared/rule-options.js";
|
|
3
|
-
import { decodeUiManifest, manifestAt, } from "../manifest.js";
|
|
4
|
-
/*
|
|
5
|
-
* A deprecated part is a promise, and an import is the place the promise is checked.
|
|
6
|
-
*
|
|
7
|
-
* Cutlist records `status: deprecated` and `useInstead` in the manifest; this rule reads
|
|
8
|
-
* that record and reports the call sites that have not migrated. It is the lint-shaped
|
|
9
|
-
* half of the same idea as a design system's "preferred instance": the catalog says what
|
|
10
|
-
* replaced the old thing, and the rule makes the old path visible instead of merely
|
|
11
|
-
* documented.
|
|
12
|
-
*
|
|
13
|
-
* The rule fails open. A missing or malformed manifest means no findings, because a lint
|
|
14
|
-
* rule that invents a migration from a file it could not read is worse than one that is
|
|
15
|
-
* briefly quiet; `cutlist build --check` is the gate that makes the manifest current.
|
|
16
|
-
*/
|
|
17
|
-
const RULE_ID = "plumb-ui/no-deprecated-parts";
|
|
18
|
-
const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
19
|
-
const CACHE = new Map();
|
|
20
|
-
function isRecord(value) {
|
|
21
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22
|
-
}
|
|
23
|
-
function manifestFrom(value) {
|
|
24
|
-
// An inline manifest is what a rule test uses; a path is what a config uses. Both
|
|
25
|
-
// decode through the same reader, so a test cannot pass a shape the real rule rejects.
|
|
26
|
-
if (isRecord(value) && Array.isArray(value.components))
|
|
27
|
-
return decodeUiManifest(value);
|
|
28
|
-
if (typeof value !== "string")
|
|
29
|
-
return undefined;
|
|
30
|
-
if (!CACHE.has(value))
|
|
31
|
-
CACHE.set(value, manifestAt(value));
|
|
32
|
-
return CACHE.get(value);
|
|
33
|
-
}
|
|
34
|
-
/** A module path without its source extension or trailing `/index`. */
|
|
35
|
-
function moduleOf(path) {
|
|
36
|
-
return path.replace(/\.(?:tsx?|jsx?)$/u, "").replace(/\/index$/u, "");
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Whether an import specifier names a manifest part.
|
|
40
|
-
*
|
|
41
|
-
* The specifier is resolved by suffix rather than by the repository's alias table: the
|
|
42
|
-
* rule has no tsconfig reader, and every alias in use (`@/`, `~/`, relative) leaves the
|
|
43
|
-
* tail of the path intact. A named import must also match an exported name when the
|
|
44
|
-
* manifest carries one; a default or namespace import matches by path alone.
|
|
45
|
-
*/
|
|
46
|
-
function namesPart(source, imported, part) {
|
|
47
|
-
const clean = source.replace(/^[.@~]+/u, "").replace(/^\/+/u, "").replace(/\.(?:tsx?|jsx?)$/u, "");
|
|
48
|
-
const target = moduleOf(part.path);
|
|
49
|
-
const pathMatches = target === clean || target.endsWith("/" + clean);
|
|
50
|
-
if (imported === "default" || imported === "*")
|
|
51
|
-
return pathMatches;
|
|
52
|
-
return pathMatches || (part.exports?.includes(imported) ?? false);
|
|
53
|
-
}
|
|
54
|
-
/** The imported binding name, or `*` for a namespace import. */
|
|
55
|
-
function importedOf(specifier) {
|
|
56
|
-
if (specifier.type === "ImportSpecifier") {
|
|
57
|
-
return specifier.imported.type === "Identifier"
|
|
58
|
-
? specifier.imported.name
|
|
59
|
-
: String(specifier.imported.value);
|
|
60
|
-
}
|
|
61
|
-
if (specifier.type === "ImportDefaultSpecifier")
|
|
62
|
-
return "default";
|
|
63
|
-
return "*";
|
|
64
|
-
}
|
|
65
|
-
function localOf(specifier) {
|
|
66
|
-
return specifier.local.name;
|
|
67
|
-
}
|
|
68
|
-
function deprecatedPartFor(manifest, source, imported) {
|
|
69
|
-
return manifest.components.find((part) => part.status === "deprecated" && namesPart(source, imported, part));
|
|
70
|
-
}
|
|
71
|
-
export const noDeprecatedPartsRule = defineRule({
|
|
72
|
-
meta: {
|
|
73
|
-
type: "problem",
|
|
74
|
-
docs: {
|
|
75
|
-
description: "Imports from a part whose catalog entry is deprecated must move to its recorded replacement.",
|
|
76
|
-
},
|
|
77
|
-
messages: {
|
|
78
|
-
deprecatedImport: "`{{name}}` comes from the deprecated part `{{part}}`; use {{useInstead}} instead.",
|
|
79
|
-
deprecatedWithoutTarget: "`{{name}}` comes from the deprecated part `{{part}}`, which records no replacement.",
|
|
80
|
-
},
|
|
81
|
-
schema: [
|
|
82
|
-
{
|
|
83
|
-
type: "object",
|
|
84
|
-
properties: {
|
|
85
|
-
manifest: {
|
|
86
|
-
anyOf: [{ type: "string" }, { type: "object" }],
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
additionalProperties: false,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
defaultOptions: [{ manifest: "tools/ui-catalog/plumb-ui.config.json" }],
|
|
93
|
-
},
|
|
94
|
-
createOnce(context) {
|
|
95
|
-
const option = firstOptionRecord(context.options);
|
|
96
|
-
const manifest = manifestFrom(option.manifest);
|
|
97
|
-
if (manifest === undefined)
|
|
98
|
-
return {};
|
|
99
|
-
const deprecated = manifest.components.filter((part) => part.status === "deprecated");
|
|
100
|
-
if (deprecated.length === 0)
|
|
101
|
-
return {};
|
|
102
|
-
return {
|
|
103
|
-
before() {
|
|
104
|
-
if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
|
|
105
|
-
return false;
|
|
106
|
-
},
|
|
107
|
-
ImportDeclaration(node) {
|
|
108
|
-
const source = node.source.value;
|
|
109
|
-
if (typeof source !== "string")
|
|
110
|
-
return;
|
|
111
|
-
for (const specifier of node.specifiers) {
|
|
112
|
-
const imported = importedOf(specifier);
|
|
113
|
-
const part = deprecatedPartFor(manifest, source, imported);
|
|
114
|
-
if (part === undefined)
|
|
115
|
-
continue;
|
|
116
|
-
const useInstead = part.useInstead ?? [];
|
|
117
|
-
context.report({
|
|
118
|
-
node: specifier,
|
|
119
|
-
messageId: useInstead.length === 0 ? "deprecatedWithoutTarget" : "deprecatedImport",
|
|
120
|
-
data: {
|
|
121
|
-
name: localOf(specifier),
|
|
122
|
-
part: part.name,
|
|
123
|
-
useInstead: useInstead.map((name) => `\`${name}\``).join(" or "),
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
export { RULE_ID };
|