@codeperfect/eslint-plugin 1.0.0 → 2.0.0
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 +26 -4
- package/dist/.tsbuildinfo +1 -1
- package/dist/{custom-rules.d.ts → application/custom-rules.d.ts} +3 -0
- package/dist/application/custom-rules.d.ts.map +1 -0
- package/dist/application/custom-rules.js +74 -0
- package/dist/application/index.d.ts +4 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +3 -0
- package/dist/codeperfect-eslint-plugin-1.0.0.tgz +0 -0
- package/dist/domain/architecture/consistent-barrel-files/barrel-file-utilities.d.ts +56 -0
- package/dist/domain/architecture/consistent-barrel-files/barrel-file-utilities.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/barrel-file-utilities.js +149 -0
- package/dist/{architecture → domain/architecture}/consistent-barrel-files/consistent-barrel-files-listeners.d.ts +4 -4
- package/dist/domain/architecture/consistent-barrel-files/consistent-barrel-files-listeners.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/consistent-barrel-files-listeners.js +98 -0
- package/dist/domain/architecture/consistent-barrel-files/consistent-barrel-files-options.d.ts +45 -0
- package/dist/domain/architecture/consistent-barrel-files/consistent-barrel-files-options.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/consistent-barrel-files-options.js +64 -0
- package/dist/{architecture → domain/architecture}/consistent-barrel-files/exports-only-rule-test-utilities.d.ts +5 -4
- package/dist/domain/architecture/consistent-barrel-files/exports-only-rule-test-utilities.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/exports-only-rule-test-utilities.js +87 -0
- package/dist/domain/architecture/consistent-barrel-files/exports-only-rule.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/exports-only-rule.js +140 -0
- package/dist/domain/architecture/consistent-barrel-files/index.d.ts +5 -0
- package/dist/domain/architecture/consistent-barrel-files/index.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/index.js +4 -0
- package/dist/domain/architecture/consistent-barrel-files/no-reexports-outside-barrels-rule.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/no-reexports-outside-barrels-rule.js +85 -0
- package/dist/{architecture → domain/architecture}/consistent-barrel-files/no-reexports-outside-barrels-test-utilities.d.ts +1 -1
- package/dist/domain/architecture/consistent-barrel-files/no-reexports-outside-barrels-test-utilities.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/no-reexports-outside-barrels-test-utilities.js +91 -0
- package/dist/{architecture → domain/architecture}/consistent-barrel-files/no-reexports-outside-barrels-utilities.d.ts +4 -6
- package/dist/domain/architecture/consistent-barrel-files/no-reexports-outside-barrels-utilities.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/no-reexports-outside-barrels-utilities.js +95 -0
- package/dist/domain/architecture/consistent-barrel-files/rule.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/rule.js +43 -0
- package/dist/domain/architecture/consistent-barrel-files/rule.repeat-runs.d.ts +4 -0
- package/dist/domain/architecture/consistent-barrel-files/rule.repeat-runs.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/rule.repeat-runs.js +4 -0
- package/dist/{architecture → domain/architecture}/consistent-barrel-files/test-helpers.d.ts +48 -48
- package/dist/domain/architecture/consistent-barrel-files/test-helpers.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/test-helpers.file-writers.d.ts +20 -0
- package/dist/domain/architecture/consistent-barrel-files/test-helpers.file-writers.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/test-helpers.file-writers.js +25 -0
- package/dist/domain/architecture/consistent-barrel-files/test-helpers.js +235 -0
- package/dist/domain/architecture/consistent-barrel-files/types.d.ts +19 -0
- package/dist/domain/architecture/consistent-barrel-files/types.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/types.js +2 -0
- package/dist/{architecture → domain/architecture}/index.d.ts +1 -1
- package/dist/domain/architecture/index.d.ts.map +1 -0
- package/dist/domain/architecture/index.js +2 -0
- package/dist/{core → domain/core}/index.d.ts +2 -2
- package/dist/domain/core/index.d.ts.map +1 -0
- package/dist/domain/core/index.js +3 -0
- package/dist/domain/core/no-multiple-declarators/index.d.ts +2 -0
- package/dist/domain/core/no-multiple-declarators/index.d.ts.map +1 -0
- package/dist/domain/core/no-multiple-declarators/index.js +2 -0
- package/dist/domain/core/no-multiple-declarators/rule-test-helpers.d.ts +101 -0
- package/dist/domain/core/no-multiple-declarators/rule-test-helpers.d.ts.map +1 -0
- package/dist/domain/core/no-multiple-declarators/rule-test-helpers.js +108 -0
- package/dist/{core → domain/core}/no-multiple-declarators/rule.d.ts +1 -0
- package/dist/domain/core/no-multiple-declarators/rule.d.ts.map +1 -0
- package/dist/domain/core/no-multiple-declarators/rule.fixes.d.ts +35 -0
- package/dist/domain/core/no-multiple-declarators/rule.fixes.d.ts.map +1 -0
- package/dist/domain/core/no-multiple-declarators/rule.fixes.js +95 -0
- package/dist/domain/core/no-multiple-declarators/rule.guardrails.d.ts +4 -0
- package/dist/domain/core/no-multiple-declarators/rule.guardrails.d.ts.map +1 -0
- package/dist/domain/core/no-multiple-declarators/rule.guardrails.js +4 -0
- package/dist/domain/core/no-multiple-declarators/rule.js +219 -0
- package/dist/domain/core/no-multiple-declarators/rule.mocked-types.d.ts +4 -0
- package/dist/domain/core/no-multiple-declarators/rule.mocked-types.d.ts.map +1 -0
- package/dist/domain/core/no-multiple-declarators/rule.mocked-types.js +4 -0
- package/dist/domain/core/no-multiple-declarators/types.d.ts +77 -0
- package/dist/domain/core/no-multiple-declarators/types.d.ts.map +1 -0
- package/dist/domain/core/no-multiple-declarators/types.js +38 -0
- package/dist/domain/core/prefer-interface-types/index.d.ts +2 -0
- package/dist/domain/core/prefer-interface-types/index.d.ts.map +1 -0
- package/dist/domain/core/prefer-interface-types/index.js +2 -0
- package/dist/domain/core/prefer-interface-types/rule.d.ts.map +1 -0
- package/dist/domain/core/prefer-interface-types/rule.js +145 -0
- package/dist/domain/core/prefer-interface-types/test-helpers.d.ts.map +1 -0
- package/dist/domain/core/prefer-interface-types/test-helpers.js +116 -0
- package/dist/{custom-rule-documentation.d.ts → domain/custom-rule-documentation.d.ts} +1 -1
- package/dist/domain/custom-rule-documentation.d.ts.map +1 -0
- package/dist/domain/custom-rule-documentation.js +35 -0
- package/dist/domain/docs/index.d.ts +4 -0
- package/dist/domain/docs/index.d.ts.map +1 -0
- package/dist/domain/docs/index.js +4 -0
- package/dist/domain/docs/no-interface-member-docs/comment-utilities-test-helpers.d.ts.map +1 -0
- package/dist/domain/docs/no-interface-member-docs/comment-utilities-test-helpers.js +129 -0
- package/dist/{docs → domain/docs}/no-interface-member-docs/comment-utilities.d.ts +1 -1
- package/dist/domain/docs/no-interface-member-docs/comment-utilities.d.ts.map +1 -0
- package/dist/domain/docs/no-interface-member-docs/comment-utilities.js +146 -0
- package/dist/domain/docs/no-interface-member-docs/index.d.ts +2 -0
- package/dist/domain/docs/no-interface-member-docs/index.d.ts.map +1 -0
- package/dist/domain/docs/no-interface-member-docs/index.js +2 -0
- package/dist/{docs → domain/docs}/no-interface-member-docs/parameter-tags.d.ts +1 -1
- package/dist/domain/docs/no-interface-member-docs/parameter-tags.d.ts.map +1 -0
- package/dist/domain/docs/no-interface-member-docs/parameter-tags.js +101 -0
- package/dist/{docs → domain/docs}/no-interface-member-docs/parameter-utilities.d.ts +1 -1
- package/dist/domain/docs/no-interface-member-docs/parameter-utilities.d.ts.map +1 -0
- package/dist/domain/docs/no-interface-member-docs/parameter-utilities.js +125 -0
- package/dist/domain/docs/no-interface-member-docs/rule.d.ts.map +1 -0
- package/dist/domain/docs/no-interface-member-docs/rule.js +168 -0
- package/dist/domain/docs/no-interface-member-docs/test-helpers.d.ts.map +1 -0
- package/dist/domain/docs/no-interface-member-docs/test-helpers.js +157 -0
- package/dist/{docs → domain/docs}/no-interface-member-docs/types.d.ts +2 -2
- package/dist/domain/docs/no-interface-member-docs/types.d.ts.map +1 -0
- package/dist/domain/docs/no-interface-member-docs/types.js +2 -0
- package/dist/domain/docs/require-example-language/create-fixer.d.ts +5 -0
- package/dist/domain/docs/require-example-language/create-fixer.d.ts.map +1 -0
- package/dist/domain/docs/require-example-language/create-fixer.js +5 -0
- package/dist/domain/docs/require-example-language/empty-fence-fixes.d.ts.map +1 -0
- package/dist/domain/docs/require-example-language/empty-fence-fixes.js +169 -0
- package/dist/domain/docs/require-example-language/example-utilities.d.ts.map +1 -0
- package/dist/domain/docs/require-example-language/example-utilities.js +76 -0
- package/dist/{docs → domain/docs}/require-example-language/examples.d.ts +1 -1
- package/dist/domain/docs/require-example-language/examples.d.ts.map +1 -0
- package/dist/domain/docs/require-example-language/examples.js +181 -0
- package/dist/{docs → domain/docs}/require-example-language/fixes.d.ts +2 -2
- package/dist/domain/docs/require-example-language/fixes.d.ts.map +1 -0
- package/dist/domain/docs/require-example-language/fixes.js +182 -0
- package/dist/domain/docs/require-example-language/index.d.ts +3 -0
- package/dist/domain/docs/require-example-language/index.d.ts.map +1 -0
- package/dist/domain/docs/require-example-language/index.js +2 -0
- package/dist/{docs → domain/docs}/require-example-language/reporting.d.ts +1 -1
- package/dist/domain/docs/require-example-language/reporting.d.ts.map +1 -0
- package/dist/domain/docs/require-example-language/reporting.js +148 -0
- package/dist/domain/docs/require-example-language/rule.d.ts.map +1 -0
- package/dist/domain/docs/require-example-language/rule.js +34 -0
- package/dist/domain/docs/require-example-language/types.d.ts.map +1 -0
- package/dist/domain/docs/require-example-language/types.js +2 -0
- package/dist/domain/docs/single-line-jsdoc/index.d.ts +2 -0
- package/dist/domain/docs/single-line-jsdoc/index.d.ts.map +1 -0
- package/dist/domain/docs/single-line-jsdoc/index.js +2 -0
- package/dist/domain/docs/single-line-jsdoc/rule.d.ts.map +1 -0
- package/dist/domain/docs/single-line-jsdoc/rule.edge-cases.d.ts +4 -0
- package/dist/domain/docs/single-line-jsdoc/rule.edge-cases.d.ts.map +1 -0
- package/dist/domain/docs/single-line-jsdoc/rule.edge-cases.js +5 -0
- package/dist/domain/docs/single-line-jsdoc/rule.js +196 -0
- package/dist/domain/docs/single-line-jsdoc/rule.node-lookups.d.ts +4 -0
- package/dist/domain/docs/single-line-jsdoc/rule.node-lookups.d.ts.map +1 -0
- package/dist/domain/docs/single-line-jsdoc/rule.node-lookups.js +5 -0
- package/dist/domain/docs/single-line-jsdoc/single-line-jsdoc-content.d.ts.map +1 -0
- package/dist/domain/docs/single-line-jsdoc/single-line-jsdoc-content.js +95 -0
- package/dist/{docs → domain/docs}/single-line-jsdoc/single-line-jsdoc-utilities.d.ts +1 -1
- package/dist/domain/docs/single-line-jsdoc/single-line-jsdoc-utilities.d.ts.map +1 -0
- package/dist/domain/docs/single-line-jsdoc/single-line-jsdoc-utilities.js +140 -0
- package/dist/domain/docs/test-helpers.d.ts.map +1 -0
- package/dist/domain/docs/test-helpers.js +107 -0
- package/dist/domain/index.d.ts +6 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +6 -0
- package/dist/domain/testing/aaa/analyzer.analysis.d.ts +92 -0
- package/dist/domain/testing/aaa/analyzer.analysis.d.ts.map +1 -0
- package/dist/domain/testing/aaa/analyzer.analysis.helpers.d.ts +4 -0
- package/dist/domain/testing/aaa/analyzer.analysis.helpers.d.ts.map +1 -0
- package/dist/domain/testing/aaa/analyzer.analysis.helpers.js +4 -0
- package/dist/domain/testing/aaa/analyzer.analysis.js +247 -0
- package/dist/domain/testing/aaa/analyzer.assertions.d.ts +93 -0
- package/dist/domain/testing/aaa/analyzer.assertions.d.ts.map +1 -0
- package/dist/domain/testing/aaa/analyzer.assertions.js +283 -0
- package/dist/domain/testing/aaa/analyzer.classification.d.ts +75 -0
- package/dist/domain/testing/aaa/analyzer.classification.d.ts.map +1 -0
- package/dist/domain/testing/aaa/analyzer.classification.js +201 -0
- package/dist/domain/testing/aaa/analyzer.classification.member-patterns.d.ts +9 -0
- package/dist/domain/testing/aaa/analyzer.classification.member-patterns.d.ts.map +1 -0
- package/dist/domain/testing/aaa/analyzer.classification.member-patterns.js +10 -0
- package/dist/domain/testing/aaa/analyzer.d.ts +46 -0
- package/dist/domain/testing/aaa/analyzer.d.ts.map +1 -0
- package/dist/domain/testing/aaa/analyzer.js +59 -0
- package/dist/domain/testing/aaa/analyzer.super.d.ts +107 -0
- package/dist/domain/testing/aaa/analyzer.super.d.ts.map +1 -0
- package/dist/domain/testing/aaa/analyzer.super.js +228 -0
- package/dist/{testing → domain/testing}/aaa/index.d.ts +2 -2
- package/dist/domain/testing/aaa/index.d.ts.map +1 -0
- package/dist/domain/testing/aaa/index.js +2 -0
- package/dist/domain/testing/aaa/types.d.ts +58 -0
- package/dist/domain/testing/aaa/types.d.ts.map +1 -0
- package/dist/domain/testing/aaa/types.js +2 -0
- package/dist/domain/testing/assert-actual-expected-names/index.d.ts +2 -0
- package/dist/domain/testing/assert-actual-expected-names/index.d.ts.map +1 -0
- package/dist/domain/testing/assert-actual-expected-names/index.js +2 -0
- package/dist/{testing → domain/testing}/assert-actual-expected-names/rule.d.ts +1 -0
- package/dist/domain/testing/assert-actual-expected-names/rule.d.ts.map +1 -0
- package/dist/domain/testing/assert-actual-expected-names/rule.js +113 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/index.d.ts +2 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/index.d.ts.map +1 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/index.js +2 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/pattern-identifiers.d.ts +13 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/pattern-identifiers.d.ts.map +1 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/pattern-identifiers.js +134 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/phase-purity-identifiers.d.ts +25 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/phase-purity-identifiers.d.ts.map +1 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/phase-purity-identifiers.js +138 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/phase-purity-reporting.behavior.d.ts +4 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/phase-purity-reporting.behavior.d.ts.map +1 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/phase-purity-reporting.behavior.js +4 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/phase-purity-reporting.d.ts +14 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/phase-purity-reporting.d.ts.map +1 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/phase-purity-reporting.js +180 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/rule-test-helpers.d.ts +42 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/rule-test-helpers.d.ts.map +1 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/rule-test-helpers.js +188 -0
- package/dist/{testing → domain/testing}/enforce-aaa-phase-purity/rule.d.ts +1 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/rule.d.ts.map +1 -0
- package/dist/domain/testing/enforce-aaa-phase-purity/rule.js +34 -0
- package/dist/domain/testing/enforce-aaa-structure/index.d.ts +2 -0
- package/dist/domain/testing/enforce-aaa-structure/index.d.ts.map +1 -0
- package/dist/domain/testing/enforce-aaa-structure/index.js +2 -0
- package/dist/{testing → domain/testing}/enforce-aaa-structure/rule.d.ts +1 -0
- package/dist/domain/testing/enforce-aaa-structure/rule.d.ts.map +1 -0
- package/dist/domain/testing/enforce-aaa-structure/rule.js +85 -0
- package/dist/{testing → domain/testing}/index.d.ts +9 -8
- package/dist/domain/testing/index.d.ts.map +1 -0
- package/dist/domain/testing/index.js +10 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix-import-statements.d.ts +29 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix-import-statements.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix-import-statements.js +90 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix-import-updates.d.ts +31 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix-import-updates.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix-import-updates.js +43 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix-imports.d.ts +16 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix-imports.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix-imports.js +205 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix.d.ts +28 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/fix.js +171 -0
- package/dist/domain/testing/prefer-vi-mocked-import/index.d.ts +2 -0
- package/dist/domain/testing/prefer-vi-mocked-import/index.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/index.js +2 -0
- package/dist/{testing → domain/testing}/prefer-vi-mocked-import/match-bindings.d.ts +1 -1
- package/dist/domain/testing/prefer-vi-mocked-import/match-bindings.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/match-bindings.js +52 -0
- package/dist/{testing → domain/testing}/prefer-vi-mocked-import/match-declarations.d.ts +2 -1
- package/dist/domain/testing/prefer-vi-mocked-import/match-declarations.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/match-declarations.js +131 -0
- package/dist/domain/testing/prefer-vi-mocked-import/match-helpers.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/match-helpers.js +102 -0
- package/dist/{testing → domain/testing}/prefer-vi-mocked-import/match-imports.d.ts +1 -1
- package/dist/domain/testing/prefer-vi-mocked-import/match-imports.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/match-imports.js +156 -0
- package/dist/{testing → domain/testing}/prefer-vi-mocked-import/match-rewrites.d.ts +1 -1
- package/dist/domain/testing/prefer-vi-mocked-import/match-rewrites.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/match-rewrites.js +119 -0
- package/dist/domain/testing/prefer-vi-mocked-import/match-walk.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/match-walk.js +62 -0
- package/dist/domain/testing/prefer-vi-mocked-import/match.d.ts +26 -0
- package/dist/domain/testing/prefer-vi-mocked-import/match.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/match.js +198 -0
- package/dist/domain/testing/prefer-vi-mocked-import/rule-test-helpers.d.ts +20 -0
- package/dist/domain/testing/prefer-vi-mocked-import/rule-test-helpers.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/rule-test-helpers.js +39 -0
- package/dist/domain/testing/prefer-vi-mocked-import/rule.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/rule.js +36 -0
- package/dist/{testing → domain/testing}/prefer-vi-mocked-import/types.d.ts +1 -1
- package/dist/domain/testing/prefer-vi-mocked-import/types.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vi-mocked-import/types.js +2 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/ast-helpers.d.ts +86 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/ast-helpers.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/ast-helpers.js +150 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/index.d.ts +2 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/index.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/index.js +2 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/match-input.d.ts +14 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/match-input.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/match-input.js +81 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/match.d.ts +13 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/match.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/match.js +189 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/replacement-helpers.d.ts +25 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/replacement-helpers.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/replacement-helpers.js +92 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule-test-helpers.d.ts +32 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule-test-helpers.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule-test-helpers.js +164 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.d.ts +5 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.guardrails.d.ts +4 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.guardrails.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.guardrails.js +4 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.input-shapes.d.ts +4 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.input-shapes.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.input-shapes.js +4 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.js +62 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.signature-fallback.d.ts +4 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.signature-fallback.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/rule.signature-fallback.js +4 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/type-helpers.d.ts +24 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/type-helpers.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/type-helpers.js +113 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/type-shape-helpers.d.ts +36 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/type-shape-helpers.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/type-shape-helpers.js +138 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/types.d.ts +203 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/types.d.ts.map +1 -0
- package/dist/domain/testing/prefer-vitest-incremental-casts/types.js +2 -0
- package/dist/domain/testing/require-aaa-sections/index.d.ts +2 -0
- package/dist/domain/testing/require-aaa-sections/index.d.ts.map +1 -0
- package/dist/domain/testing/require-aaa-sections/index.js +2 -0
- package/dist/domain/testing/require-aaa-sections/missing-section-fixes.d.ts +17 -0
- package/dist/domain/testing/require-aaa-sections/missing-section-fixes.d.ts.map +1 -0
- package/dist/domain/testing/require-aaa-sections/missing-section-fixes.js +150 -0
- package/dist/{testing → domain/testing}/require-aaa-sections/rule.d.ts +1 -0
- package/dist/domain/testing/require-aaa-sections/rule.d.ts.map +1 -0
- package/dist/domain/testing/require-aaa-sections/rule.js +129 -0
- package/dist/domain/testing/require-aaa-sections/rule.reporting.d.ts +104 -0
- package/dist/domain/testing/require-aaa-sections/rule.reporting.d.ts.map +1 -0
- package/dist/domain/testing/require-aaa-sections/rule.reporting.js +217 -0
- package/dist/domain/testing/require-act-result-capture/index.d.ts +2 -0
- package/dist/domain/testing/require-act-result-capture/index.d.ts.map +1 -0
- package/dist/domain/testing/require-act-result-capture/index.js +2 -0
- package/dist/{testing → domain/testing}/require-act-result-capture/rule.d.ts +1 -0
- package/dist/domain/testing/require-act-result-capture/rule.d.ts.map +1 -0
- package/dist/domain/testing/require-act-result-capture/rule.js +106 -0
- package/dist/domain/testing/require-test-companion/index.d.ts +3 -0
- package/dist/domain/testing/require-test-companion/index.d.ts.map +1 -0
- package/dist/domain/testing/require-test-companion/index.js +3 -0
- package/dist/{testing → domain/testing}/require-test-companion/require-test-companion-listeners.d.ts +1 -1
- package/dist/domain/testing/require-test-companion/require-test-companion-listeners.d.ts.map +1 -0
- package/dist/domain/testing/require-test-companion/require-test-companion-listeners.js +145 -0
- package/dist/domain/testing/require-test-companion/require-test-companion-options.d.ts.map +1 -0
- package/dist/domain/testing/require-test-companion/require-test-companion-options.js +113 -0
- package/dist/{testing → domain/testing}/require-test-companion/require-test-companion-test-helpers.d.ts +1 -1
- package/dist/domain/testing/require-test-companion/require-test-companion-test-helpers.d.ts.map +1 -0
- package/dist/domain/testing/require-test-companion/require-test-companion-test-helpers.js +184 -0
- package/dist/{testing → domain/testing}/require-test-companion/require-test-companion-utilities.d.ts +1 -1
- package/dist/domain/testing/require-test-companion/require-test-companion-utilities.d.ts.map +1 -0
- package/dist/domain/testing/require-test-companion/require-test-companion-utilities.js +26 -0
- package/dist/domain/testing/require-test-companion/rule.d.ts.map +1 -0
- package/dist/domain/testing/require-test-companion/rule.js +57 -0
- package/dist/domain/testing/require-test-companion/types.d.ts.map +1 -0
- package/dist/domain/testing/require-test-companion/types.js +2 -0
- package/dist/domain/testing/single-act-statement/index.d.ts +2 -0
- package/dist/domain/testing/single-act-statement/index.d.ts.map +1 -0
- package/dist/domain/testing/single-act-statement/index.js +2 -0
- package/dist/{testing → domain/testing}/single-act-statement/rule.d.ts +1 -0
- package/dist/domain/testing/single-act-statement/rule.d.ts.map +1 -0
- package/dist/domain/testing/single-act-statement/rule.js +34 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -6
- package/dist/{codeperfect-plugin.d.ts → infrastructure/codeperfect-plugin.d.ts} +2 -0
- package/dist/infrastructure/codeperfect-plugin.d.ts.map +1 -0
- package/dist/infrastructure/codeperfect-plugin.js +30 -0
- package/dist/infrastructure/index.d.ts +5 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +4 -0
- package/dist/infrastructure/presets.d.ts +18 -0
- package/dist/infrastructure/presets.d.ts.map +1 -0
- package/dist/infrastructure/presets.js +81 -0
- package/package.json +54 -27
- package/dist/architecture/consistent-barrel-files/consistent-barrel-files-listeners.d.ts.map +0 -1
- package/dist/architecture/consistent-barrel-files/consistent-barrel-files-listeners.js +0 -131
- package/dist/architecture/consistent-barrel-files/consistent-barrel-files-options.d.ts +0 -48
- package/dist/architecture/consistent-barrel-files/consistent-barrel-files-options.d.ts.map +0 -1
- package/dist/architecture/consistent-barrel-files/consistent-barrel-files-options.js +0 -126
- package/dist/architecture/consistent-barrel-files/exports-only-rule-test-utilities.d.ts.map +0 -1
- package/dist/architecture/consistent-barrel-files/exports-only-rule-test-utilities.js +0 -90
- package/dist/architecture/consistent-barrel-files/exports-only-rule.d.ts.map +0 -1
- package/dist/architecture/consistent-barrel-files/exports-only-rule.js +0 -218
- package/dist/architecture/consistent-barrel-files/index.d.ts +0 -5
- package/dist/architecture/consistent-barrel-files/index.d.ts.map +0 -1
- package/dist/architecture/consistent-barrel-files/index.js +0 -4
- package/dist/architecture/consistent-barrel-files/no-reexports-outside-barrels-rule.d.ts.map +0 -1
- package/dist/architecture/consistent-barrel-files/no-reexports-outside-barrels-rule.js +0 -100
- package/dist/architecture/consistent-barrel-files/no-reexports-outside-barrels-test-utilities.d.ts.map +0 -1
- package/dist/architecture/consistent-barrel-files/no-reexports-outside-barrels-test-utilities.js +0 -90
- package/dist/architecture/consistent-barrel-files/no-reexports-outside-barrels-utilities.d.ts.map +0 -1
- package/dist/architecture/consistent-barrel-files/no-reexports-outside-barrels-utilities.js +0 -154
- package/dist/architecture/consistent-barrel-files/rule.d.ts.map +0 -1
- package/dist/architecture/consistent-barrel-files/rule.js +0 -58
- package/dist/architecture/consistent-barrel-files/test-helpers.d.ts.map +0 -1
- package/dist/architecture/consistent-barrel-files/test-helpers.js +0 -229
- package/dist/architecture/consistent-barrel-files/types.d.ts +0 -25
- package/dist/architecture/consistent-barrel-files/types.d.ts.map +0 -1
- package/dist/architecture/consistent-barrel-files/types.js +0 -2
- package/dist/architecture/index.d.ts.map +0 -1
- package/dist/architecture/index.js +0 -2
- package/dist/benchmark-rules.d.ts +0 -83
- package/dist/benchmark-rules.d.ts.map +0 -1
- package/dist/benchmark-rules.js +0 -175
- package/dist/codeperfect-plugin.d.ts.map +0 -1
- package/dist/codeperfect-plugin.js +0 -29
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -3
- package/dist/core/no-multiple-declarators/index.d.ts +0 -2
- package/dist/core/no-multiple-declarators/index.d.ts.map +0 -1
- package/dist/core/no-multiple-declarators/index.js +0 -2
- package/dist/core/no-multiple-declarators/rule.d.ts.map +0 -1
- package/dist/core/no-multiple-declarators/rule.js +0 -100
- package/dist/core/prefer-interface-types/index.d.ts +0 -2
- package/dist/core/prefer-interface-types/index.d.ts.map +0 -1
- package/dist/core/prefer-interface-types/index.js +0 -2
- package/dist/core/prefer-interface-types/rule.d.ts.map +0 -1
- package/dist/core/prefer-interface-types/rule.js +0 -145
- package/dist/core/prefer-interface-types/test-helpers.d.ts.map +0 -1
- package/dist/core/prefer-interface-types/test-helpers.js +0 -116
- package/dist/custom-rule-documentation.d.ts.map +0 -1
- package/dist/custom-rule-documentation.js +0 -35
- package/dist/custom-rules.d.ts.map +0 -1
- package/dist/custom-rules.js +0 -70
- package/dist/docs/index.d.ts +0 -4
- package/dist/docs/index.d.ts.map +0 -1
- package/dist/docs/index.js +0 -4
- package/dist/docs/no-interface-member-docs/comment-utilities-test-helpers.d.ts.map +0 -1
- package/dist/docs/no-interface-member-docs/comment-utilities-test-helpers.js +0 -129
- package/dist/docs/no-interface-member-docs/comment-utilities.d.ts.map +0 -1
- package/dist/docs/no-interface-member-docs/comment-utilities.js +0 -146
- package/dist/docs/no-interface-member-docs/index.d.ts +0 -2
- package/dist/docs/no-interface-member-docs/index.d.ts.map +0 -1
- package/dist/docs/no-interface-member-docs/index.js +0 -2
- package/dist/docs/no-interface-member-docs/parameter-tags.d.ts.map +0 -1
- package/dist/docs/no-interface-member-docs/parameter-tags.js +0 -101
- package/dist/docs/no-interface-member-docs/parameter-utilities.d.ts.map +0 -1
- package/dist/docs/no-interface-member-docs/parameter-utilities.js +0 -125
- package/dist/docs/no-interface-member-docs/rule.d.ts.map +0 -1
- package/dist/docs/no-interface-member-docs/rule.js +0 -168
- package/dist/docs/no-interface-member-docs/test-helpers.d.ts.map +0 -1
- package/dist/docs/no-interface-member-docs/test-helpers.js +0 -157
- package/dist/docs/no-interface-member-docs/types.d.ts.map +0 -1
- package/dist/docs/no-interface-member-docs/types.js +0 -2
- package/dist/docs/require-example-language/empty-fence-fixes.d.ts.map +0 -1
- package/dist/docs/require-example-language/empty-fence-fixes.js +0 -169
- package/dist/docs/require-example-language/example-utilities.d.ts.map +0 -1
- package/dist/docs/require-example-language/example-utilities.js +0 -76
- package/dist/docs/require-example-language/examples.d.ts.map +0 -1
- package/dist/docs/require-example-language/examples.js +0 -181
- package/dist/docs/require-example-language/fixes.d.ts.map +0 -1
- package/dist/docs/require-example-language/fixes.js +0 -182
- package/dist/docs/require-example-language/index.d.ts +0 -3
- package/dist/docs/require-example-language/index.d.ts.map +0 -1
- package/dist/docs/require-example-language/index.js +0 -2
- package/dist/docs/require-example-language/reporting.d.ts.map +0 -1
- package/dist/docs/require-example-language/reporting.js +0 -145
- package/dist/docs/require-example-language/rule.d.ts.map +0 -1
- package/dist/docs/require-example-language/rule.js +0 -34
- package/dist/docs/require-example-language/types.d.ts.map +0 -1
- package/dist/docs/require-example-language/types.js +0 -2
- package/dist/docs/single-line-jsdoc/index.d.ts +0 -2
- package/dist/docs/single-line-jsdoc/index.d.ts.map +0 -1
- package/dist/docs/single-line-jsdoc/index.js +0 -2
- package/dist/docs/single-line-jsdoc/rule.d.ts.map +0 -1
- package/dist/docs/single-line-jsdoc/rule.js +0 -196
- package/dist/docs/single-line-jsdoc/single-line-jsdoc-content.d.ts.map +0 -1
- package/dist/docs/single-line-jsdoc/single-line-jsdoc-content.js +0 -95
- package/dist/docs/single-line-jsdoc/single-line-jsdoc-utilities.d.ts.map +0 -1
- package/dist/docs/single-line-jsdoc/single-line-jsdoc-utilities.js +0 -140
- package/dist/docs/test-helpers.d.ts.map +0 -1
- package/dist/docs/test-helpers.js +0 -107
- package/dist/presets.d.ts +0 -10
- package/dist/presets.d.ts.map +0 -1
- package/dist/presets.js +0 -50
- package/dist/rules/index.d.ts +0 -5
- package/dist/rules/index.d.ts.map +0 -1
- package/dist/rules/index.js +0 -6
- package/dist/testing/aaa/analyzer.d.ts +0 -36
- package/dist/testing/aaa/analyzer.d.ts.map +0 -1
- package/dist/testing/aaa/analyzer.js +0 -490
- package/dist/testing/aaa/index.d.ts.map +0 -1
- package/dist/testing/aaa/index.js +0 -2
- package/dist/testing/aaa/types.d.ts +0 -31
- package/dist/testing/aaa/types.d.ts.map +0 -1
- package/dist/testing/aaa/types.js +0 -2
- package/dist/testing/assert-actual-expected-names/index.d.ts +0 -2
- package/dist/testing/assert-actual-expected-names/index.d.ts.map +0 -1
- package/dist/testing/assert-actual-expected-names/index.js +0 -2
- package/dist/testing/assert-actual-expected-names/rule.d.ts.map +0 -1
- package/dist/testing/assert-actual-expected-names/rule.js +0 -54
- package/dist/testing/enforce-aaa-phase-purity/index.d.ts +0 -2
- package/dist/testing/enforce-aaa-phase-purity/index.d.ts.map +0 -1
- package/dist/testing/enforce-aaa-phase-purity/index.js +0 -2
- package/dist/testing/enforce-aaa-phase-purity/rule.d.ts.map +0 -1
- package/dist/testing/enforce-aaa-phase-purity/rule.js +0 -110
- package/dist/testing/enforce-aaa-structure/index.d.ts +0 -2
- package/dist/testing/enforce-aaa-structure/index.d.ts.map +0 -1
- package/dist/testing/enforce-aaa-structure/index.js +0 -2
- package/dist/testing/enforce-aaa-structure/rule.d.ts.map +0 -1
- package/dist/testing/enforce-aaa-structure/rule.js +0 -48
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js +0 -9
- package/dist/testing/prefer-vi-mocked-import/fix.d.ts +0 -16
- package/dist/testing/prefer-vi-mocked-import/fix.d.ts.map +0 -1
- package/dist/testing/prefer-vi-mocked-import/fix.js +0 -224
- package/dist/testing/prefer-vi-mocked-import/index.d.ts +0 -2
- package/dist/testing/prefer-vi-mocked-import/index.d.ts.map +0 -1
- package/dist/testing/prefer-vi-mocked-import/index.js +0 -2
- package/dist/testing/prefer-vi-mocked-import/match-bindings.d.ts.map +0 -1
- package/dist/testing/prefer-vi-mocked-import/match-bindings.js +0 -52
- package/dist/testing/prefer-vi-mocked-import/match-declarations.d.ts.map +0 -1
- package/dist/testing/prefer-vi-mocked-import/match-declarations.js +0 -99
- package/dist/testing/prefer-vi-mocked-import/match-helpers.d.ts.map +0 -1
- package/dist/testing/prefer-vi-mocked-import/match-helpers.js +0 -102
- package/dist/testing/prefer-vi-mocked-import/match-imports.d.ts.map +0 -1
- package/dist/testing/prefer-vi-mocked-import/match-imports.js +0 -156
- package/dist/testing/prefer-vi-mocked-import/match-rewrites.d.ts.map +0 -1
- package/dist/testing/prefer-vi-mocked-import/match-rewrites.js +0 -119
- package/dist/testing/prefer-vi-mocked-import/match-walk.d.ts.map +0 -1
- package/dist/testing/prefer-vi-mocked-import/match-walk.js +0 -62
- package/dist/testing/prefer-vi-mocked-import/match.d.ts +0 -15
- package/dist/testing/prefer-vi-mocked-import/match.d.ts.map +0 -1
- package/dist/testing/prefer-vi-mocked-import/match.js +0 -193
- package/dist/testing/prefer-vi-mocked-import/rule.d.ts.map +0 -1
- package/dist/testing/prefer-vi-mocked-import/rule.js +0 -32
- package/dist/testing/prefer-vi-mocked-import/types.d.ts.map +0 -1
- package/dist/testing/prefer-vi-mocked-import/types.js +0 -2
- package/dist/testing/require-aaa-sections/index.d.ts +0 -2
- package/dist/testing/require-aaa-sections/index.d.ts.map +0 -1
- package/dist/testing/require-aaa-sections/index.js +0 -2
- package/dist/testing/require-aaa-sections/rule.d.ts.map +0 -1
- package/dist/testing/require-aaa-sections/rule.js +0 -111
- package/dist/testing/require-act-result-capture/index.d.ts +0 -2
- package/dist/testing/require-act-result-capture/index.d.ts.map +0 -1
- package/dist/testing/require-act-result-capture/index.js +0 -2
- package/dist/testing/require-act-result-capture/rule.d.ts.map +0 -1
- package/dist/testing/require-act-result-capture/rule.js +0 -34
- package/dist/testing/require-test-companion/index.d.ts +0 -3
- package/dist/testing/require-test-companion/index.d.ts.map +0 -1
- package/dist/testing/require-test-companion/index.js +0 -3
- package/dist/testing/require-test-companion/require-test-companion-listeners.d.ts.map +0 -1
- package/dist/testing/require-test-companion/require-test-companion-listeners.js +0 -145
- package/dist/testing/require-test-companion/require-test-companion-options.d.ts.map +0 -1
- package/dist/testing/require-test-companion/require-test-companion-options.js +0 -112
- package/dist/testing/require-test-companion/require-test-companion-test-helpers.d.ts.map +0 -1
- package/dist/testing/require-test-companion/require-test-companion-test-helpers.js +0 -183
- package/dist/testing/require-test-companion/require-test-companion-utilities.d.ts.map +0 -1
- package/dist/testing/require-test-companion/require-test-companion-utilities.js +0 -26
- package/dist/testing/require-test-companion/rule.d.ts.map +0 -1
- package/dist/testing/require-test-companion/rule.js +0 -57
- package/dist/testing/require-test-companion/types.d.ts.map +0 -1
- package/dist/testing/require-test-companion/types.js +0 -2
- package/dist/testing/single-act-statement/index.d.ts +0 -2
- package/dist/testing/single-act-statement/index.d.ts.map +0 -1
- package/dist/testing/single-act-statement/index.js +0 -2
- package/dist/testing/single-act-statement/rule.d.ts.map +0 -1
- package/dist/testing/single-act-statement/rule.js +0 -33
- /package/dist/{architecture → domain/architecture}/consistent-barrel-files/exports-only-rule.d.ts +0 -0
- /package/dist/{architecture → domain/architecture}/consistent-barrel-files/no-reexports-outside-barrels-rule.d.ts +0 -0
- /package/dist/{architecture → domain/architecture}/consistent-barrel-files/rule.d.ts +0 -0
- /package/dist/{core → domain/core}/prefer-interface-types/rule.d.ts +0 -0
- /package/dist/{core → domain/core}/prefer-interface-types/test-helpers.d.ts +0 -0
- /package/dist/{docs → domain/docs}/no-interface-member-docs/comment-utilities-test-helpers.d.ts +0 -0
- /package/dist/{docs → domain/docs}/no-interface-member-docs/rule.d.ts +0 -0
- /package/dist/{docs → domain/docs}/no-interface-member-docs/test-helpers.d.ts +0 -0
- /package/dist/{docs → domain/docs}/require-example-language/empty-fence-fixes.d.ts +0 -0
- /package/dist/{docs → domain/docs}/require-example-language/example-utilities.d.ts +0 -0
- /package/dist/{docs → domain/docs}/require-example-language/rule.d.ts +0 -0
- /package/dist/{docs → domain/docs}/require-example-language/types.d.ts +0 -0
- /package/dist/{docs → domain/docs}/single-line-jsdoc/rule.d.ts +0 -0
- /package/dist/{docs → domain/docs}/single-line-jsdoc/single-line-jsdoc-content.d.ts +0 -0
- /package/dist/{docs → domain/docs}/test-helpers.d.ts +0 -0
- /package/dist/{testing → domain/testing}/prefer-vi-mocked-import/match-helpers.d.ts +0 -0
- /package/dist/{testing → domain/testing}/prefer-vi-mocked-import/match-walk.d.ts +0 -0
- /package/dist/{testing → domain/testing}/prefer-vi-mocked-import/rule.d.ts +0 -0
- /package/dist/{testing → domain/testing}/require-test-companion/require-test-companion-options.d.ts +0 -0
- /package/dist/{testing → domain/testing}/require-test-companion/rule.d.ts +0 -0
- /package/dist/{testing → domain/testing}/require-test-companion/types.d.ts +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { hasRange } from "./match-helpers.js";
|
|
2
|
+
/**
|
|
3
|
+
* Builds an import plan for insertion mode.
|
|
4
|
+
* @param moduleSpecifier Target module path.
|
|
5
|
+
* @param names Names to import.
|
|
6
|
+
* @param afterRange Range to insert after.
|
|
7
|
+
* @returns Insert plan payload.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const plan = createInsertPlan("./x", ["a"], [0, 1]);
|
|
11
|
+
* void plan;
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
function createInsertPlan(moduleSpecifier, names, afterRange) {
|
|
15
|
+
return afterRange === void 0
|
|
16
|
+
? { insert: {}, moduleSpecifier, names }
|
|
17
|
+
: { insert: { afterRange }, moduleSpecifier, names };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Builds an import plan for update mode.
|
|
21
|
+
* @param statement Existing import declaration.
|
|
22
|
+
* @param moduleSpecifier Target module path.
|
|
23
|
+
* @param names Names to import.
|
|
24
|
+
* @returns Update plan payload.
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const plan = createUpdatePlan({ specifiers: [], source: { type: "Literal", value: "./x" }, type: "ImportDeclaration", range: [0, 1] } as never, "./x", ["a"]);
|
|
28
|
+
* void plan;
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function createUpdatePlan(statement, moduleSpecifier, names) {
|
|
32
|
+
if (hasNamespaceImport(statement)) {
|
|
33
|
+
return createInsertPlan(moduleSpecifier, names, statement.range);
|
|
34
|
+
}
|
|
35
|
+
const defaultImportName = getDefaultImportName(statement);
|
|
36
|
+
const baseUpdate = {
|
|
37
|
+
existingNamedImports: getNamedImports(statement),
|
|
38
|
+
range: statement.range,
|
|
39
|
+
};
|
|
40
|
+
const update = defaultImportName === void 0
|
|
41
|
+
? baseUpdate
|
|
42
|
+
: { ...baseUpdate, defaultImportName };
|
|
43
|
+
return {
|
|
44
|
+
moduleSpecifier,
|
|
45
|
+
names,
|
|
46
|
+
update,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns the default import local name.
|
|
51
|
+
* @param statement Import declaration.
|
|
52
|
+
* @returns Default local name when present.
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const localName = getDefaultImportName({ specifiers: [], type: "ImportDeclaration" } as never);
|
|
56
|
+
* void localName;
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
function getDefaultImportName(statement) {
|
|
60
|
+
const defaultSpecifier = statement.specifiers.find((specifier) => specifier.type === "ImportDefaultSpecifier");
|
|
61
|
+
return defaultSpecifier?.local.name;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Filters top-level import declarations that include a `range`.
|
|
65
|
+
* @param program Program node.
|
|
66
|
+
* @returns Import declarations with stable ranges.
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const imports = getImportDeclarations({ body: [], sourceType: "module", type: "Program" } as never);
|
|
70
|
+
* void imports;
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
function getImportDeclarations(program) {
|
|
74
|
+
return program.body.filter((statement) => statement.type === "ImportDeclaration" && hasRange(statement));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns all named imports from a declaration.
|
|
78
|
+
* @param statement Import declaration.
|
|
79
|
+
* @returns Named import identifiers.
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const named = getNamedImports({ specifiers: [], type: "ImportDeclaration" } as never);
|
|
83
|
+
* void named;
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
function getNamedImports(statement) {
|
|
87
|
+
return statement.specifiers.flatMap((specifier) => {
|
|
88
|
+
const importedName = toImportedName(specifier);
|
|
89
|
+
return importedName === void 0 ? [] : [importedName];
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Checks whether an import includes a namespace specifier.
|
|
94
|
+
* @param statement Import declaration.
|
|
95
|
+
* @returns True when declaration includes `* as x` form.
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const hasNamespace = hasNamespaceImport({ specifiers: [], type: "ImportDeclaration" } as never);
|
|
99
|
+
* void hasNamespace;
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
function hasNamespaceImport(statement) {
|
|
103
|
+
return statement.specifiers.some((specifier) => specifier.type === "ImportNamespaceSpecifier");
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Checks whether an import declaration matches the mocked module.
|
|
107
|
+
* @param statement Import declaration candidate.
|
|
108
|
+
* @param moduleSpecifier Expected module path.
|
|
109
|
+
* @returns True when declaration targets the same module.
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const matched = isMatchingImport({ source: { type: "Literal", value: "./x" }, type: "ImportDeclaration" } as never, "./x");
|
|
113
|
+
* void matched;
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
function isMatchingImport(statement, moduleSpecifier) {
|
|
117
|
+
const sourceValue = statement.source.value;
|
|
118
|
+
return typeof sourceValue === "string" && sourceValue === moduleSpecifier;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Resolves whether imports should be updated in place or inserted.
|
|
122
|
+
* @param program Program node to inspect.
|
|
123
|
+
* @param moduleSpecifier Target module path.
|
|
124
|
+
* @param names Import names that must exist.
|
|
125
|
+
* @returns Insert or update plan for the import section.
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const plan = resolveImportPlan({ body: [], sourceType: "module", type: "Program" } as never, "./x", ["a"]);
|
|
129
|
+
* void plan;
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
function resolveImportPlan(program, moduleSpecifier, names) {
|
|
133
|
+
const imports = getImportDeclarations(program);
|
|
134
|
+
const existingImport = imports.find((statement) => isMatchingImport(statement, moduleSpecifier));
|
|
135
|
+
return existingImport === void 0
|
|
136
|
+
? createInsertPlan(moduleSpecifier, names, imports.at(-1)?.range)
|
|
137
|
+
: createUpdatePlan(existingImport, moduleSpecifier, names);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Extracts imported identifier name from one specifier.
|
|
141
|
+
* @param specifier Import clause entry.
|
|
142
|
+
* @returns Imported identifier name.
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const imported = toImportedName({ type: "ImportSpecifier", imported: { type: "Identifier", name: "x" } } as never);
|
|
146
|
+
* void imported;
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
function toImportedName(specifier) {
|
|
150
|
+
return specifier.type === "ImportSpecifier" &&
|
|
151
|
+
specifier.imported.type === "Identifier"
|
|
152
|
+
? specifier.imported.name
|
|
153
|
+
: void 0;
|
|
154
|
+
}
|
|
155
|
+
export { resolveImportPlan };
|
|
156
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW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9uZSBzcGVjaWZpZXIuXG4gKiBAcGFyYW0gc3BlY2lmaWVyIEltcG9ydCBjbGF1c2UgZW50cnkuXG4gKiBAcmV0dXJucyBJbXBvcnRlZCBpZGVudGlmaWVyIG5hbWUuXG4gKiBAZXhhbXBsZVxuICogYGBgdHlwZXNjcmlwdFxuICogY29uc3QgaW1wb3J0ZWQgPSB0b0ltcG9ydGVkTmFtZSh7IHR5cGU6IFwiSW1wb3J0U3BlY2lmaWVyXCIsIGltcG9ydGVkOiB7IHR5cGU6IFwiSWRlbnRpZmllclwiLCBuYW1lOiBcInhcIiB9IH0gYXMgbmV2ZXIpO1xuICogdm9pZCBpbXBvcnRlZDtcbiAqIGBgYFxuICovXG5mdW5jdGlvbiB0b0ltcG9ydGVkTmFtZShcbiAgc3BlY2lmaWVyOiBFU1RyZWUuSW1wb3J0RGVjbGFyYXRpb25bXCJzcGVjaWZpZXJzXCJdW251bWJlcl0sXG4pOiBzdHJpbmcgfCB1bmRlZmluZWQge1xuICByZXR1cm4gc3BlY2lmaWVyLnR5cGUgPT09IFwiSW1wb3J0U3BlY2lmaWVyXCIgJiZcbiAgICBzcGVjaWZpZXIuaW1wb3J0ZWQudHlwZSA9PT0gXCJJZGVudGlmaWVyXCJcbiAgICA/IHNwZWNpZmllci5pbXBvcnRlZC5uYW1lXG4gICAgOiB2b2lkIDA7XG59XG5cbmV4cG9ydCB7IHJlc29sdmVJbXBvcnRQbGFuIH07XG4iXX0=
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as ESTree from "estree";
|
|
2
|
-
import type { Binding, Declaration, MemberRewrite } from "./types";
|
|
2
|
+
import type { Binding, Declaration, MemberRewrite } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Returns false if a binding local is used outside allowed rewrite sites.
|
|
5
5
|
* @param program Program node containing mock usage.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-rewrites.d.ts","sourceRoot":"","sources":["../../../../src/domain/testing/prefer-vi-mocked-import/match-rewrites.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAyBnE;;;;;;;;;;;GAWG;AACH,iBAAS,qBAAqB,CAC5B,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,uBAAuB,EAAE,GAAG,CAAC,MAAM,CAAC,EACpC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,GACtB,OAAO,CAkBT;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,kBAAkB,CACzB,QAAQ,EAAE,OAAO,EAAE,EACnB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EACtC,QAAQ,EAAE,aAAa,EAAE,GACxB,GAAG,CAAC,MAAM,CAAC,CAkBb;AAED;;;;;;;;;;GAUG;AACH,iBAAS,qBAAqB,CAC5B,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,aAAa,EAAE,CAUjB;AAqCD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { hasRange } from "./match-helpers.js";
|
|
2
|
+
import { walkNode } from "./match-walk.js";
|
|
3
|
+
/**
|
|
4
|
+
* Adds declaration identifier range to the allowed set.
|
|
5
|
+
* @param allowedRanges Allowed range set.
|
|
6
|
+
* @param declaration Declaration to include.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const allowed = new Set<string>();
|
|
10
|
+
* addDeclarationIdRange(allowed, void 0);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
function addDeclarationIdRange(allowedRanges, declaration) {
|
|
14
|
+
if (declaration !== void 0) {
|
|
15
|
+
const rangeKey = `${declaration.declarationIdRange[0]}:${declaration.declarationIdRange[1]}`;
|
|
16
|
+
allowedRanges.add(rangeKey);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns false if a binding local is used outside allowed rewrite sites.
|
|
21
|
+
* @param program Program node containing mock usage.
|
|
22
|
+
* @param allowedIdentifierRanges Identifier ranges that are safe to rewrite.
|
|
23
|
+
* @param localNames Local names tracked by the matcher.
|
|
24
|
+
* @returns True when all local usages are safe.
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const safe = areLocalsSafeToInline({ body: [], sourceType: "module", type: "Program" } as never, new Set(), new Set());
|
|
28
|
+
* void safe;
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function areLocalsSafeToInline(program, allowedIdentifierRanges, localNames) {
|
|
32
|
+
let isSafe = true;
|
|
33
|
+
walkNode(program, (currentNode) => {
|
|
34
|
+
if (!isSafe ||
|
|
35
|
+
currentNode.type !== "Identifier" ||
|
|
36
|
+
!hasRange(currentNode)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const key = `${currentNode.range[0]}:${currentNode.range[1]}`;
|
|
40
|
+
if (localNames.has(currentNode.name) && !allowedIdentifierRanges.has(key)) {
|
|
41
|
+
isSafe = false;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return isSafe;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Builds a set of allowed identifier ranges for safe-inline validation.
|
|
48
|
+
* @param bindings Bindings list.
|
|
49
|
+
* @param declarations Declarations map.
|
|
50
|
+
* @param rewrites Member rewrites.
|
|
51
|
+
* @returns Allowed identifier range keys.
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const ranges = buildAllowedRanges([], new Map(), []);
|
|
55
|
+
* void ranges;
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
function buildAllowedRanges(bindings, declarations, rewrites) {
|
|
59
|
+
const allowedRanges = new Set();
|
|
60
|
+
for (const binding of bindings) {
|
|
61
|
+
allowedRanges.add(`${binding.propertyKeyRange[0]}:${binding.propertyKeyRange[1]}`);
|
|
62
|
+
allowedRanges.add(`${binding.propertyValueRange[0]}:${binding.propertyValueRange[1]}`);
|
|
63
|
+
addDeclarationIdRange(allowedRanges, declarations.get(binding.localName));
|
|
64
|
+
}
|
|
65
|
+
for (const rewrite of rewrites) {
|
|
66
|
+
allowedRanges.add(`${rewrite.localObjectRange[0]}:${rewrite.localObjectRange[1]}`);
|
|
67
|
+
}
|
|
68
|
+
return allowedRanges;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Collects member-expression object rewrites for `.mock*` calls.
|
|
72
|
+
* @param program Program node.
|
|
73
|
+
* @param localToExported Local to exported name map.
|
|
74
|
+
* @returns Collected member rewrites.
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const rewrites = collectMemberRewrites({ body: [], sourceType: "module", type: "Program" } as never, new Map());
|
|
78
|
+
* void rewrites;
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
function collectMemberRewrites(program, localToExported) {
|
|
82
|
+
const rewrites = [];
|
|
83
|
+
walkNode(program, (currentNode) => {
|
|
84
|
+
const rewrite = toMemberRewrite(currentNode, localToExported);
|
|
85
|
+
if (rewrite !== void 0) {
|
|
86
|
+
rewrites.push(rewrite);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return rewrites;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Converts a node into a member rewrite when supported.
|
|
93
|
+
* @param currentNode Candidate node.
|
|
94
|
+
* @param localToExported Local to exported name map.
|
|
95
|
+
* @returns Member rewrite when node is supported.
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const rewrite = toMemberRewrite({ type: "Identifier", name: "x" } as never, new Map());
|
|
99
|
+
* void rewrite;
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
function toMemberRewrite(currentNode, localToExported) {
|
|
103
|
+
if (currentNode.type !== "MemberExpression") {
|
|
104
|
+
return void 0;
|
|
105
|
+
}
|
|
106
|
+
const { object, property } = currentNode;
|
|
107
|
+
if (object.type !== "Identifier" ||
|
|
108
|
+
!hasRange(object) ||
|
|
109
|
+
property.type !== "Identifier" ||
|
|
110
|
+
!property.name.startsWith("mock")) {
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
const exportedName = localToExported.get(object.name);
|
|
114
|
+
return exportedName === void 0
|
|
115
|
+
? void 0
|
|
116
|
+
: { exportedName, localObjectRange: object.range };
|
|
117
|
+
}
|
|
118
|
+
export { areLocalsSafeToInline, buildAllowedRanges, collectMemberRewrites };
|
|
119
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWF0Y2gtcmV3cml0ZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvZG9tYWluL3Rlc3RpbmcvcHJlZmVyLXZpLW1vY2tlZC1pbXBvcnQvbWF0Y2gtcmV3cml0ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBSUEsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQzNDLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFFeEM7Ozs7Ozs7OztHQVNHO0FBQ0gsU0FBUyxxQkFBcUIsQ0FDNUIsYUFBMEIsRUFDMUIsV0FBb0M7SUFFcEMsSUFBSSxXQUFXLEtBQUssS0FBSyxDQUFDLEVBQUUsQ0FBQztRQUMzQixNQUFNLFFBQVEsR0FBRyxHQUFHLFdBQVcsQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDLENBQUMsSUFBSSxXQUFXLENBQUMsa0JBQWtCLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQztRQUM3RixhQUFhL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JlZS5Ob2RlLFxuICBsb2NhbFRvRXhwb3J0ZWQ6IE1hcDxzdHJpbmcsIHN0cmluZz4sXG4pOiBNZW1iZXJSZXdyaXRlIHwgdW5kZWZpbmVkIHtcbiAgaWYgKGN1cnJlbnROb2RlLnR5cGUgIT09IFwiTWVtYmVyRXhwcmVzc2lvblwiKSB7XG4gICAgcmV0dXJuIHZvaWQgMDtcbiAgfVxuXG4gIGNvbnN0IHsgb2JqZWN0LCBwcm9wZXJ0eSB9ID0gY3VycmVudE5vZGU7XG4gIGlmIChcbiAgICBvYmplY3QudHlwZSAhPT0gXCJJZGVudGlmaWVyXCIgfHxcbiAgICAhaGFzUmFuZ2Uob2JqZWN0KSB8fFxuICAgIHByb3BlcnR5LnR5cGUgIT09IFwiSWRlbnRpZmllclwiIHx8XG4gICAgIXByb3BlcnR5Lm5hbWUuc3RhcnRzV2l0aChcIm1vY2tcIilcbiAgKSB7XG4gICAgcmV0dXJuIHZvaWQgMDtcbiAgfVxuXG4gIGNvbnN0IGV4cG9ydGVkTmFtZSA9IGxvY2FsVG9FeHBvcnRlZC5nZXQob2JqZWN0Lm5hbWUpO1xuICByZXR1cm4gZXhwb3J0ZWROYW1lID09PSB2b2lkIDBcbiAgICA/IHZvaWQgMFxuICAgIDogeyBleHBvcnRlZE5hbWUsIGxvY2FsT2JqZWN0UmFuZ2U6IG9iamVjdC5yYW5nZSB9O1xufVxuXG5leHBvcnQgeyBhcmVMb2NhbHNTYWZlVG9JbmxpbmUsIGJ1aWxkQWxsb3dlZFJhbmdlcywgY29sbGVjdE1lbWJlclJld3JpdGVzIH07XG4iXX0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-walk.d.ts","sourceRoot":"","sources":["../../../../src/domain/testing/prefer-vi-mocked-import/match-walk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAC;AAqDtC;;;;;;;;GAQG;AACH,iBAAS,QAAQ,CACf,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,OAAO,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,KAAK,IAAI,GAC1C,IAAI,CAKN;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns child nodes for a given AST node.
|
|
3
|
+
* @param node Source node.
|
|
4
|
+
* @returns Flattened list of child nodes.
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const childNodes = getChildNodes({ type: "Program", body: [], sourceType: "module" } as never);
|
|
8
|
+
* void childNodes;
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
function getChildNodes(node) {
|
|
12
|
+
const values = Object.entries(node)
|
|
13
|
+
.filter(([key]) => key !== "parent")
|
|
14
|
+
.map(([, value]) => value);
|
|
15
|
+
return values.flatMap((value) => toNodeList(value));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Checks whether a value is an ESTree node.
|
|
19
|
+
* @param value Arbitrary value from node property iteration.
|
|
20
|
+
* @returns True when the value has node-like shape.
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const ok = isNode({ type: "Identifier", name: "x" });
|
|
24
|
+
* void ok;
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
function isNode(value) {
|
|
28
|
+
return typeof value === "object" && value !== null && "type" in value;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Converts an unknown value into a list of AST nodes.
|
|
32
|
+
* @param value Arbitrary value from the AST object graph.
|
|
33
|
+
* @returns Node list extracted from arrays or single values.
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const list = toNodeList([{ type: "Identifier", name: "x" }] as never);
|
|
37
|
+
* void list;
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
function toNodeList(value) {
|
|
41
|
+
if (Array.isArray(value)) {
|
|
42
|
+
return value.filter((nodeValue) => isNode(nodeValue));
|
|
43
|
+
}
|
|
44
|
+
return isNode(value) ? [value] : [];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Visits a node and all nested child nodes.
|
|
48
|
+
* @param node Root node to visit.
|
|
49
|
+
* @param visitor Callback run for each visited node.
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* walkNode({ type: "Program", body: [], sourceType: "module" } as never, () => {});
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
function walkNode(node, visitor) {
|
|
56
|
+
visitor(node);
|
|
57
|
+
for (const childNode of getChildNodes(node)) {
|
|
58
|
+
walkNode(childNode, visitor);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export { walkNode };
|
|
62
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWF0Y2gtd2Fsay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9kb21haW4vdGVzdGluZy9wcmVmZXItdmktbW9ja2VkLWltcG9ydC9tYXRjaC13YWxrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBOzs7Ozs7Ozs7R0FTRztBQUNILFNBQVMsYUFBYSxDQUFDLElBQWlCO0lBQ3RDLE1BQU0sTUFBTSxHQUFHLE1BQU0sQ0FBQyxPQUFPLENBQUMsSUFBMEMsQ0FBQztTQUN0RSxNQUFNLENBQUMsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxHQUFHLEtBQUssUUFBUSxDQUFDO1NBQ25DLEdBQUcsQ0FBQyxDQUFDLENBQUMsRUFBRSxLQUFLLENBQUMsRUFBRSxFQUFFLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDN0IsT0FBTyxNQUFNLENBQUMsT0FBTyxDQUFDLENBQUMsS0FBSyxFQUFFLEVBQUUsQ0FBQyx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0LlxuICogQHBhcmFtIHZpc2l0b3IgQ2FsbGJhY2sgcnVuIGZvciBlYWNoIHZpc2l0ZWQgbm9kZS5cbiAqIEBleGFtcGxlXG4gKiBgYGB0eXBlc2NyaXB0XG4gKiB3YWxrTm9kZSh7IHR5cGU6IFwiUHJvZ3JhbVwiLCBib2R5OiBbXSwgc291cmNlVHlwZTogXCJtb2R1bGVcIiB9IGFzIG5ldmVyLCAoKSA9PiB7fSk7XG4gKiBgYGBcbiAqL1xuZnVuY3Rpb24gd2Fsa05vZGUoXG4gIG5vZGU6IEVTVHJlZS5Ob2RlLFxuICB2aXNpdG9yOiAoY3VycmVudE5vZGU6IEVTVHJlZS5Ob2RlKSA9PiB2b2lkLFxuKTogdm9pZCB7XG4gIHZpc2l0b3Iobm9kZSk7XG4gIGZvciAoY29uc3QgY2hpbGROb2RlIG9mIGdldENoaWxkTm9kZXMobm9kZSkpIHtcbiAgICB3YWxrTm9kZShjaGlsZE5vZGUsIHZpc2l0b3IpO1xuICB9XG59XG5cbmV4cG9ydCB7IHdhbGtOb2RlIH07XG4iXX0=
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
import type { RuleMatch } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Collects the first applicable rule match from the file.
|
|
5
|
+
* @param context Rule context.
|
|
6
|
+
* @returns Collected match when pattern is found.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const match = collectMatch({ sourceCode: { ast: { body: [], sourceType: "module", type: "Program" }, text: "" } } as never);
|
|
10
|
+
* void match;
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
declare function collectMatch(context: Rule.RuleContext): RuleMatch | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Collects every applicable rule match from the file.
|
|
16
|
+
* @param context Rule context.
|
|
17
|
+
* @returns Collected matches when patterns are found.
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const matches = collectMatches({ sourceCode: { ast: { body: [], sourceType: "module", type: "Program" }, text: "" } } as never);
|
|
21
|
+
* void matches;
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare function collectMatches(context: Rule.RuleContext): RuleMatch[];
|
|
25
|
+
export { collectMatch, collectMatches };
|
|
26
|
+
//# sourceMappingURL=match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../../src/domain/testing/prefer-vi-mocked-import/match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAwFzC;;;;;;;;;GASG;AACH,iBAAS,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,GAAG,SAAS,GAAG,SAAS,CAEtE;AAED;;;;;;;;;GASG;AACH,iBAAS,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,GAAG,SAAS,EAAE,CAM9D;AAmKD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
|