@ddd-ts-kit/eslint-plugin 0.0.0-stage → 0.1.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 +292 -2
- package/dist/ddd-ts-kit.d.ts +5 -0
- package/dist/ddd-ts-kit.d.ts.map +1 -0
- package/dist/ddd-ts-kit.js +7 -0
- package/dist/ddd-ts-kit.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +30 -0
- package/dist/plugin.js.map +1 -0
- package/dist/presets/braces-rules.d.ts +11 -0
- package/dist/presets/braces-rules.d.ts.map +1 -0
- package/dist/presets/braces-rules.js +10 -0
- package/dist/presets/braces-rules.js.map +1 -0
- package/dist/presets/create-ddd-ts-kit.d.ts +21 -0
- package/dist/presets/create-ddd-ts-kit.d.ts.map +1 -0
- package/dist/presets/create-ddd-ts-kit.js +123 -0
- package/dist/presets/create-ddd-ts-kit.js.map +1 -0
- package/dist/presets/flat-rules.d.ts +3 -0
- package/dist/presets/flat-rules.d.ts.map +1 -0
- package/dist/presets/flat-rules.js +2 -0
- package/dist/presets/flat-rules.js.map +1 -0
- package/dist/presets/layout-rules.d.ts +11 -0
- package/dist/presets/layout-rules.d.ts.map +1 -0
- package/dist/presets/layout-rules.js +33 -0
- package/dist/presets/layout-rules.js.map +1 -0
- package/dist/presets/plugin-rule-levels.d.ts +4 -0
- package/dist/presets/plugin-rule-levels.d.ts.map +1 -0
- package/dist/presets/plugin-rule-levels.js +13 -0
- package/dist/presets/plugin-rule-levels.js.map +1 -0
- package/dist/presets/standard-rule-sets.d.ts +12 -0
- package/dist/presets/standard-rule-sets.d.ts.map +1 -0
- package/dist/presets/standard-rule-sets.js +15 -0
- package/dist/presets/standard-rule-sets.js.map +1 -0
- package/dist/presets/standard-rules.d.ts +24 -0
- package/dist/presets/standard-rules.d.ts.map +1 -0
- package/dist/presets/standard-rules.js +88 -0
- package/dist/presets/standard-rules.js.map +1 -0
- package/dist/project/alias-root.d.ts +8 -0
- package/dist/project/alias-root.d.ts.map +1 -0
- package/dist/project/alias-root.js +2 -0
- package/dist/project/alias-root.js.map +1 -0
- package/dist/project/alias-roots.d.ts +9 -0
- package/dist/project/alias-roots.d.ts.map +1 -0
- package/dist/project/alias-roots.js +17 -0
- package/dist/project/alias-roots.js.map +1 -0
- package/dist/project/config-file.d.ts +2 -0
- package/dist/project/config-file.d.ts.map +1 -0
- package/dist/project/config-file.js +2 -0
- package/dist/project/config-file.js.map +1 -0
- package/dist/project/config.d.ts +53 -0
- package/dist/project/config.d.ts.map +1 -0
- package/dist/project/config.js +2 -0
- package/dist/project/config.js.map +1 -0
- package/dist/project/configured-severity.d.ts +3 -0
- package/dist/project/configured-severity.d.ts.map +1 -0
- package/dist/project/configured-severity.js +5 -0
- package/dist/project/configured-severity.js.map +1 -0
- package/dist/project/describe-linted-file.d.ts +4 -0
- package/dist/project/describe-linted-file.d.ts.map +1 -0
- package/dist/project/describe-linted-file.js +38 -0
- package/dist/project/describe-linted-file.js.map +1 -0
- package/dist/project/find-project.d.ts +4 -0
- package/dist/project/find-project.d.ts.map +1 -0
- package/dist/project/find-project.js +37 -0
- package/dist/project/find-project.js.map +1 -0
- package/dist/project/is-record.d.ts +2 -0
- package/dist/project/is-record.d.ts.map +1 -0
- package/dist/project/is-record.js +4 -0
- package/dist/project/is-record.js.map +1 -0
- package/dist/project/is-test-file.d.ts +3 -0
- package/dist/project/is-test-file.d.ts.map +1 -0
- package/dist/project/is-test-file.js +4 -0
- package/dist/project/is-test-file.js.map +1 -0
- package/dist/project/layer.d.ts +2 -0
- package/dist/project/layer.d.ts.map +1 -0
- package/dist/project/layer.js +2 -0
- package/dist/project/layer.js.map +1 -0
- package/dist/project/lint-host.d.ts +6 -0
- package/dist/project/lint-host.d.ts.map +1 -0
- package/dist/project/lint-host.js +2 -0
- package/dist/project/lint-host.js.map +1 -0
- package/dist/project/linted-file.d.ts +13 -0
- package/dist/project/linted-file.d.ts.map +1 -0
- package/dist/project/linted-file.js +2 -0
- package/dist/project/linted-file.js.map +1 -0
- package/dist/project/locate.d.ts +5 -0
- package/dist/project/locate.d.ts.map +1 -0
- package/dist/project/locate.js +47 -0
- package/dist/project/locate.js.map +1 -0
- package/dist/project/location.d.ts +11 -0
- package/dist/project/location.d.ts.map +1 -0
- package/dist/project/location.js +2 -0
- package/dist/project/location.js.map +1 -0
- package/dist/project/parse-allowed-file.d.ts +4 -0
- package/dist/project/parse-allowed-file.d.ts.map +1 -0
- package/dist/project/parse-allowed-file.js +11 -0
- package/dist/project/parse-allowed-file.js.map +1 -0
- package/dist/project/parse-config.d.ts +10 -0
- package/dist/project/parse-config.d.ts.map +1 -0
- package/dist/project/parse-config.js +113 -0
- package/dist/project/parse-config.js.map +1 -0
- package/dist/project/plugin-settings.d.ts +8 -0
- package/dist/project/plugin-settings.d.ts.map +1 -0
- package/dist/project/plugin-settings.js +2 -0
- package/dist/project/plugin-settings.js.map +1 -0
- package/dist/project/posix.d.ts +2 -0
- package/dist/project/posix.d.ts.map +1 -0
- package/dist/project/posix.js +4 -0
- package/dist/project/posix.js.map +1 -0
- package/dist/project/resolve-import.d.ts +15 -0
- package/dist/project/resolve-import.d.ts.map +1 -0
- package/dist/project/resolve-import.js +32 -0
- package/dist/project/resolve-import.js.map +1 -0
- package/dist/project/to-alias.d.ts +7 -0
- package/dist/project/to-alias.d.ts.map +1 -0
- package/dist/project/to-alias.js +13 -0
- package/dist/project/to-alias.js.map +1 -0
- package/dist/project/to-posix.d.ts +2 -0
- package/dist/project/to-posix.d.ts.map +1 -0
- package/dist/project/to-posix.js +5 -0
- package/dist/project/to-posix.js.map +1 -0
- package/dist/rules/application-command-query-separation.d.ts +6 -0
- package/dist/rules/application-command-query-separation.d.ts.map +1 -0
- package/dist/rules/application-command-query-separation.js +49 -0
- package/dist/rules/application-command-query-separation.js.map +1 -0
- package/dist/rules/application-handler-shape.d.ts +4 -0
- package/dist/rules/application-handler-shape.d.ts.map +1 -0
- package/dist/rules/application-handler-shape.js +51 -0
- package/dist/rules/application-handler-shape.js.map +1 -0
- package/dist/rules/aspects-outside-in.d.ts +2 -0
- package/dist/rules/aspects-outside-in.d.ts.map +1 -0
- package/dist/rules/aspects-outside-in.js +45 -0
- package/dist/rules/aspects-outside-in.js.map +1 -0
- package/dist/rules/authz-actor-explicit.d.ts +5 -0
- package/dist/rules/authz-actor-explicit.d.ts.map +1 -0
- package/dist/rules/authz-actor-explicit.js +106 -0
- package/dist/rules/authz-actor-explicit.js.map +1 -0
- package/dist/rules/authz-declared.d.ts +5 -0
- package/dist/rules/authz-declared.d.ts.map +1 -0
- package/dist/rules/authz-declared.js +167 -0
- package/dist/rules/authz-declared.js.map +1 -0
- package/dist/rules/authz-in-application.d.ts +5 -0
- package/dist/rules/authz-in-application.d.ts.map +1 -0
- package/dist/rules/authz-in-application.js +202 -0
- package/dist/rules/authz-in-application.js.map +1 -0
- package/dist/rules/clean-file-size.d.ts +2 -0
- package/dist/rules/clean-file-size.d.ts.map +1 -0
- package/dist/rules/clean-file-size.js +25 -0
- package/dist/rules/clean-file-size.js.map +1 -0
- package/dist/rules/clean-function-ceiling.d.ts +6 -0
- package/dist/rules/clean-function-ceiling.d.ts.map +1 -0
- package/dist/rules/clean-function-ceiling.js +32 -0
- package/dist/rules/clean-function-ceiling.js.map +1 -0
- package/dist/rules/clean-function-size.d.ts +7 -0
- package/dist/rules/clean-function-size.d.ts.map +1 -0
- package/dist/rules/clean-function-size.js +70 -0
- package/dist/rules/clean-function-size.js.map +1 -0
- package/dist/rules/clean-no-commented-out-code.d.ts +3 -0
- package/dist/rules/clean-no-commented-out-code.d.ts.map +1 -0
- package/dist/rules/clean-no-commented-out-code.js +60 -0
- package/dist/rules/clean-no-commented-out-code.js.map +1 -0
- package/dist/rules/clean-no-escape-hatch.d.ts +15 -0
- package/dist/rules/clean-no-escape-hatch.d.ts.map +1 -0
- package/dist/rules/clean-no-escape-hatch.js +116 -0
- package/dist/rules/clean-no-escape-hatch.js.map +1 -0
- package/dist/rules/clean-no-flag-argument.d.ts +2 -0
- package/dist/rules/clean-no-flag-argument.d.ts.map +1 -0
- package/dist/rules/clean-no-flag-argument.js +80 -0
- package/dist/rules/clean-no-flag-argument.js.map +1 -0
- package/dist/rules/clean-no-hash-private.d.ts +2 -0
- package/dist/rules/clean-no-hash-private.d.ts.map +1 -0
- package/dist/rules/clean-no-hash-private.js +36 -0
- package/dist/rules/clean-no-hash-private.js.map +1 -0
- package/dist/rules/clean-no-noise-comment.d.ts +5 -0
- package/dist/rules/clean-no-noise-comment.d.ts.map +1 -0
- package/dist/rules/clean-no-noise-comment.js +187 -0
- package/dist/rules/clean-no-noise-comment.js.map +1 -0
- package/dist/rules/clean-one-export-per-file.d.ts +10 -0
- package/dist/rules/clean-one-export-per-file.d.ts.map +1 -0
- package/dist/rules/clean-one-export-per-file.js +124 -0
- package/dist/rules/clean-one-export-per-file.js.map +1 -0
- package/dist/rules/clean-stepdown.d.ts +3 -0
- package/dist/rules/clean-stepdown.d.ts.map +1 -0
- package/dist/rules/clean-stepdown.js +33 -0
- package/dist/rules/clean-stepdown.js.map +1 -0
- package/dist/rules/context-boundaries.d.ts +4 -0
- package/dist/rules/context-boundaries.d.ts.map +1 -0
- package/dist/rules/context-boundaries.js +87 -0
- package/dist/rules/context-boundaries.js.map +1 -0
- package/dist/rules/context-extractable.d.ts +5 -0
- package/dist/rules/context-extractable.d.ts.map +1 -0
- package/dist/rules/context-extractable.js +242 -0
- package/dist/rules/context-extractable.js.map +1 -0
- package/dist/rules/declarations-role-declared.d.ts +5 -0
- package/dist/rules/declarations-role-declared.d.ts.map +1 -0
- package/dist/rules/declarations-role-declared.js +142 -0
- package/dist/rules/declarations-role-declared.js.map +1 -0
- package/dist/rules/domain-aggregate-encapsulation.d.ts +4 -0
- package/dist/rules/domain-aggregate-encapsulation.d.ts.map +1 -0
- package/dist/rules/domain-aggregate-encapsulation.js +93 -0
- package/dist/rules/domain-aggregate-encapsulation.js.map +1 -0
- package/dist/rules/domain-events-dispatched-on-save.d.ts +3 -0
- package/dist/rules/domain-events-dispatched-on-save.d.ts.map +1 -0
- package/dist/rules/domain-events-dispatched-on-save.js +87 -0
- package/dist/rules/domain-events-dispatched-on-save.js.map +1 -0
- package/dist/rules/domain-events-transactional-before-commit.d.ts +4 -0
- package/dist/rules/domain-events-transactional-before-commit.d.ts.map +1 -0
- package/dist/rules/domain-events-transactional-before-commit.js +121 -0
- package/dist/rules/domain-events-transactional-before-commit.js.map +1 -0
- package/dist/rules/domain-no-generic-error.d.ts +2 -0
- package/dist/rules/domain-no-generic-error.d.ts.map +1 -0
- package/dist/rules/domain-no-generic-error.js +32 -0
- package/dist/rules/domain-no-generic-error.js.map +1 -0
- package/dist/rules/domain-value-object-immutability.d.ts +4 -0
- package/dist/rules/domain-value-object-immutability.d.ts.map +1 -0
- package/dist/rules/domain-value-object-immutability.js +77 -0
- package/dist/rules/domain-value-object-immutability.js.map +1 -0
- package/dist/rules/events-consumer-idempotent.d.ts +5 -0
- package/dist/rules/events-consumer-idempotent.d.ts.map +1 -0
- package/dist/rules/events-consumer-idempotent.js +115 -0
- package/dist/rules/events-consumer-idempotent.js.map +1 -0
- package/dist/rules/events-name-format.d.ts +2 -0
- package/dist/rules/events-name-format.d.ts.map +1 -0
- package/dist/rules/events-name-format.js +53 -0
- package/dist/rules/events-name-format.js.map +1 -0
- package/dist/rules/events-outbox-required.d.ts +7 -0
- package/dist/rules/events-outbox-required.d.ts.map +1 -0
- package/dist/rules/events-outbox-required.js +82 -0
- package/dist/rules/events-outbox-required.js.map +1 -0
- package/dist/rules/governance-recorded-deviation.d.ts +2 -0
- package/dist/rules/governance-recorded-deviation.d.ts.map +1 -0
- package/dist/rules/governance-recorded-deviation.js +73 -0
- package/dist/rules/governance-recorded-deviation.js.map +1 -0
- package/dist/rules/imports-alias-only.d.ts +5 -0
- package/dist/rules/imports-alias-only.d.ts.map +1 -0
- package/dist/rules/imports-alias-only.js +63 -0
- package/dist/rules/imports-alias-only.js.map +1 -0
- package/dist/rules/layer-application-inward.d.ts +2 -0
- package/dist/rules/layer-application-inward.d.ts.map +1 -0
- package/dist/rules/layer-application-inward.js +66 -0
- package/dist/rules/layer-application-inward.js.map +1 -0
- package/dist/rules/layer-domain-purity.d.ts +4 -0
- package/dist/rules/layer-domain-purity.d.ts.map +1 -0
- package/dist/rules/layer-domain-purity.js +75 -0
- package/dist/rules/layer-domain-purity.js.map +1 -0
- package/dist/rules/layer-sideways.d.ts +3 -0
- package/dist/rules/layer-sideways.d.ts.map +1 -0
- package/dist/rules/layer-sideways.js +42 -0
- package/dist/rules/layer-sideways.js.map +1 -0
- package/dist/rules/ports-abstract-class.d.ts +2 -0
- package/dist/rules/ports-abstract-class.d.ts.map +1 -0
- package/dist/rules/ports-abstract-class.js +74 -0
- package/dist/rules/ports-abstract-class.js.map +1 -0
- package/dist/rules/ports-implements-never-extends.d.ts +5 -0
- package/dist/rules/ports-implements-never-extends.d.ts.map +1 -0
- package/dist/rules/ports-implements-never-extends.js +81 -0
- package/dist/rules/ports-implements-never-extends.js.map +1 -0
- package/dist/rules/ports-no-concrete-dependency.d.ts +2 -0
- package/dist/rules/ports-no-concrete-dependency.d.ts.map +1 -0
- package/dist/rules/ports-no-concrete-dependency.js +32 -0
- package/dist/rules/ports-no-concrete-dependency.js.map +1 -0
- package/dist/rules/ports-no-token-constant.d.ts +5 -0
- package/dist/rules/ports-no-token-constant.d.ts.map +1 -0
- package/dist/rules/ports-no-token-constant.js +109 -0
- package/dist/rules/ports-no-token-constant.js.map +1 -0
- package/dist/rules/ports-value-import.d.ts +3 -0
- package/dist/rules/ports-value-import.d.ts.map +1 -0
- package/dist/rules/ports-value-import.js +60 -0
- package/dist/rules/ports-value-import.js.map +1 -0
- package/dist/rules/purity.d.ts +4 -0
- package/dist/rules/purity.d.ts.map +1 -0
- package/dist/rules/purity.js +65 -0
- package/dist/rules/purity.js.map +1 -0
- package/dist/rules/rules.d.ts +4 -0
- package/dist/rules/rules.d.ts.map +1 -0
- package/dist/rules/rules.js +97 -0
- package/dist/rules/rules.js.map +1 -0
- package/dist/rules/scheduling-job-name.d.ts +5 -0
- package/dist/rules/scheduling-job-name.d.ts.map +1 -0
- package/dist/rules/scheduling-job-name.js +98 -0
- package/dist/rules/scheduling-job-name.js.map +1 -0
- package/dist/rules/scheduling-job-triggers-use-case.d.ts +5 -0
- package/dist/rules/scheduling-job-triggers-use-case.d.ts.map +1 -0
- package/dist/rules/scheduling-job-triggers-use-case.js +129 -0
- package/dist/rules/scheduling-job-triggers-use-case.js.map +1 -0
- package/dist/rules/standard-no-parallel-interface.d.ts +2 -0
- package/dist/rules/standard-no-parallel-interface.d.ts.map +1 -0
- package/dist/rules/standard-no-parallel-interface.js +57 -0
- package/dist/rules/standard-no-parallel-interface.js.map +1 -0
- package/dist/rules/test-no-mocks.d.ts +2 -0
- package/dist/rules/test-no-mocks.d.ts.map +1 -0
- package/dist/rules/test-no-mocks.js +50 -0
- package/dist/rules/test-no-mocks.js.map +1 -0
- package/dist/rules/tracing-platform-only.d.ts +2 -0
- package/dist/rules/tracing-platform-only.d.ts.map +1 -0
- package/dist/rules/tracing-platform-only.js +52 -0
- package/dist/rules/tracing-platform-only.js.map +1 -0
- package/dist/support/ancestors.d.ts +4 -0
- package/dist/support/ancestors.d.ts.map +1 -0
- package/dist/support/ancestors.js +7 -0
- package/dist/support/ancestors.js.map +1 -0
- package/dist/support/calls/accessed-name.d.ts +4 -0
- package/dist/support/calls/accessed-name.d.ts.map +1 -0
- package/dist/support/calls/accessed-name.js +14 -0
- package/dist/support/calls/accessed-name.js.map +1 -0
- package/dist/support/calls/callee-name.d.ts +4 -0
- package/dist/support/calls/callee-name.d.ts.map +1 -0
- package/dist/support/calls/callee-name.js +11 -0
- package/dist/support/calls/callee-name.js.map +1 -0
- package/dist/support/calls/has-spread.d.ts +4 -0
- package/dist/support/calls/has-spread.d.ts.map +1 -0
- package/dist/support/calls/has-spread.js +6 -0
- package/dist/support/calls/has-spread.js.map +1 -0
- package/dist/support/calls/method-chain.d.ts +8 -0
- package/dist/support/calls/method-chain.d.ts.map +1 -0
- package/dist/support/calls/method-chain.js +13 -0
- package/dist/support/calls/method-chain.js.map +1 -0
- package/dist/support/calls/missing-keys.d.ts +7 -0
- package/dist/support/calls/missing-keys.d.ts.map +1 -0
- package/dist/support/calls/missing-keys.js +28 -0
- package/dist/support/calls/missing-keys.js.map +1 -0
- package/dist/support/calls/property-of.d.ts +3 -0
- package/dist/support/calls/property-of.d.ts.map +1 -0
- package/dist/support/calls/property-of.js +8 -0
- package/dist/support/calls/property-of.js.map +1 -0
- package/dist/support/classes/class-finder.d.ts +18 -0
- package/dist/support/classes/class-finder.d.ts.map +1 -0
- package/dist/support/classes/class-finder.js +76 -0
- package/dist/support/classes/class-finder.js.map +1 -0
- package/dist/support/classes/class-name.d.ts +4 -0
- package/dist/support/classes/class-name.d.ts.map +1 -0
- package/dist/support/classes/class-name.js +4 -0
- package/dist/support/classes/class-name.js.map +1 -0
- package/dist/support/classes/constructor-of.d.ts +3 -0
- package/dist/support/classes/constructor-of.d.ts.map +1 -0
- package/dist/support/classes/constructor-of.js +5 -0
- package/dist/support/classes/constructor-of.js.map +1 -0
- package/dist/support/classes/enclosing-member.d.ts +8 -0
- package/dist/support/classes/enclosing-member.d.ts.map +1 -0
- package/dist/support/classes/enclosing-member.js +15 -0
- package/dist/support/classes/enclosing-member.js.map +1 -0
- package/dist/support/classes/exported-classes.d.ts +4 -0
- package/dist/support/classes/exported-classes.d.ts.map +1 -0
- package/dist/support/classes/exported-classes.js +22 -0
- package/dist/support/classes/exported-classes.js.map +1 -0
- package/dist/support/classes/is-callable.d.ts +4 -0
- package/dist/support/classes/is-callable.d.ts.map +1 -0
- package/dist/support/classes/is-callable.js +10 -0
- package/dist/support/classes/is-callable.js.map +1 -0
- package/dist/support/classes/is-constructor.d.ts +3 -0
- package/dist/support/classes/is-constructor.d.ts.map +1 -0
- package/dist/support/classes/is-constructor.js +5 -0
- package/dist/support/classes/is-constructor.js.map +1 -0
- package/dist/support/classes/is-function.d.ts +3 -0
- package/dist/support/classes/is-function.d.ts.map +1 -0
- package/dist/support/classes/is-function.js +5 -0
- package/dist/support/classes/is-function.js.map +1 -0
- package/dist/support/classes/is-inline-export.d.ts +3 -0
- package/dist/support/classes/is-inline-export.d.ts.map +1 -0
- package/dist/support/classes/is-inline-export.js +6 -0
- package/dist/support/classes/is-inline-export.js.map +1 -0
- package/dist/support/classes/is-keyed.d.ts +5 -0
- package/dist/support/classes/is-keyed.d.ts.map +1 -0
- package/dist/support/classes/is-keyed.js +5 -0
- package/dist/support/classes/is-keyed.js.map +1 -0
- package/dist/support/classes/key-name.d.ts +3 -0
- package/dist/support/classes/key-name.d.ts.map +1 -0
- package/dist/support/classes/key-name.js +11 -0
- package/dist/support/classes/key-name.js.map +1 -0
- package/dist/support/classes/member-name.d.ts +4 -0
- package/dist/support/classes/member-name.d.ts.map +1 -0
- package/dist/support/classes/member-name.js +7 -0
- package/dist/support/classes/member-name.js.map +1 -0
- package/dist/support/classes/top-level-classes.d.ts +4 -0
- package/dist/support/classes/top-level-classes.d.ts.map +1 -0
- package/dist/support/classes/top-level-classes.js +10 -0
- package/dist/support/classes/top-level-classes.js.map +1 -0
- package/dist/support/classes/visibility-of.d.ts +4 -0
- package/dist/support/classes/visibility-of.d.ts.map +1 -0
- package/dist/support/classes/visibility-of.js +12 -0
- package/dist/support/classes/visibility-of.js.map +1 -0
- package/dist/support/comments/comment-lines.d.ts +15 -0
- package/dist/support/comments/comment-lines.d.ts.map +1 -0
- package/dist/support/comments/comment-lines.js +47 -0
- package/dist/support/comments/comment-lines.js.map +1 -0
- package/dist/support/comments/is-commented-out-code.d.ts +6 -0
- package/dist/support/comments/is-commented-out-code.d.ts.map +1 -0
- package/dist/support/comments/is-commented-out-code.js +108 -0
- package/dist/support/comments/is-commented-out-code.js.map +1 -0
- package/dist/support/comments/is-directive.d.ts +3 -0
- package/dist/support/comments/is-directive.d.ts.map +1 -0
- package/dist/support/comments/is-directive.js +6 -0
- package/dist/support/comments/is-directive.js.map +1 -0
- package/dist/support/comments/is-fragment.d.ts +3 -0
- package/dist/support/comments/is-fragment.d.ts.map +1 -0
- package/dist/support/comments/is-fragment.js +18 -0
- package/dist/support/comments/is-fragment.js.map +1 -0
- package/dist/support/comments/is-jsdoc.d.ts +3 -0
- package/dist/support/comments/is-jsdoc.d.ts.map +1 -0
- package/dist/support/comments/is-jsdoc.js +5 -0
- package/dist/support/comments/is-jsdoc.js.map +1 -0
- package/dist/support/comments/prose-opening.d.ts +3 -0
- package/dist/support/comments/prose-opening.d.ts.map +1 -0
- package/dist/support/comments/prose-opening.js +3 -0
- package/dist/support/comments/prose-opening.js.map +1 -0
- package/dist/support/comments/reads-as-prose.d.ts +3 -0
- package/dist/support/comments/reads-as-prose.d.ts.map +1 -0
- package/dist/support/comments/reads-as-prose.js +7 -0
- package/dist/support/comments/reads-as-prose.js.map +1 -0
- package/dist/support/declarations/access-decorators.d.ts +3 -0
- package/dist/support/declarations/access-decorators.d.ts.map +1 -0
- package/dist/support/declarations/access-decorators.js +3 -0
- package/dist/support/declarations/access-decorators.js.map +1 -0
- package/dist/support/declarations/declaration-reader.d.ts +19 -0
- package/dist/support/declarations/declaration-reader.d.ts.map +1 -0
- package/dist/support/declarations/declaration-reader.js +46 -0
- package/dist/support/declarations/declaration-reader.js.map +1 -0
- package/dist/support/declarations/declared-role-of.d.ts +5 -0
- package/dist/support/declarations/declared-role-of.d.ts.map +1 -0
- package/dist/support/declarations/declared-role-of.js +12 -0
- package/dist/support/declarations/declared-role-of.js.map +1 -0
- package/dist/support/declarations/declared-role.d.ts +9 -0
- package/dist/support/declarations/declared-role.d.ts.map +1 -0
- package/dist/support/declarations/declared-role.js +2 -0
- package/dist/support/declarations/declared-role.js.map +1 -0
- package/dist/support/declarations/declared-roles.d.ts +4 -0
- package/dist/support/declarations/declared-roles.d.ts.map +1 -0
- package/dist/support/declarations/declared-roles.js +20 -0
- package/dist/support/declarations/declared-roles.js.map +1 -0
- package/dist/support/declarations/is-declared-style.d.ts +3 -0
- package/dist/support/declarations/is-declared-style.d.ts.map +1 -0
- package/dist/support/declarations/is-declared-style.js +4 -0
- package/dist/support/declarations/is-declared-style.js.map +1 -0
- package/dist/support/declarations/written-name.d.ts +11 -0
- package/dist/support/declarations/written-name.d.ts.map +1 -0
- package/dist/support/declarations/written-name.js +22 -0
- package/dist/support/declarations/written-name.js.map +1 -0
- package/dist/support/declarations/written-names.d.ts +3 -0
- package/dist/support/declarations/written-names.d.ts.map +1 -0
- package/dist/support/declarations/written-names.js +7 -0
- package/dist/support/declarations/written-names.js.map +1 -0
- package/dist/support/descendants.d.ts +4 -0
- package/dist/support/descendants.d.ts.map +1 -0
- package/dist/support/descendants.js +21 -0
- package/dist/support/descendants.js.map +1 -0
- package/dist/support/exports/derived-forms-of.d.ts +8 -0
- package/dist/support/exports/derived-forms-of.d.ts.map +1 -0
- package/dist/support/exports/derived-forms-of.js +23 -0
- package/dist/support/exports/derived-forms-of.js.map +1 -0
- package/dist/support/exports/explain-exports.d.ts +11 -0
- package/dist/support/exports/explain-exports.d.ts.map +1 -0
- package/dist/support/exports/explain-exports.js +60 -0
- package/dist/support/exports/explain-exports.js.map +1 -0
- package/dist/support/exports/export-explanation.d.ts +9 -0
- package/dist/support/exports/export-explanation.d.ts.map +1 -0
- package/dist/support/exports/export-explanation.js +2 -0
- package/dist/support/exports/export-explanation.js.map +1 -0
- package/dist/support/exports/is-named-after.d.ts +8 -0
- package/dist/support/exports/is-named-after.d.ts.map +1 -0
- package/dist/support/exports/is-named-after.js +16 -0
- package/dist/support/exports/is-named-after.js.map +1 -0
- package/dist/support/exports/module-shape-of.d.ts +4 -0
- package/dist/support/exports/module-shape-of.d.ts.map +1 -0
- package/dist/support/exports/module-shape-of.js +11 -0
- package/dist/support/exports/module-shape-of.js.map +1 -0
- package/dist/support/exports/module-shape.d.ts +10 -0
- package/dist/support/exports/module-shape.d.ts.map +1 -0
- package/dist/support/exports/module-shape.js +2 -0
- package/dist/support/exports/module-shape.js.map +1 -0
- package/dist/support/exports/shares-private-state.d.ts +11 -0
- package/dist/support/exports/shares-private-state.d.ts.map +1 -0
- package/dist/support/exports/shares-private-state.js +36 -0
- package/dist/support/exports/shares-private-state.js.map +1 -0
- package/dist/support/exports/signature-of.d.ts +8 -0
- package/dist/support/exports/signature-of.d.ts.map +1 -0
- package/dist/support/exports/signature-of.js +44 -0
- package/dist/support/exports/signature-of.js.map +1 -0
- package/dist/support/exports/top-level-declaration.d.ts +10 -0
- package/dist/support/exports/top-level-declaration.d.ts.map +1 -0
- package/dist/support/exports/top-level-declaration.js +2 -0
- package/dist/support/exports/top-level-declaration.js.map +1 -0
- package/dist/support/exports/top-level-declarations.d.ts +5 -0
- package/dist/support/exports/top-level-declarations.d.ts.map +1 -0
- package/dist/support/exports/top-level-declarations.js +48 -0
- package/dist/support/exports/top-level-declarations.js.map +1 -0
- package/dist/support/exports/type-closure.d.ts +5 -0
- package/dist/support/exports/type-closure.d.ts.map +1 -0
- package/dist/support/exports/type-closure.js +18 -0
- package/dist/support/exports/type-closure.js.map +1 -0
- package/dist/support/exports/type-family-of.d.ts +8 -0
- package/dist/support/exports/type-family-of.d.ts.map +1 -0
- package/dist/support/exports/type-family-of.js +43 -0
- package/dist/support/exports/type-family-of.js.map +1 -0
- package/dist/support/exports/type-names-in.d.ts +4 -0
- package/dist/support/exports/type-names-in.d.ts.map +1 -0
- package/dist/support/exports/type-names-in.js +21 -0
- package/dist/support/exports/type-names-in.js.map +1 -0
- package/dist/support/functions/code-lines.d.ts +5 -0
- package/dist/support/functions/code-lines.d.ts.map +1 -0
- package/dist/support/functions/code-lines.js +14 -0
- package/dist/support/functions/code-lines.js.map +1 -0
- package/dist/support/functions/described-function.d.ts +11 -0
- package/dist/support/functions/described-function.d.ts.map +1 -0
- package/dist/support/functions/described-function.js +9 -0
- package/dist/support/functions/described-function.js.map +1 -0
- package/dist/support/functions/function-node.d.ts +3 -0
- package/dist/support/functions/function-node.d.ts.map +1 -0
- package/dist/support/functions/function-node.js +2 -0
- package/dist/support/functions/function-node.js.map +1 -0
- package/dist/support/glob-matcher.d.ts +3 -0
- package/dist/support/glob-matcher.d.ts.map +1 -0
- package/dist/support/glob-matcher.js +8 -0
- package/dist/support/glob-matcher.js.map +1 -0
- package/dist/support/globals/ambient-name.d.ts +8 -0
- package/dist/support/globals/ambient-name.d.ts.map +1 -0
- package/dist/support/globals/ambient-name.js +26 -0
- package/dist/support/globals/ambient-name.js.map +1 -0
- package/dist/support/globals/property-name.d.ts +3 -0
- package/dist/support/globals/property-name.d.ts.map +1 -0
- package/dist/support/globals/property-name.js +10 -0
- package/dist/support/globals/property-name.js.map +1 -0
- package/dist/support/hash-private-fix.d.ts +12 -0
- package/dist/support/hash-private-fix.d.ts.map +1 -0
- package/dist/support/hash-private-fix.js +52 -0
- package/dist/support/hash-private-fix.js.map +1 -0
- package/dist/support/imports/describe-target.d.ts +3 -0
- package/dist/support/imports/describe-target.d.ts.map +1 -0
- package/dist/support/imports/describe-target.js +11 -0
- package/dist/support/imports/describe-target.js.map +1 -0
- package/dist/support/imports/import-listener.d.ts +23 -0
- package/dist/support/imports/import-listener.d.ts.map +1 -0
- package/dist/support/imports/import-listener.js +43 -0
- package/dist/support/imports/import-listener.js.map +1 -0
- package/dist/support/imports/in-context.d.ts +4 -0
- package/dist/support/imports/in-context.d.ts.map +1 -0
- package/dist/support/imports/in-context.js +4 -0
- package/dist/support/imports/in-context.js.map +1 -0
- package/dist/support/imports/in-layer.d.ts +5 -0
- package/dist/support/imports/in-layer.d.ts.map +1 -0
- package/dist/support/imports/in-layer.js +4 -0
- package/dist/support/imports/in-layer.js.map +1 -0
- package/dist/support/imports/in-source-root.d.ts +4 -0
- package/dist/support/imports/in-source-root.d.ts.map +1 -0
- package/dist/support/imports/in-source-root.js +5 -0
- package/dist/support/imports/in-source-root.js.map +1 -0
- package/dist/support/imports/inner-layer.d.ts +4 -0
- package/dist/support/imports/inner-layer.d.ts.map +1 -0
- package/dist/support/imports/inner-layer.js +9 -0
- package/dist/support/imports/inner-layer.js.map +1 -0
- package/dist/support/imports/static-string.d.ts +3 -0
- package/dist/support/imports/static-string.d.ts.map +1 -0
- package/dist/support/imports/static-string.js +11 -0
- package/dist/support/imports/static-string.js.map +1 -0
- package/dist/support/kebab-case.d.ts +7 -0
- package/dist/support/kebab-case.d.ts.map +1 -0
- package/dist/support/kebab-case.js +13 -0
- package/dist/support/kebab-case.js.map +1 -0
- package/dist/support/members/parameter-name.d.ts +3 -0
- package/dist/support/members/parameter-name.d.ts.map +1 -0
- package/dist/support/members/parameter-name.js +7 -0
- package/dist/support/members/parameter-name.js.map +1 -0
- package/dist/support/members/parameter-properties.d.ts +4 -0
- package/dist/support/members/parameter-properties.d.ts.map +1 -0
- package/dist/support/members/parameter-properties.js +6 -0
- package/dist/support/members/parameter-properties.js.map +1 -0
- package/dist/support/members/starts-at-this.d.ts +4 -0
- package/dist/support/members/starts-at-this.d.ts.map +1 -0
- package/dist/support/members/starts-at-this.js +10 -0
- package/dist/support/members/starts-at-this.js.map +1 -0
- package/dist/support/outside-concerns/outside-concern-message.d.ts +3 -0
- package/dist/support/outside-concerns/outside-concern-message.d.ts.map +1 -0
- package/dist/support/outside-concerns/outside-concern-message.js +3 -0
- package/dist/support/outside-concerns/outside-concern-message.js.map +1 -0
- package/dist/support/outside-concerns/outside-concern.d.ts +13 -0
- package/dist/support/outside-concerns/outside-concern.d.ts.map +1 -0
- package/dist/support/outside-concerns/outside-concern.js +31 -0
- package/dist/support/outside-concerns/outside-concern.js.map +1 -0
- package/dist/support/ports/binding-call-reader.d.ts +10 -0
- package/dist/support/ports/binding-call-reader.d.ts.map +1 -0
- package/dist/support/ports/binding-call-reader.js +25 -0
- package/dist/support/ports/binding-call-reader.js.map +1 -0
- package/dist/support/ports/dependency-list-listener.d.ts +10 -0
- package/dist/support/ports/dependency-list-listener.d.ts.map +1 -0
- package/dist/support/ports/dependency-list-listener.js +37 -0
- package/dist/support/ports/dependency-list-listener.js.map +1 -0
- package/dist/support/ports/imported-binding.d.ts +11 -0
- package/dist/support/ports/imported-binding.d.ts.map +1 -0
- package/dist/support/ports/imported-binding.js +2 -0
- package/dist/support/ports/imported-binding.js.map +1 -0
- package/dist/support/ports/imported-bindings.d.ts +6 -0
- package/dist/support/ports/imported-bindings.d.ts.map +1 -0
- package/dist/support/ports/imported-bindings.js +19 -0
- package/dist/support/ports/imported-bindings.js.map +1 -0
- package/dist/support/ports/is-port-file.d.ts +4 -0
- package/dist/support/ports/is-port-file.d.ts.map +1 -0
- package/dist/support/ports/is-port-file.js +13 -0
- package/dist/support/ports/is-port-file.js.map +1 -0
- package/dist/support/purity-rule.d.ts +19 -0
- package/dist/support/purity-rule.d.ts.map +1 -0
- package/dist/support/purity-rule.js +74 -0
- package/dist/support/purity-rule.js.map +1 -0
- package/dist/support/rule/define-rule.d.ts +30 -0
- package/dist/support/rule/define-rule.d.ts.map +1 -0
- package/dist/support/rule/define-rule.js +51 -0
- package/dist/support/rule/define-rule.js.map +1 -0
- package/dist/support/rule/docs-of.d.ts +6 -0
- package/dist/support/rule/docs-of.d.ts.map +1 -0
- package/dist/support/rule/docs-of.js +9 -0
- package/dist/support/rule/docs-of.js.map +1 -0
- package/dist/support/rule/rule-docs.d.ts +9 -0
- package/dist/support/rule/rule-docs.d.ts.map +1 -0
- package/dist/support/rule/rule-docs.js +2 -0
- package/dist/support/rule/rule-docs.js.map +1 -0
- package/dist/support/scheduling/is-job-file.d.ts +4 -0
- package/dist/support/scheduling/is-job-file.d.ts.map +1 -0
- package/dist/support/scheduling/is-job-file.js +11 -0
- package/dist/support/scheduling/is-job-file.js.map +1 -0
- package/dist/support/scheduling/registered-job.d.ts +11 -0
- package/dist/support/scheduling/registered-job.d.ts.map +1 -0
- package/dist/support/scheduling/registered-job.js +17 -0
- package/dist/support/scheduling/registered-job.js.map +1 -0
- package/dist/support/standard-interfaces/boundary-names.d.ts +3 -0
- package/dist/support/standard-interfaces/boundary-names.d.ts.map +1 -0
- package/dist/support/standard-interfaces/boundary-names.js +3 -0
- package/dist/support/standard-interfaces/boundary-names.js.map +1 -0
- package/dist/support/standard-interfaces/parallel-names.d.ts +4 -0
- package/dist/support/standard-interfaces/parallel-names.d.ts.map +1 -0
- package/dist/support/standard-interfaces/parallel-names.js +76 -0
- package/dist/support/standard-interfaces/parallel-names.js.map +1 -0
- package/dist/support/standard-interfaces/standard-names-in.d.ts +3 -0
- package/dist/support/standard-interfaces/standard-names-in.d.ts.map +1 -0
- package/dist/support/standard-interfaces/standard-names-in.js +5 -0
- package/dist/support/standard-interfaces/standard-names-in.js.map +1 -0
- package/dist/support/stepdown/call-graph.d.ts +8 -0
- package/dist/support/stepdown/call-graph.d.ts.map +1 -0
- package/dist/support/stepdown/call-graph.js +27 -0
- package/dist/support/stepdown/call-graph.js.map +1 -0
- package/dist/support/stepdown/member-use.d.ts +7 -0
- package/dist/support/stepdown/member-use.d.ts.map +1 -0
- package/dist/support/stepdown/member-use.js +2 -0
- package/dist/support/stepdown/member-use.js.map +1 -0
- package/dist/support/stepdown/member-uses.d.ts +9 -0
- package/dist/support/stepdown/member-uses.d.ts.map +1 -0
- package/dist/support/stepdown/member-uses.js +27 -0
- package/dist/support/stepdown/member-uses.js.map +1 -0
- package/dist/support/stepdown/misplaced-functions.d.ts +11 -0
- package/dist/support/stepdown/misplaced-functions.d.ts.map +1 -0
- package/dist/support/stepdown/misplaced-functions.js +80 -0
- package/dist/support/stepdown/misplaced-functions.js.map +1 -0
- package/dist/support/stepdown/misplaced-members.d.ts +10 -0
- package/dist/support/stepdown/misplaced-members.d.ts.map +1 -0
- package/dist/support/stepdown/misplaced-members.js +73 -0
- package/dist/support/stepdown/misplaced-members.js.map +1 -0
- package/dist/support/suppressions/shares-line-with-code.d.ts +3 -0
- package/dist/support/suppressions/shares-line-with-code.d.ts.map +1 -0
- package/dist/support/suppressions/shares-line-with-code.js +5 -0
- package/dist/support/suppressions/shares-line-with-code.js.map +1 -0
- package/dist/support/suppressions/suppressed-lines.d.ts +4 -0
- package/dist/support/suppressions/suppressed-lines.d.ts.map +1 -0
- package/dist/support/suppressions/suppressed-lines.js +17 -0
- package/dist/support/suppressions/suppressed-lines.js.map +1 -0
- package/dist/support/types/declared-type-name.d.ts +6 -0
- package/dist/support/types/declared-type-name.d.ts.map +1 -0
- package/dist/support/types/declared-type-name.js +33 -0
- package/dist/support/types/declared-type-name.js.map +1 -0
- package/dist/support/types/parameter-binding.d.ts +4 -0
- package/dist/support/types/parameter-binding.d.ts.map +1 -0
- package/dist/support/types/parameter-binding.js +7 -0
- package/dist/support/types/parameter-binding.js.map +1 -0
- package/dist/support/types/parameter-type-name.d.ts +3 -0
- package/dist/support/types/parameter-type-name.d.ts.map +1 -0
- package/dist/support/types/parameter-type-name.js +6 -0
- package/dist/support/types/parameter-type-name.js.map +1 -0
- package/dist/support/types/type-reference-name.d.ts +4 -0
- package/dist/support/types/type-reference-name.d.ts.map +1 -0
- package/dist/support/types/type-reference-name.js +14 -0
- package/dist/support/types/type-reference-name.js.map +1 -0
- package/dist/support/words/same-word.d.ts +3 -0
- package/dist/support/words/same-word.d.ts.map +1 -0
- package/dist/support/words/same-word.js +75 -0
- package/dist/support/words/same-word.js.map +1 -0
- package/dist/support/words/split-words.d.ts +3 -0
- package/dist/support/words/split-words.d.ts.map +1 -0
- package/dist/support/words/split-words.js +12 -0
- package/dist/support/words/split-words.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/docs/rules/application-command-query-separation.md +54 -0
- package/docs/rules/application-handler-shape.md +52 -0
- package/docs/rules/aspects-outside-in.md +54 -0
- package/docs/rules/authz-actor-explicit.md +70 -0
- package/docs/rules/authz-declared.md +87 -0
- package/docs/rules/authz-in-application.md +88 -0
- package/docs/rules/clean-blank-lines.md +87 -0
- package/docs/rules/clean-braces.md +61 -0
- package/docs/rules/clean-file-size.md +43 -0
- package/docs/rules/clean-formatted.md +32 -0
- package/docs/rules/clean-function-ceiling.md +53 -0
- package/docs/rules/clean-function-size.md +45 -0
- package/docs/rules/clean-no-commented-out-code.md +48 -0
- package/docs/rules/clean-no-escape-hatch.md +80 -0
- package/docs/rules/clean-no-flag-argument.md +50 -0
- package/docs/rules/clean-no-hash-private.md +63 -0
- package/docs/rules/clean-no-noise-comment.md +55 -0
- package/docs/rules/clean-one-export-per-file.md +88 -0
- package/docs/rules/clean-stepdown.md +60 -0
- package/docs/rules/context-declared-relationship.md +49 -0
- package/docs/rules/context-extractable.md +109 -0
- package/docs/rules/context-published-language-is-a-contract.md +47 -0
- package/docs/rules/context-published-language-only.md +47 -0
- package/docs/rules/declarations-role-declared.md +109 -0
- package/docs/rules/domain-aggregate-encapsulation.md +63 -0
- package/docs/rules/domain-events-dispatched-on-save.md +83 -0
- package/docs/rules/domain-events-transactional-before-commit.md +92 -0
- package/docs/rules/domain-no-generic-error.md +40 -0
- package/docs/rules/domain-value-object-immutability.md +52 -0
- package/docs/rules/events-consumer-idempotent.md +68 -0
- package/docs/rules/events-name-format.md +50 -0
- package/docs/rules/events-outbox-required.md +57 -0
- package/docs/rules/governance-recorded-deviation.md +55 -0
- package/docs/rules/imports-alias-only.md +73 -0
- package/docs/rules/layer-application-inward.md +62 -0
- package/docs/rules/layer-domain-purity.md +60 -0
- package/docs/rules/layer-infrastructure-no-presentation.md +46 -0
- package/docs/rules/layer-presentation-no-infrastructure.md +46 -0
- package/docs/rules/ports-abstract-class.md +70 -0
- package/docs/rules/ports-implements-never-extends.md +53 -0
- package/docs/rules/ports-no-concrete-dependency.md +52 -0
- package/docs/rules/ports-no-token-constant.md +57 -0
- package/docs/rules/ports-value-import.md +55 -0
- package/docs/rules/purity-no-ambient-randomness.md +43 -0
- package/docs/rules/purity-no-environment.md +45 -0
- package/docs/rules/purity-no-system-clock.md +49 -0
- package/docs/rules/scheduling-job-name.md +57 -0
- package/docs/rules/scheduling-job-triggers-use-case.md +71 -0
- package/docs/rules/standard-no-parallel-interface.md +95 -0
- package/docs/rules/test-no-mocks.md +47 -0
- package/docs/rules/tracing-platform-only.md +65 -0
- package/package.json +56 -4
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { AST_TOKEN_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { commentLines } from '../support/comments/comment-lines.js';
|
|
3
|
+
import { isDirective } from '../support/comments/is-directive.js';
|
|
4
|
+
import { isJsdoc } from '../support/comments/is-jsdoc.js';
|
|
5
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
6
|
+
import { sameWord } from '../support/words/same-word.js';
|
|
7
|
+
import { splitWords } from '../support/words/split-words.js';
|
|
8
|
+
const BANNER = /^(?:[-=*#~_+/\\]\s?){4,}|^[-=*#~]{2,}.*[-=*#~]{3,}$/;
|
|
9
|
+
const CLOSING = /^(?:end\b|close\b|\/\s*\w+|(?:if|for|while|function|class|switch|try|catch|else|namespace|module|describe|it)\b)/i;
|
|
10
|
+
const JOURNAL = /@(?:author|created|modified|date|changelog)\b|^(?:\d{4}[-/.]\d{1,2}[-/.]\d{1,2}|\d{1,2}[-/.]\d{1,2}[-/.]\d{4})\b|\b(?:added|changed|modified|fixed|created|updated|written)\s+by\s+[A-Z@]/;
|
|
11
|
+
const EMPTY_TAG = /^@(?:param|arg|argument)\s+(?:\{[^}]*\}\s*)?[[\]\w$.=]+\s*-?\s*$|^@(?:returns?|throws)\s*(?:\{[^}]*\})?\s*$/;
|
|
12
|
+
const OWNERLESS_TODO = /\b(?:TODO|FIXME)\b(?!\s*\()/;
|
|
13
|
+
const REFERENCE = /#\d+|\b[A-Z][A-Z0-9]+-\d+\b|https?:\/\//;
|
|
14
|
+
/** Words that add nothing to the name they sit next to. */
|
|
15
|
+
const FILLER = [
|
|
16
|
+
'the',
|
|
17
|
+
'a',
|
|
18
|
+
'an',
|
|
19
|
+
'of',
|
|
20
|
+
'this',
|
|
21
|
+
'that',
|
|
22
|
+
'for',
|
|
23
|
+
'to',
|
|
24
|
+
'is',
|
|
25
|
+
'it',
|
|
26
|
+
'its',
|
|
27
|
+
'new',
|
|
28
|
+
'given',
|
|
29
|
+
'current',
|
|
30
|
+
'class',
|
|
31
|
+
'function',
|
|
32
|
+
'method',
|
|
33
|
+
'property',
|
|
34
|
+
'field',
|
|
35
|
+
'constructor',
|
|
36
|
+
'instance',
|
|
37
|
+
'object',
|
|
38
|
+
'value',
|
|
39
|
+
'get',
|
|
40
|
+
'set',
|
|
41
|
+
'return',
|
|
42
|
+
'create',
|
|
43
|
+
'represent',
|
|
44
|
+
'define',
|
|
45
|
+
'implementation',
|
|
46
|
+
'interface',
|
|
47
|
+
'type',
|
|
48
|
+
];
|
|
49
|
+
const MODIFIERS = new Set([
|
|
50
|
+
'export',
|
|
51
|
+
'default',
|
|
52
|
+
'public',
|
|
53
|
+
'private',
|
|
54
|
+
'protected',
|
|
55
|
+
'static',
|
|
56
|
+
'readonly',
|
|
57
|
+
'abstract',
|
|
58
|
+
'async',
|
|
59
|
+
'override',
|
|
60
|
+
'declare',
|
|
61
|
+
'get',
|
|
62
|
+
'set',
|
|
63
|
+
'const',
|
|
64
|
+
'let',
|
|
65
|
+
'var',
|
|
66
|
+
'function',
|
|
67
|
+
'class',
|
|
68
|
+
'interface',
|
|
69
|
+
'type',
|
|
70
|
+
'enum',
|
|
71
|
+
'*',
|
|
72
|
+
]);
|
|
73
|
+
const NAME_TOKENS = new Set([AST_TOKEN_TYPES.Identifier, AST_TOKEN_TYPES.PrivateIdentifier]);
|
|
74
|
+
const INSTEAD = 'Delete it, or replace it by what the name cannot say: why, a constraint, a consequence.';
|
|
75
|
+
export const cleanNoNoiseComment = defineRule({
|
|
76
|
+
id: 'clean/no-noise-comment',
|
|
77
|
+
type: 'suggestion',
|
|
78
|
+
recommended: 'warn',
|
|
79
|
+
description: 'No comment that restates the code, no banner, no journal, no closing-brace comment, no @param without description.',
|
|
80
|
+
messages: {
|
|
81
|
+
banner: 'The comment is a banner: "{{excerpt}}". Delete it; if the file needs sections, it holds several concepts that deserve their own files.',
|
|
82
|
+
closingBrace: 'The comment labels a closing brace: "{{excerpt}}". Delete it and shorten the block: a brace that needs a label closes a function that is too long.',
|
|
83
|
+
journal: 'The comment keeps a journal or an author: "{{excerpt}}". Delete it: version control records who changed what and when.',
|
|
84
|
+
emptyTag: 'The comment is a tag without a description: "{{excerpt}}". Describe what the type cannot say (unit, range, meaning of an absent value) or delete the tag.',
|
|
85
|
+
ownerlessTodo: 'The comment is a TODO without an owner or a reference: "{{excerpt}}". Write it as TODO(<owner or ticket>): ..., or do it now, or delete it.',
|
|
86
|
+
restatesName: `The comment only repeats the name {{name}}: "{{excerpt}}". ${INSTEAD}`,
|
|
87
|
+
},
|
|
88
|
+
create({ sourceCode, report }) {
|
|
89
|
+
return {
|
|
90
|
+
Program() {
|
|
91
|
+
const lines = commentLines(sourceCode).filter((line) => !line.sample && line.text !== '' && !isDirective(line.text));
|
|
92
|
+
for (const line of lines) {
|
|
93
|
+
const noise = noiseOf(line, sourceCode);
|
|
94
|
+
if (noise !== undefined) {
|
|
95
|
+
report({ loc: line.loc, messageId: noise, data: { excerpt: line.text.slice(0, 60) } });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
for (const description of descriptions(lines)) {
|
|
99
|
+
const name = declaredAfter(sourceCode, description.last);
|
|
100
|
+
if (name === undefined || !restatesName(description.text, name)) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
report({
|
|
104
|
+
loc: description.first.loc,
|
|
105
|
+
messageId: 'restatesName',
|
|
106
|
+
data: { name, excerpt: description.text.slice(0, 60) },
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
function noiseOf(line, sourceCode) {
|
|
114
|
+
const { text } = line;
|
|
115
|
+
if (BANNER.test(text)) {
|
|
116
|
+
return 'banner';
|
|
117
|
+
}
|
|
118
|
+
if (labelsClosingBrace(line, sourceCode)) {
|
|
119
|
+
return 'closingBrace';
|
|
120
|
+
}
|
|
121
|
+
if (JOURNAL.test(text)) {
|
|
122
|
+
return 'journal';
|
|
123
|
+
}
|
|
124
|
+
if (line.block && EMPTY_TAG.test(text)) {
|
|
125
|
+
return 'emptyTag';
|
|
126
|
+
}
|
|
127
|
+
return OWNERLESS_TODO.test(text) && !REFERENCE.test(text) ? 'ownerlessTodo' : undefined;
|
|
128
|
+
}
|
|
129
|
+
function labelsClosingBrace(line, sourceCode) {
|
|
130
|
+
if (!line.trailing || !CLOSING.test(line.text) || line.text.split(' ').length > 3) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return sourceCode.getTokenBefore(line.comment)?.value === '}';
|
|
134
|
+
}
|
|
135
|
+
/** What is said just above a declaration: a JSDoc block without its tags, or a run of `//` lines. */
|
|
136
|
+
function descriptions(lines) {
|
|
137
|
+
const found = [];
|
|
138
|
+
let run = [];
|
|
139
|
+
const close = () => {
|
|
140
|
+
const [first] = run;
|
|
141
|
+
const last = run.at(-1);
|
|
142
|
+
if (first !== undefined && last !== undefined) {
|
|
143
|
+
found.push({ text: run.map((line) => line.text).join(' '), first, last: last.comment });
|
|
144
|
+
}
|
|
145
|
+
run = [];
|
|
146
|
+
};
|
|
147
|
+
for (const line of lines.filter((candidate) => !candidate.trailing && (!candidate.block || (isJsdoc(candidate.comment) && !candidate.text.startsWith('@'))))) {
|
|
148
|
+
const previous = run.at(-1);
|
|
149
|
+
if (previous !== undefined && !belongsTogether(previous, line)) {
|
|
150
|
+
close();
|
|
151
|
+
}
|
|
152
|
+
run.push(line);
|
|
153
|
+
}
|
|
154
|
+
close();
|
|
155
|
+
return found;
|
|
156
|
+
}
|
|
157
|
+
function belongsTogether(previous, line) {
|
|
158
|
+
if (previous.block || line.block) {
|
|
159
|
+
return previous.comment === line.comment;
|
|
160
|
+
}
|
|
161
|
+
return line.loc.start.line === previous.loc.start.line + 1;
|
|
162
|
+
}
|
|
163
|
+
/** The name declared on the line that follows the comment, read from its tokens. */
|
|
164
|
+
function declaredAfter(sourceCode, comment) {
|
|
165
|
+
const tokens = sourceCode.getTokensAfter(comment, { count: 8 });
|
|
166
|
+
const [first] = tokens;
|
|
167
|
+
if (first === undefined || first.loc.start.line > comment.loc.end.line + 1) {
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
const named = tokens.findIndex((token) => !MODIFIERS.has(token.value));
|
|
171
|
+
// `get()` and `static()` are methods named like a modifier: the name is the word before the parenthesis.
|
|
172
|
+
const name = tokens[named]?.value === '(' ? tokens[named - 1] : tokens[named];
|
|
173
|
+
if (name === undefined || (!NAME_TOKENS.has(name.type) && !MODIFIERS.has(name.value))) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
return name.type === AST_TOKEN_TYPES.PrivateIdentifier ? `#${name.value}` : name.value;
|
|
177
|
+
}
|
|
178
|
+
/** True when the description says nothing the name does not already say. */
|
|
179
|
+
function restatesName(description, name) {
|
|
180
|
+
const said = splitWords(description.replace(/[.`'"]/g, ' '));
|
|
181
|
+
if (said.length === 0 || said.length > 8) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
const named = splitWords(name);
|
|
185
|
+
return said.every((word) => [...FILLER, ...named].some((known) => sameWord(known, word)));
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=clean-no-noise-comment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-no-noise-comment.js","sourceRoot":"","sources":["../../src/rules/clean-no-noise-comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgC,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,YAAY,EAAoB,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAA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AK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE9E,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACtF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;AACzF,CAAC;AAED,4EAA4E;AAC5E,SAAS,YAAY,CAAC,WAAmB,EAAE,IAAY;IACrD,MAAM,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;IAE7D,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAE/B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AllowedFile } from '../project/config.js';
|
|
2
|
+
interface Options {
|
|
3
|
+
/** Files whose several exports are one thing, each with the sentence that says why; added to `onePerFile.allow` of the config. */
|
|
4
|
+
readonly allow?: readonly AllowedFile[];
|
|
5
|
+
/** Globs of the entry files besides every `index.ts`: the subpath entries of a package. */
|
|
6
|
+
readonly entries?: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export declare const cleanOneExportPerFile: import("@typescript-eslint/utils/ts-eslint").RuleModule<"entry" | "fileName" | "several", [Options], import("../index.js").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=clean-one-export-per-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-one-export-per-file.d.ts","sourceRoot":"","sources":["../../src/rules/clean-one-export-per-file.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAWxD,UAAU,OAAO;IACf,kIAAkI;IAClI,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAKD,eAAO,MAAM,qBAAqB,iMAqEhC,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
3
|
+
import { parseAllowedFile } from '../project/parse-allowed-file.js';
|
|
4
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
5
|
+
import { explainExports } from '../support/exports/explain-exports.js';
|
|
6
|
+
import { isNamedAfter } from '../support/exports/is-named-after.js';
|
|
7
|
+
import { moduleShapeOf } from '../support/exports/module-shape-of.js';
|
|
8
|
+
import { globMatcher } from '../support/glob-matcher.js';
|
|
9
|
+
import { kebabCase } from '../support/kebab-case.js';
|
|
10
|
+
const SOURCE = /\.(?:ts|mts|cts)$/;
|
|
11
|
+
const TEST = /\.(?:spec|test)\.[cm]?ts$/;
|
|
12
|
+
export const cleanOneExportPerFile = defineRule({
|
|
13
|
+
id: 'clean/one-export-per-file',
|
|
14
|
+
type: 'suggestion',
|
|
15
|
+
recommended: 'error',
|
|
16
|
+
description: 'A source file exports one class, interface or function, with the types of its own signature, and is named after it; an entry file only re-exports.',
|
|
17
|
+
messages: {
|
|
18
|
+
several: 'This file exports {{count}} classes, interfaces or functions ({{names}}) that are not one thing. Keep one per file, named after it in kebab-case, with the types of its own signature; move each other one to its own file. Exports that really are one thing (a closed family) are declared in `onePerFile.allow` of ddd-ts-kit.config.json with the reason.',
|
|
19
|
+
fileName: 'This file exports {{exported}} but is named {{file}}. Name it {{expected}}: a file is named after its export in kebab-case (in a role file `<name>.<role>.ts`, after the name before the role).',
|
|
20
|
+
entry: 'An entry file only re-exports: this statement declares or exports something of its own. Move it to a file named after what it declares and write `export { .. } from` here.',
|
|
21
|
+
},
|
|
22
|
+
schema: [
|
|
23
|
+
{
|
|
24
|
+
type: 'object',
|
|
25
|
+
additionalProperties: false,
|
|
26
|
+
properties: {
|
|
27
|
+
allow: {
|
|
28
|
+
type: 'array',
|
|
29
|
+
items: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
additionalProperties: false,
|
|
32
|
+
required: ['file', 'reason'],
|
|
33
|
+
properties: { file: { type: 'string' }, reason: { type: 'string' } },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
entries: { type: 'array', items: { type: 'string' }, uniqueItems: true },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
defaultOptions: [{}],
|
|
41
|
+
create({ file, sourceCode, options: [options], report }) {
|
|
42
|
+
if (!isJudged(file)) {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
const isEntry = isEntryFile(file, options);
|
|
46
|
+
const allowed = isAllowed(file, options);
|
|
47
|
+
const judgeEntry = (program) => {
|
|
48
|
+
for (const statement of program.body.filter((candidate) => !isReExport(candidate))) {
|
|
49
|
+
report({ node: statement, messageId: 'entry' });
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const judgeSource = (program) => {
|
|
53
|
+
const shape = moduleShapeOf(program);
|
|
54
|
+
const explanation = explainExports(shape, sourceCode);
|
|
55
|
+
const finding = explanation !== undefined || allowed ? misnamed(file, explanation?.mains ?? shape.counted) : undefined;
|
|
56
|
+
if (explanation === undefined && !allowed) {
|
|
57
|
+
report({
|
|
58
|
+
node: nodeOf(shape, shape.counted[1]),
|
|
59
|
+
messageId: 'several',
|
|
60
|
+
data: { count: shape.counted.length, names: shape.counted.join(', ') },
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (finding !== undefined) {
|
|
64
|
+
report({ node: nodeOf(shape, finding.main), messageId: 'fileName', data: finding.data });
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
return { Program: isEntry ? judgeEntry : judgeSource };
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
function isEntryFile(file, options) {
|
|
71
|
+
return (isIndex(file) ||
|
|
72
|
+
globMatcher([`${file.config.contextsDir}/*/*.declarations.ts`, ...(options.entries ?? [])])(file.path));
|
|
73
|
+
}
|
|
74
|
+
function isIndex(file) {
|
|
75
|
+
return /^index\.[cm]?ts$/.test(path.posix.basename(file.path));
|
|
76
|
+
}
|
|
77
|
+
function isAllowed(file, options) {
|
|
78
|
+
return globMatcher([...file.config.onePerFile.allow, ...(options.allow ?? []).flatMap(parseAllowedFile)].map((entry) => entry.file))(file.path);
|
|
79
|
+
}
|
|
80
|
+
/** The file carries the name of none of the exports it may be named after. A family that no export names is named freely. */
|
|
81
|
+
function misnamed(file, mains) {
|
|
82
|
+
const base = path.posix.basename(file.path);
|
|
83
|
+
const stem = base.replace(SOURCE, '');
|
|
84
|
+
const [main] = mains === 'free' ? [] : mains;
|
|
85
|
+
if (mains === 'free' || main === undefined || main === 'default' || mains.some((name) => isNamedAfter(stem, name))) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
return { main, data: { exported: mains.join(' or '), file: base, expected: `${expectedStem(stem, main)}.ts` } };
|
|
89
|
+
}
|
|
90
|
+
/** A source under the source root; in a workspace, under the directory of that name of a package. Never a test, never a declaration file. */
|
|
91
|
+
function isJudged(file) {
|
|
92
|
+
const segments = file.path.split('/');
|
|
93
|
+
const sourceDirectory = file.config.sourceRoot.split('/').at(-1) ?? 'src';
|
|
94
|
+
if (!SOURCE.test(file.path) ||
|
|
95
|
+
/\.d\.[cm]?ts$/.test(file.path) ||
|
|
96
|
+
file.isTest ||
|
|
97
|
+
TEST.test(file.path) ||
|
|
98
|
+
segments.includes('test')) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return file.path.startsWith(`${file.config.sourceRoot}/`) || segments.slice(0, -1).includes(sourceDirectory);
|
|
102
|
+
}
|
|
103
|
+
/** `export .. from`, `export * from`, and what declares nothing: an import for its effect, the empty `export {}` of a module without export yet. */
|
|
104
|
+
function isReExport(statement) {
|
|
105
|
+
if (statement.type === AST_NODE_TYPES.ImportDeclaration) {
|
|
106
|
+
return statement.specifiers.length === 0;
|
|
107
|
+
}
|
|
108
|
+
if (statement.type !== AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
109
|
+
return statement.type === AST_NODE_TYPES.ExportAllDeclaration;
|
|
110
|
+
}
|
|
111
|
+
return statement.source !== null || (statement.declaration === null && statement.specifiers.length === 0);
|
|
112
|
+
}
|
|
113
|
+
function nodeOf(shape, name) {
|
|
114
|
+
const declared = shape.exports.find((declaration) => declaration.name === name)?.node ?? shape.program;
|
|
115
|
+
return 'id' in declared && declared.id !== null ? declared.id : declared;
|
|
116
|
+
}
|
|
117
|
+
/** The name to give the file: the role suffix of a role file is kept. */
|
|
118
|
+
function expectedStem(stem, main) {
|
|
119
|
+
const [, ...roles] = stem.split('.');
|
|
120
|
+
const role = roles.at(-1);
|
|
121
|
+
const name = kebabCase(main);
|
|
122
|
+
return role !== undefined && !name.endsWith(`-${role}`) ? `${name}.${role}` : name;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=clean-one-export-per-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-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,QAAQ,IAAI,QAAQ,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC3E,CAAC;AAED,yEAAyE;AACzE,SAAS,YAAY,CAAC,IAAY,EAAE,IAAY;IAC9C,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAE7B,OAAO,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ClassMessageId } from '../support/stepdown/misplaced-members.js';
|
|
2
|
+
export declare const cleanStepdown: import("@typescript-eslint/utils/ts-eslint").RuleModule<"functionAboveCaller" | ClassMessageId, [], import("../index.js").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
3
|
+
//# sourceMappingURL=clean-stepdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-stepdown.d.ts","sourceRoot":"","sources":["../../src/rules/clean-stepdown.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAGjG,eAAO,MAAM,aAAa,gMAiCxB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
2
|
+
import { MemberUses } from '../support/stepdown/member-uses.js';
|
|
3
|
+
import { misplacedMembers } from '../support/stepdown/misplaced-members.js';
|
|
4
|
+
import { misplacedFunctions } from '../support/stepdown/misplaced-functions.js';
|
|
5
|
+
export const cleanStepdown = defineRule({
|
|
6
|
+
id: 'clean/stepdown',
|
|
7
|
+
type: 'suggestion',
|
|
8
|
+
recommended: 'error',
|
|
9
|
+
description: 'A file reads top to bottom: static factories, public members, then private ones, and a function above the functions it calls.',
|
|
10
|
+
messages: {
|
|
11
|
+
nonPublicBeforePublic: 'The {{visibility}} member {{name}} of {{className}} is declared before the public member {{publicName}}. Move {{name}} below the public members, after its first caller: a reader meets what the class does before how.',
|
|
12
|
+
staticAfterInstance: 'The static method {{name}} of {{className}} is declared after the instance method {{instanceName}}. Move the static factories to the top of the class, above the instance methods.',
|
|
13
|
+
memberAboveCaller: 'The private member {{name}} of {{className}} is declared above its first caller (line {{line}}). Move {{name}} just below the member that first calls it.',
|
|
14
|
+
functionAboveCaller: 'The function {{name}} is declared above its first caller (line {{line}}). Move {{name}} below the function that first calls it, so that the file reads from intention to detail.',
|
|
15
|
+
},
|
|
16
|
+
create({ sourceCode, report }) {
|
|
17
|
+
const uses = new MemberUses();
|
|
18
|
+
return {
|
|
19
|
+
MemberExpression: (node) => uses.record(node),
|
|
20
|
+
'ClassBody:exit'(node) {
|
|
21
|
+
for (const finding of misplacedMembers(node, uses.of(node))) {
|
|
22
|
+
report(finding);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
'Program:exit'(node) {
|
|
26
|
+
for (const finding of misplacedFunctions(node, sourceCode)) {
|
|
27
|
+
report({ ...finding, messageId: 'functionAboveCaller' });
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=clean-stepdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-stepdown.js","sourceRoot":"","sources":["../../src/rules/clean-stepdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAuB,MAAM,0CAA0C,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAEhF,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAyC;IAC9E,EAAE,EAAE,gBAAgB;IACpB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,OAAO;IACpB,WAAW,EACT,+HAA+H;IACjI,QAAQ,EAAE;QACR,qBAAqB,EACnB,yNAAyN;QAC3N,mBAAmB,EACjB,oLAAoL;QACtL,iBAAiB,EACf,2JAA2J;QAC7J,mBAAmB,EACjB,kLAAkL;KACrL;IACD,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE;QAC3B,MAAM,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC;QAE9B,OAAO;YACL,gBAAgB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAC7C,gBAAgB,CAAC,IAAI;gBACnB,KAAK,MAAM,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;oBAC5D,MAAM,CAAC,OAAO,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;YACD,cAAc,CAAC,IAAI;gBACjB,KAAK,MAAM,OAAO,IAAI,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC;oBAC3D,MAAM,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const contextPublishedLanguageOnly: import("@typescript-eslint/utils/ts-eslint").RuleModule<"internals", [], import("../index.js").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
2
|
+
export declare const contextDeclaredRelationship: import("@typescript-eslint/utils/ts-eslint").RuleModule<"undeclared", [], import("../index.js").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
3
|
+
export declare const contextPublishedLanguageIsAContract: import("@typescript-eslint/utils/ts-eslint").RuleModule<"leak", [], import("../index.js").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
4
|
+
//# sourceMappingURL=context-boundaries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-boundaries.d.ts","sourceRoot":"","sources":["../../src/rules/context-boundaries.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,4BAA4B,qKAkCvC,CAAC;AAEH,eAAO,MAAM,2BAA2B,sKAiCtC,CAAC;AAEH,eAAO,MAAM,mCAAmC,gKAgC9C,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
2
|
+
import { describeTarget } from '../support/imports/describe-target.js';
|
|
3
|
+
import { importListener } from '../support/imports/import-listener.js';
|
|
4
|
+
import { inContext } from '../support/imports/in-context.js';
|
|
5
|
+
import { inLayer } from '../support/imports/in-layer.js';
|
|
6
|
+
export const contextPublishedLanguageOnly = defineRule({
|
|
7
|
+
id: 'context/published-language-only',
|
|
8
|
+
type: 'problem',
|
|
9
|
+
recommended: 'error',
|
|
10
|
+
description: "A file imports from another context only through that context's published-language/.",
|
|
11
|
+
messages: {
|
|
12
|
+
internals: '"{{here}}" imports the internals of "{{there}}" ({{path}}). Import from {{contextsDir}}/{{there}}/published-language only; if the type is missing there, publish it with `ddd-ts-kit generate integration-event {{there}} <Aggregate> <Fact>` or react to an integration event.',
|
|
13
|
+
},
|
|
14
|
+
create({ file, report }) {
|
|
15
|
+
const here = inContext(file);
|
|
16
|
+
if (here === undefined) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
return importListener(file, ({ node, target }) => {
|
|
20
|
+
if (target.kind !== 'file' || target.location.area !== 'context') {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const there = target.location;
|
|
24
|
+
if (there.context === here.context || there.layer === 'published-language') {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
report({
|
|
28
|
+
node,
|
|
29
|
+
messageId: 'internals',
|
|
30
|
+
data: { here: here.context, there: there.context, path: target.path, contextsDir: file.config.contextsDir },
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export const contextDeclaredRelationship = defineRule({
|
|
36
|
+
id: 'context/declared-relationship',
|
|
37
|
+
type: 'problem',
|
|
38
|
+
recommended: 'error',
|
|
39
|
+
description: 'Importing the published language of another context requires the relationship to be declared in the config.',
|
|
40
|
+
messages: {
|
|
41
|
+
undeclared: '"{{here}}" depends on "{{there}}" but the relationship is not declared. Add { "context": "{{there}}", "relationship": "published-language" } to contexts.{{here}}.upstreams in ddd-ts-kit.config.json, after checking that the dependency direction is intended.',
|
|
42
|
+
},
|
|
43
|
+
create({ file, report }) {
|
|
44
|
+
const here = inContext(file);
|
|
45
|
+
if (here === undefined) {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
const upstreams = file.config.contexts[here.context]?.upstreams.map((upstream) => upstream.context) ?? [];
|
|
49
|
+
return importListener(file, ({ node, target }) => {
|
|
50
|
+
if (target.kind !== 'file' || target.location.area !== 'context') {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const there = target.location;
|
|
54
|
+
if (there.context === here.context || there.layer !== 'published-language' || upstreams.includes(there.context)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
report({ node, messageId: 'undeclared', data: { here: here.context, there: there.context } });
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
export const contextPublishedLanguageIsAContract = defineRule({
|
|
62
|
+
id: 'context/published-language-is-a-contract',
|
|
63
|
+
type: 'problem',
|
|
64
|
+
recommended: 'error',
|
|
65
|
+
description: 'published-language/ imports only the kernel, the event declaration helper with the schema library of the project, and other published languages.',
|
|
66
|
+
messages: {
|
|
67
|
+
leak: 'The published language imports {{target}}. Declare the contract with plain serializable types written in this folder: copy the few fields other contexts need instead of exposing an internal model.',
|
|
68
|
+
},
|
|
69
|
+
create({ file, report }) {
|
|
70
|
+
if (inLayer(file, 'published-language') === undefined) {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
const allowed = file.config.publishedLanguageAllowedPackages;
|
|
74
|
+
return importListener(file, ({ node, target }) => {
|
|
75
|
+
if (target.kind === 'package' && allowed.includes(target.name)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (target.kind === 'file' &&
|
|
79
|
+
target.location.area === 'context' &&
|
|
80
|
+
target.location.layer === 'published-language') {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
report({ node, messageId: 'leak', data: { target: describeTarget(target) } });
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=context-boundaries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-boundaries.js","sourceRoot":"","sources":["../../src/rules/context-boundaries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD,MAAM,CAAC,MAAM,4BAA4B,GAAG,UAAU,CAAc;IAClE,EAAE,EAAE,iCAAiC;IACrC,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,sFAAsF;IACnG,QAAQ,EAAE;Q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CAAC;YACtD,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,gCAAgC,CAAC;QAE7D,OAAO,cAAc,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;YAC/C,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/D,OAAO;YACT,CAAC;YAED,IACE,MAAM,CAAC,IAAI,KAAK,MAAM;gBACtB,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS;gBAClC,MAAM,CAAC,QAAQ,CAAC,KAAK,KAAK,oBAAoB,EAC9C,CAAC;gBACD,OAAO;YACT,CAAC;YAED,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;QAChF,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
type MessageId = 'foreignSchema' | 'foreignTable' | 'mutableBinding' | 'mutableState' | 'foreignWiring' | 'foreignPort';
|
|
3
|
+
export declare const contextExtractable: TSESLint.RuleModule<MessageId, [], import("../index.js").RuleDocs, TSESLint.RuleListener>;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=context-extractable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-extractable.d.ts","sourceRoot":"","sources":["../../src/rules/context-extractable.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,QAAQ,EAAiB,MAAM,0BAA0B,CAAC;AAa7F,KAAK,SAAS,GAAG,eAAe,GAAG,cAAc,GAAG,gBAAgB,GAAG,cAAc,GAAG,eAAe,GAAG,aAAa,CAAC;AAiDxH,eAAO,MAAM,kBAAkB,2FA8B7B,CAAC"}
|