@ddd-ts-kit/eslint-plugin 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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,242 @@
|
|
|
1
|
+
import { ASTUtils, AST_NODE_TYPES, TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
import { resolveImport } from '../project/resolve-import.js';
|
|
3
|
+
import { calleeName } from '../support/calls/callee-name.js';
|
|
4
|
+
import { declaredRoleOf } from '../support/declarations/declared-role-of.js';
|
|
5
|
+
import { isDeclaredStyle } from '../support/declarations/is-declared-style.js';
|
|
6
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
7
|
+
import { propertyName } from '../support/globals/property-name.js';
|
|
8
|
+
import { inContext } from '../support/imports/in-context.js';
|
|
9
|
+
import { staticString } from '../support/imports/static-string.js';
|
|
10
|
+
import { isPortFile } from '../support/ports/is-port-file.js';
|
|
11
|
+
const SCHEMA_HELPERS = new Set(['contextSchema', 'schemaNameOf']);
|
|
12
|
+
const KEBAB = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
13
|
+
const SQL = /\b(?:select|insert|update|delete|from|join|into|references)\b/i;
|
|
14
|
+
const IMPORTS = new Set([
|
|
15
|
+
AST_NODE_TYPES.ImportDeclaration,
|
|
16
|
+
AST_NODE_TYPES.ExportNamedDeclaration,
|
|
17
|
+
AST_NODE_TYPES.ExportAllDeclaration,
|
|
18
|
+
AST_NODE_TYPES.ImportExpression,
|
|
19
|
+
]);
|
|
20
|
+
const CONTAINERS = new Set(['Map', 'Set', 'WeakMap', 'WeakSet', 'Array']);
|
|
21
|
+
const MUTATORS = new Set([
|
|
22
|
+
'set',
|
|
23
|
+
'add',
|
|
24
|
+
'delete',
|
|
25
|
+
'clear',
|
|
26
|
+
'push',
|
|
27
|
+
'pop',
|
|
28
|
+
'shift',
|
|
29
|
+
'unshift',
|
|
30
|
+
'splice',
|
|
31
|
+
'sort',
|
|
32
|
+
'reverse',
|
|
33
|
+
'fill',
|
|
34
|
+
'copyWithin',
|
|
35
|
+
]);
|
|
36
|
+
const WIRING = new Set(['bind', 'rebind', 'resolve', 'handledBy', 'toClass']);
|
|
37
|
+
const BY_CONTRACT = 'Read what "{{there}}" publishes: keep a projection of your own fed by its integration events, or declare a port in application/ports whose adapter calls it and could be remote tomorrow.';
|
|
38
|
+
export const contextExtractable = defineRule({
|
|
39
|
+
id: 'context/extractable',
|
|
40
|
+
type: 'problem',
|
|
41
|
+
recommended: 'error',
|
|
42
|
+
description: 'A context can run alone: it reads no table of another context, exports no shared mutable state and wires no port or adapter that belongs to another context.',
|
|
43
|
+
messages: {
|
|
44
|
+
foreignSchema: `"{{here}}" opens the database schema of "{{there}}": the two contexts could no longer be deployed apart. ${BY_CONTRACT}`,
|
|
45
|
+
foreignTable: `This statement of "{{here}}" names a table of the schema of "{{there}}": a join or a foreign key across contexts cannot survive an extraction. ${BY_CONTRACT}`,
|
|
46
|
+
mutableBinding: '{{name}} is exported with `{{kind}}`: every importer shares one variable that any of them may see change. Export a `const`, and keep state that changes in an adapter bound in {{here}}.module.ts or declared with `@Adapter`.',
|
|
47
|
+
mutableState: '{{name}} is exported and changed in this file: it is state shared by every importer, lost on restart and invisible to a second instance. Hold it in a class bound in {{here}}.module.ts or declared by its decorator (a repository, a cache behind a port) and export nothing mutable.',
|
|
48
|
+
foreignWiring: `The module of "{{here}}" wires {{name}}, which belongs to "{{there}}": the context could not start without the other. Bind a port of "{{here}}" to an adapter of its own, or receive the capability from the platform. ${BY_CONTRACT}`,
|
|
49
|
+
foreignPort: 'This role file of "{{here}}" imports {{name}} from a port file of "{{there}}": a declaration that names a port of another context cannot be wired alone, so "{{here}}" could no longer be extracted. Declare a port of "{{here}}" as an abstract class in application/ports/<need>.port.ts and implement it with a `@Gateway` of "{{here}}" that calls "{{there}}", or receive the capability from the platform.',
|
|
50
|
+
},
|
|
51
|
+
create({ file, sourceCode, report }) {
|
|
52
|
+
const here = inContext(file);
|
|
53
|
+
if (here === undefined || file.isTest) {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
...sharedState(here, sourceCode, report),
|
|
58
|
+
...boundaries(file, here, report),
|
|
59
|
+
...foreignPorts(file, here, report),
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
function sharedState(here, sourceCode, tell) {
|
|
64
|
+
return {
|
|
65
|
+
ExportNamedDeclaration(node) {
|
|
66
|
+
if (node.source !== null) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
for (const { declarator, kind } of exportedVariables(node, sourceCode)) {
|
|
70
|
+
const name = sourceCode.getText(declarator.id);
|
|
71
|
+
if (kind === 'let' || kind === 'var') {
|
|
72
|
+
tell({ node: declarator.id, messageId: 'mutableBinding', data: { name, kind, here: here.context } });
|
|
73
|
+
}
|
|
74
|
+
else if (isContainer(declarator.init) && isMutated(declarator, sourceCode)) {
|
|
75
|
+
tell({ node: declarator.id, messageId: 'mutableState', data: { name, here: here.context } });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** `export const a = ...` and `export { a }` of a variable declared above. */
|
|
82
|
+
function exportedVariables(node, sourceCode) {
|
|
83
|
+
const { declaration } = node;
|
|
84
|
+
if (declaration?.type === AST_NODE_TYPES.VariableDeclaration) {
|
|
85
|
+
return declaration.declarations.map((declarator) => ({ declarator, kind: declaration.kind }));
|
|
86
|
+
}
|
|
87
|
+
return node.specifiers.flatMap((specifier) => {
|
|
88
|
+
const definition = ASTUtils.findVariable(sourceCode.getScope(node), specifier.local.type === AST_NODE_TYPES.Identifier ? specifier.local.name : '')?.defs[0];
|
|
89
|
+
return definition?.type === TSESLint.Scope.DefinitionType.Variable
|
|
90
|
+
? [{ declarator: definition.node, kind: definition.parent.kind }]
|
|
91
|
+
: [];
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function isContainer(init) {
|
|
95
|
+
if (init === null) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (init.type === AST_NODE_TYPES.ArrayExpression || init.type === AST_NODE_TYPES.ObjectExpression) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
return init.type === AST_NODE_TYPES.NewExpression && CONTAINERS.has(calleeName(init) ?? '');
|
|
102
|
+
}
|
|
103
|
+
function isMutated(declarator, sourceCode) {
|
|
104
|
+
return sourceCode
|
|
105
|
+
.getDeclaredVariables(declarator)
|
|
106
|
+
.some((variable) => variable.references.some((reference) => mutates(reference.identifier)));
|
|
107
|
+
}
|
|
108
|
+
function mutates(identifier) {
|
|
109
|
+
const { parent } = identifier;
|
|
110
|
+
if (parent?.type === AST_NODE_TYPES.CallExpression) {
|
|
111
|
+
return parent.arguments[0] === identifier && isObjectAssign(parent.callee);
|
|
112
|
+
}
|
|
113
|
+
return parent?.type === AST_NODE_TYPES.MemberExpression && parent.object === identifier && changesItsObject(parent);
|
|
114
|
+
}
|
|
115
|
+
/** `x.push(1)`, `x.key = 1`, `x.count++`, `delete x.key`. */
|
|
116
|
+
function changesItsObject(member) {
|
|
117
|
+
const use = member.parent;
|
|
118
|
+
if (use.type === AST_NODE_TYPES.CallExpression) {
|
|
119
|
+
return use.callee === member && MUTATORS.has(propertyName(member) ?? '');
|
|
120
|
+
}
|
|
121
|
+
if (use.type === AST_NODE_TYPES.AssignmentExpression) {
|
|
122
|
+
return use.left === member;
|
|
123
|
+
}
|
|
124
|
+
return (use.type === AST_NODE_TYPES.UpdateExpression ||
|
|
125
|
+
(use.type === AST_NODE_TYPES.UnaryExpression && use.operator === 'delete'));
|
|
126
|
+
}
|
|
127
|
+
function isObjectAssign(callee) {
|
|
128
|
+
return (callee.type === AST_NODE_TYPES.MemberExpression &&
|
|
129
|
+
callee.object.type === AST_NODE_TYPES.Identifier &&
|
|
130
|
+
callee.object.name === 'Object' &&
|
|
131
|
+
propertyName(callee) === 'assign');
|
|
132
|
+
}
|
|
133
|
+
function boundaries(file, here, tell) {
|
|
134
|
+
if (here.layer === 'module') {
|
|
135
|
+
return foreignWiring(file, here, tell);
|
|
136
|
+
}
|
|
137
|
+
return here.layer === 'infrastructure' && here.inside[0] === 'persistence' ? foreignData(file, here, tell) : {};
|
|
138
|
+
}
|
|
139
|
+
function foreignData(file, here, tell) {
|
|
140
|
+
const others = Object.keys(file.config.contexts).filter((context) => context !== here.context && KEBAB.test(context));
|
|
141
|
+
const schemas = others.map((context) => ({
|
|
142
|
+
context,
|
|
143
|
+
qualifier: new RegExp(`(?<![\\w.])"?${context.replaceAll('-', '_')}"?\\.`),
|
|
144
|
+
}));
|
|
145
|
+
const statement = (node, text) => {
|
|
146
|
+
const there = foreignSchemaIn(text, schemas);
|
|
147
|
+
if (there !== undefined) {
|
|
148
|
+
tell({ node, messageId: 'foreignTable', data: { here: here.context, there } });
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
CallExpression(node) {
|
|
153
|
+
const [name] = node.arguments;
|
|
154
|
+
const there = SCHEMA_HELPERS.has(calleeName(node) ?? '') && name !== undefined ? staticString(name) : undefined;
|
|
155
|
+
if (there !== undefined && others.includes(there)) {
|
|
156
|
+
tell({ node, messageId: 'foreignSchema', data: { here: here.context, there } });
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
TemplateLiteral: (node) => statement(node, node.quasis.map((quasi) => quasi.value.cooked ?? '').join('?')),
|
|
160
|
+
Literal(node) {
|
|
161
|
+
if (typeof node.value === 'string' && !IMPORTS.has(node.parent.type)) {
|
|
162
|
+
statement(node, node.value);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function foreignSchemaIn(text, schemas) {
|
|
168
|
+
return SQL.test(text) ? schemas.find((schema) => schema.qualifier.test(text))?.context : undefined;
|
|
169
|
+
}
|
|
170
|
+
function foreignWiring(file, here, tell) {
|
|
171
|
+
const foreign = new Map();
|
|
172
|
+
return {
|
|
173
|
+
ImportDeclaration(node) {
|
|
174
|
+
const target = resolveImport(file.config, file.path, node.source.value);
|
|
175
|
+
if (target.kind !== 'file' || target.location.area !== 'context') {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const there = target.location;
|
|
179
|
+
if (there.context === here.context || there.layer === 'published-language') {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
for (const specifier of node.specifiers) {
|
|
183
|
+
foreign.set(specifier.local.name, there.context);
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
CallExpression(node) {
|
|
187
|
+
if (!WIRING.has(calleeName(node) ?? '')) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
for (const wired of node.arguments.flatMap(wiredNames)) {
|
|
191
|
+
const there = foreign.get(wired.name);
|
|
192
|
+
if (there !== undefined) {
|
|
193
|
+
tell({ node: wired, messageId: 'foreignWiring', data: { here: here.context, there, name: wired.name } });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** `resolve(Port)` and the dependency list of `handledBy(Handler, [Port])`. */
|
|
200
|
+
function wiredNames(argument) {
|
|
201
|
+
if (argument.type === AST_NODE_TYPES.Identifier) {
|
|
202
|
+
return [argument];
|
|
203
|
+
}
|
|
204
|
+
if (argument.type !== AST_NODE_TYPES.ArrayExpression) {
|
|
205
|
+
return [];
|
|
206
|
+
}
|
|
207
|
+
return argument.elements.filter((element) => element?.type === AST_NODE_TYPES.Identifier);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* In the declared style a role file names the ports it needs next to its decorator: one taken from
|
|
211
|
+
* a port file of another context (its repositories, its ports) ties the two wirings.
|
|
212
|
+
*/
|
|
213
|
+
function foreignPorts(file, here, tell) {
|
|
214
|
+
if (!isDeclaredStyle(file) || declaredRoleOf(file) === undefined) {
|
|
215
|
+
return {};
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
ImportDeclaration(node) {
|
|
219
|
+
const target = resolveImport(file.config, file.path, node.source.value);
|
|
220
|
+
if (target.kind !== 'file' || target.location.area !== 'context' || target.location.context === here.context) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const there = target.location.context;
|
|
224
|
+
const taken = isPortFile(file.config, target.path) ? node.specifiers : [];
|
|
225
|
+
for (const specifier of taken) {
|
|
226
|
+
tell({
|
|
227
|
+
node: specifier,
|
|
228
|
+
messageId: 'foreignPort',
|
|
229
|
+
data: { here: here.context, there, name: takenName(specifier) },
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/** The name the other module exports, whatever it is renamed to locally. */
|
|
236
|
+
function takenName(specifier) {
|
|
237
|
+
if (specifier.type !== AST_NODE_TYPES.ImportSpecifier) {
|
|
238
|
+
return specifier.local.name;
|
|
239
|
+
}
|
|
240
|
+
return specifier.imported.type === AST_NODE_TYPES.Identifier ? specifier.imported.name : specifier.imported.value;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=context-extractable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-extractable.js","sourceRoot":"","sources":["../../src/rules/context-extractable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAiB,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAe,MAA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KACF,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,SAAS,SAAS,CAAC,SAAgC;IACjD,IAAI,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,eAAe,EAAE,CAAC;QACtD,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,OAAO,SAAS,CAAC,QAAQ,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;AACpH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
type MessageId = 'undeclared' | 'wrongRole' | 'name' | 'eventName' | 'inDomain';
|
|
3
|
+
export declare const declarationsRoleDeclared: TSESLint.RuleModule<MessageId, [], import("../index.js").RuleDocs, TSESLint.RuleListener>;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=declarations-role-declared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations-role-declared.d.ts","sourceRoot":"","sources":["../../src/rules/declarations-role-declared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAiB,MAAM,0BAA0B,CAAC;AAsBxF,KAAK,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC;AAGhF,eAAO,MAAM,wBAAwB,2FAgDnC,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { className } from '../support/classes/class-name.js';
|
|
3
|
+
import { exportedClasses } from '../support/classes/exported-classes.js';
|
|
4
|
+
import { keyName } from '../support/classes/key-name.js';
|
|
5
|
+
import { topLevelClasses } from '../support/classes/top-level-classes.js';
|
|
6
|
+
import { ACCESS_DECORATORS } from '../support/declarations/access-decorators.js';
|
|
7
|
+
import { DECLARATIONS_ENTRY, declarationReader, } from '../support/declarations/declaration-reader.js';
|
|
8
|
+
import { WRITTEN_NAMES } from '../support/declarations/written-names.js';
|
|
9
|
+
import { declaredRoleOf } from '../support/declarations/declared-role-of.js';
|
|
10
|
+
import { isDeclaredStyle } from '../support/declarations/is-declared-style.js';
|
|
11
|
+
import { writtenName } from '../support/declarations/written-name.js';
|
|
12
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
13
|
+
import { inContext } from '../support/imports/in-context.js';
|
|
14
|
+
import { staticString } from '../support/imports/static-string.js';
|
|
15
|
+
import { classFinder } from '../support/classes/class-finder.js';
|
|
16
|
+
export const declarationsRoleDeclared = defineRule({
|
|
17
|
+
id: 'declarations/role-declared',
|
|
18
|
+
type: 'problem',
|
|
19
|
+
recommended: 'error',
|
|
20
|
+
description: 'In a declared-style project, a role file exports a class carrying the decorator of its role, names are written as string literals, and the domain declares nothing.',
|
|
21
|
+
messages: {
|
|
22
|
+
undeclared: `This file is a role file of the declared style (\`*.{{suffix}}.ts\` under {{folder}}/) but exports no class carrying \`@{{expected}}\`. Put \`@{{expected}}(...)\` from "${DECLARATIONS_ENTRY}" on the exported class: a class that does not say what it is is in no assembly and is never registered.`,
|
|
23
|
+
wrongRole: '{{className}} carries `@{{actual}}` in a `*.{{suffix}}.ts` file under {{folder}}/, where a class is declared with `@{{expected}}`. Move the class to the file of its role, or declare it with `@{{expected}}(...)`: the file name, the folder and the decorator say the same thing.',
|
|
24
|
+
name: "`@{{decorator}}` of {{className}} has a `{{key}}` that is {{problem}}. Write `{ {{key}}: '{{context}}.<name>' }` as a string literal: the name is written once, never derived, and survives the renaming of the class.",
|
|
25
|
+
eventName: '`@DomainEventHandler` of {{className}} names "{{declared}}", but {{event}} is named "{{actual}}". Write `{ name: \'{{actual}}\' }`: a handler names the domain event it reacts to by the name the event carries.',
|
|
26
|
+
inDomain: '{{className}} carries `@{{decorator}}` under domain/: the domain declares nothing. Aggregates, entities, value objects, events, services and repository ports carry no decorator and no dependency list. Remove the decorator and declare the class of application/ or infrastructure/ that plays the role.',
|
|
27
|
+
},
|
|
28
|
+
create({ file, sourceCode, context, report }) {
|
|
29
|
+
const here = inContext(file);
|
|
30
|
+
if (here === undefined || file.isTest || !isDeclaredStyle(file)) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
const declarationsOf = declarationReader(sourceCode.ast);
|
|
34
|
+
if (here.layer === 'domain') {
|
|
35
|
+
return domain(declarationsOf, report);
|
|
36
|
+
}
|
|
37
|
+
const findClass = classFinder(file, sourceCode.ast, context.languageOptions.parser);
|
|
38
|
+
const role = declaredRoleOf(file);
|
|
39
|
+
const judgeClass = (node) => {
|
|
40
|
+
for (const declaration of declarationsOf(node)) {
|
|
41
|
+
const finding = unwrittenName(node, declaration, here.context) ?? renamedEvent(node, declaration, findClass);
|
|
42
|
+
if (finding !== undefined) {
|
|
43
|
+
report(finding);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
Program: (program) => (role === undefined ? [] : misdeclaredRole(program, role, declarationsOf)).forEach(report),
|
|
49
|
+
ClassDeclaration: judgeClass,
|
|
50
|
+
ClassExpression: judgeClass,
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
function domain(declarationsOf, tell) {
|
|
55
|
+
const judgeClass = (node) => {
|
|
56
|
+
for (const declaration of declarationsOf(node)) {
|
|
57
|
+
tell({
|
|
58
|
+
node: declaration.node,
|
|
59
|
+
messageId: 'inDomain',
|
|
60
|
+
data: { className: className(node), decorator: declaration.name },
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return { ClassDeclaration: judgeClass, ClassExpression: judgeClass };
|
|
65
|
+
}
|
|
66
|
+
/** `authz/declared` holds the two roles whose decorator says who may send a message. */
|
|
67
|
+
function misdeclaredRole(program, role, declarationsOf) {
|
|
68
|
+
if (role.decorators.some((decorator) => ACCESS_DECORATORS.has(decorator))) {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
const data = { suffix: role.suffix, folder: role.folders.join(' or '), expected: role.decorators.join(' or @') };
|
|
72
|
+
const playsRole = (declaration) => role.decorators.includes(declaration.name);
|
|
73
|
+
const misplaced = topLevelClasses(program).flatMap((node) => declarationsOf(node)
|
|
74
|
+
.filter((declaration) => !playsRole(declaration))
|
|
75
|
+
.map((declaration) => ({ node, declaration })));
|
|
76
|
+
if (misplaced.length > 0) {
|
|
77
|
+
return misplaced.map(({ node, declaration }) => ({
|
|
78
|
+
node: declaration.node,
|
|
79
|
+
messageId: 'wrongRole',
|
|
80
|
+
data: { ...data, className: className(node), actual: declaration.name },
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
const exported = exportedClasses(program);
|
|
84
|
+
if (exported.some((node) => declarationsOf(node).some(playsRole))) {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
const [first] = exported;
|
|
88
|
+
return [
|
|
89
|
+
first === undefined
|
|
90
|
+
? { loc: { line: 1, column: 0 }, messageId: 'undeclared', data }
|
|
91
|
+
: { node: first.id ?? first, messageId: 'undeclared', data },
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
function unwrittenName(node, declaration, context) {
|
|
95
|
+
const key = WRITTEN_NAMES[declaration.name];
|
|
96
|
+
const written = key === undefined ? undefined : writtenName(declaration.arguments[1], key);
|
|
97
|
+
if (key === undefined || written === undefined || 'value' in written) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
node: declaration.node,
|
|
102
|
+
messageId: 'name',
|
|
103
|
+
data: { decorator: declaration.name, className: className(node), key, problem: written.problem, context },
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** Compared only when the event class is in view: declared in this file, or imported by name from a file read from disk. */
|
|
107
|
+
function renamedEvent(node, declaration, findClass) {
|
|
108
|
+
const [event, options] = declaration.arguments;
|
|
109
|
+
if (declaration.name !== 'DomainEventHandler' || event?.type !== AST_NODE_TYPES.Identifier) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
const declared = writtenName(options, 'name');
|
|
113
|
+
const site = findClass(event.name);
|
|
114
|
+
const actual = site === undefined ? undefined : eventName(site.node);
|
|
115
|
+
if (!('value' in declared) || actual === undefined || actual === declared.value) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
node: declaration.node,
|
|
120
|
+
messageId: 'eventName',
|
|
121
|
+
data: { className: className(node), declared: declared.value, event: event.name, actual },
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** `readonly name = 'billing.invoice.issued';`, with or without `as const`. */
|
|
125
|
+
function eventName(event) {
|
|
126
|
+
for (const member of event.body.body) {
|
|
127
|
+
if (member.type !== AST_NODE_TYPES.PropertyDefinition ||
|
|
128
|
+
member.computed ||
|
|
129
|
+
keyName(member.key) !== 'name' ||
|
|
130
|
+
member.value === null) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
return staticString(unwrapped(member.value));
|
|
134
|
+
}
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
function unwrapped(value) {
|
|
138
|
+
return value.type === AST_NODE_TYPES.TSAsExpression || value.type === AST_NODE_TYPES.TSSatisfiesExpression
|
|
139
|
+
? unwrapped(value.expression)
|
|
140
|
+
: value;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=declarations-role-declared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations-role-declared.js","sourceRoot":"","sources":["../../src/rules/declarations-role-declared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgC,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,SAAS,EAAkB,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAw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AAI,EAAE,MAAM,EAAE;KAC1F,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,SAAS,SAAS,CAAC,KAAgC;IACjD,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACrC,IACE,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,kBAAkB;YACjD,MAAM,CAAC,QAAQ;YACf,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,MAAM;YAC9B,MAAM,CAAC,KAAK,KAAK,IAAI,EACrB,CAAC;YACD,SAAS;QACX,CAAC;QAED,OAAO,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CAAC,KAA0B;IAC3C,OAAO,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,cAAc,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,qBAAqB;QACxG,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;QAC7B,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
type MessageId = 'publicConstructor' | 'missingConstructor' | 'publicMutableProperty' | 'setter';
|
|
2
|
+
export declare const domainAggregateEncapsulation: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageId, [], import("../index.js").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
3
|
+
export {};
|
|
4
|
+
//# sourceMappingURL=domain-aggregate-encapsulation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-aggregate-encapsulation.d.ts","sourceRoot":"","sources":["../../src/rules/domain-aggregate-encapsulation.ts"],"names":[],"mappings":"AAWA,KAAK,SAAS,GAAG,mBAAmB,GAAG,oBAAoB,GAAG,uBAAuB,GAAG,QAAQ,CAAC;AAIjG,eAAO,MAAM,4BAA4B,mKAgDvC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { className } from '../support/classes/class-name.js';
|
|
3
|
+
import { constructorOf } from '../support/classes/constructor-of.js';
|
|
4
|
+
import { isCallable } from '../support/classes/is-callable.js';
|
|
5
|
+
import { memberName } from '../support/classes/member-name.js';
|
|
6
|
+
import { visibilityOf } from '../support/classes/visibility-of.js';
|
|
7
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
8
|
+
import { parameterName } from '../support/members/parameter-name.js';
|
|
9
|
+
import { parameterProperties } from '../support/members/parameter-properties.js';
|
|
10
|
+
import { startsAtThis } from '../support/members/starts-at-this.js';
|
|
11
|
+
const GUARDED_DIRECTORIES = ['aggregates', 'entities'];
|
|
12
|
+
export const domainAggregateEncapsulation = defineRule({
|
|
13
|
+
id: 'domain/aggregate-encapsulation',
|
|
14
|
+
type: 'problem',
|
|
15
|
+
recommended: 'error',
|
|
16
|
+
description: 'An aggregate or an entity has a private or protected constructor, no public mutable property and no setter: state changes through methods named after the business intention.',
|
|
17
|
+
messages: {
|
|
18
|
+
publicConstructor: 'The constructor of {{className}} is public. Make it private (protected for a base class) and create instances through `create` for a birth and `rehydrate` for a load, so that no invalid {{className}} can exist.',
|
|
19
|
+
missingConstructor: '{{className}} has no constructor, so anyone can instantiate it without its invariants. Declare a private constructor and the `create` and `rehydrate` factories.',
|
|
20
|
+
publicMutableProperty: 'The property {{name}} of {{className}} can be written from outside. Make it private or readonly and change it through a method named after the business intention.',
|
|
21
|
+
setter: '{{name}} is a setter: it changes {{className}} without saying why. Replace it with a method named after the business intention, which guards its invariants and records the event.',
|
|
22
|
+
},
|
|
23
|
+
create({ file, report }) {
|
|
24
|
+
const { location } = file;
|
|
25
|
+
if (location.area !== 'context' ||
|
|
26
|
+
location.layer !== 'domain' ||
|
|
27
|
+
file.isTest ||
|
|
28
|
+
!GUARDED_DIRECTORIES.includes(location.inside[0] ?? '')) {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
ClassBody(body) {
|
|
33
|
+
const owner = className(body.parent);
|
|
34
|
+
judgeConstructor(body, owner, report);
|
|
35
|
+
for (const node of mutableProperties(body)) {
|
|
36
|
+
report({ node, messageId: 'publicMutableProperty', data: { className: owner, name: propertyLabel(node) } });
|
|
37
|
+
}
|
|
38
|
+
for (const member of body.body.filter(isSetter)) {
|
|
39
|
+
report({
|
|
40
|
+
node: member.key,
|
|
41
|
+
messageId: 'setter',
|
|
42
|
+
data: { className: owner, name: memberName(member) ?? 'This method' },
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
function judgeConstructor(body, owner, report) {
|
|
50
|
+
if (body.parent.abstract) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const constructor = constructorOf(body);
|
|
54
|
+
if (constructor !== undefined && visibilityOf(constructor) === 'public') {
|
|
55
|
+
report({ node: constructor.key, messageId: 'publicConstructor', data: { className: owner } });
|
|
56
|
+
}
|
|
57
|
+
// A subclass without a constructor inherits the visibility of its base: the kernel bases are protected.
|
|
58
|
+
if (constructor === undefined && body.parent.superClass === null) {
|
|
59
|
+
report({ node: body.parent.id ?? body.parent, messageId: 'missingConstructor', data: { className: owner } });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function mutableProperties(body) {
|
|
63
|
+
const fields = body.body.filter((member) => member.type === AST_NODE_TYPES.PropertyDefinition || member.type === AST_NODE_TYPES.AccessorProperty);
|
|
64
|
+
const exposed = fields.filter((member) => visibilityOf(member) === 'public' && !member.readonly && !member.declare && !isCallable(member));
|
|
65
|
+
const parameters = parameterProperties(constructorOf(body)).filter((property) => property.accessibility === 'public' && !property.readonly);
|
|
66
|
+
return [...exposed, ...parameters];
|
|
67
|
+
}
|
|
68
|
+
function propertyLabel(node) {
|
|
69
|
+
return node.type === AST_NODE_TYPES.TSParameterProperty
|
|
70
|
+
? parameterName(node)
|
|
71
|
+
: (memberName(node) ?? 'a computed key');
|
|
72
|
+
}
|
|
73
|
+
function isSetter(member) {
|
|
74
|
+
if (member.type !== AST_NODE_TYPES.MethodDefinition || visibilityOf(member) !== 'public') {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (member.kind === 'set') {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return member.kind === 'method' && /^set[A-Z]/.test(memberName(member) ?? '') && onlyAssigns(member.value.body);
|
|
81
|
+
}
|
|
82
|
+
function onlyAssigns(body) {
|
|
83
|
+
const statements = body?.body ?? [];
|
|
84
|
+
return statements.length > 0 && statements.every(isAssignmentToThis);
|
|
85
|
+
}
|
|
86
|
+
function isAssignmentToThis(statement) {
|
|
87
|
+
if (statement.type !== AST_NODE_TYPES.ExpressionStatement ||
|
|
88
|
+
statement.expression.type !== AST_NODE_TYPES.AssignmentExpression) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
return startsAtThis(statement.expression.left);
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=domain-aggregate-encapsulation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-aggregate-encapsulation.js","sourceRoot":"","sources":["../../src/rules/domain-aggregate-encapsulation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAe,MAAM,gCAA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AAE,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAClH,CAAC;AAED,SAAS,WAAW,CAAC,IAAgD;IACnE,MAAM,UAAU,GAAG,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;IAEpC,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,kBAAkB,CAAC,SAA6B;IACvD,IACE,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,mBAAmB;QACrD,SAAS,CAAC,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,oBAAoB,EACjE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,YAAY,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
export declare const domainEventsDispatchedOnSave: TSESLint.RuleModule<"dispatcher" | "pulled", [], import("../index.js").RuleDocs, TSESLint.RuleListener>;
|
|
3
|
+
//# sourceMappingURL=domain-events-dispatched-on-save.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-events-dispatched-on-save.d.ts","sourceRoot":"","sources":["../../src/rules/domain-events-dispatched-on-save.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAiB,MAAM,0BAA0B,CAAC;AAqBxF,eAAO,MAAM,4BAA4B,yGA2CvC,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { propertyName } from '../support/globals/property-name.js';
|
|
3
|
+
import { dependencyListListener } from '../support/ports/dependency-list-listener.js';
|
|
4
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
5
|
+
import { parameterTypeName } from '../support/types/parameter-type-name.js';
|
|
6
|
+
const DISPATCHER = 'DomainEventDispatcher';
|
|
7
|
+
const PULL = 'pullEvents';
|
|
8
|
+
const ON_SAVE = 'events leave with the save: `await repository.save(aggregate)` and nothing else; a removal that announces an event takes the aggregate.';
|
|
9
|
+
export const domainEventsDispatchedOnSave = defineRule({
|
|
10
|
+
id: 'domain-events/dispatched-on-save',
|
|
11
|
+
type: 'problem',
|
|
12
|
+
recommended: 'error',
|
|
13
|
+
description: 'Domain events leave with the save: no `pullEvents()` in application/ or infrastructure/, no DomainEventDispatcher in a command, a query or a repository adapter.',
|
|
14
|
+
messages: {
|
|
15
|
+
pulled: `\`${PULL}()\` is called in {{place}}: ${ON_SAVE}`,
|
|
16
|
+
dispatcher: `${DISPATCHER} is {{how}} in {{place}}: ${ON_SAVE}`,
|
|
17
|
+
},
|
|
18
|
+
create({ file, sourceCode, report }) {
|
|
19
|
+
const judged = judgedAs(file);
|
|
20
|
+
if (judged === undefined) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
const { place } = judged;
|
|
24
|
+
const refuse = (node, how) => report({ node, messageId: 'dispatcher', data: { how, place } });
|
|
25
|
+
const lists = dependencyLists(sourceCode.ast, judged, refuse);
|
|
26
|
+
return {
|
|
27
|
+
...lists,
|
|
28
|
+
CallExpression(node) {
|
|
29
|
+
lists.CallExpression?.(node);
|
|
30
|
+
if (isPull(node)) {
|
|
31
|
+
report({ node, messageId: 'pulled', data: { place } });
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
ImportDeclaration(node) {
|
|
35
|
+
for (const specifier of judged.refusesDispatcher ? node.specifiers.filter(importsDispatcher) : []) {
|
|
36
|
+
refuse(specifier, 'imported');
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
MethodDefinition(node) {
|
|
40
|
+
for (const parameter of judged.refusesDispatcher ? dispatcherParameters(node) : []) {
|
|
41
|
+
refuse(parameter, 'a constructor parameter');
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
function dependencyLists(program, judged, refuse) {
|
|
48
|
+
return dependencyListListener(program, (dependency) => {
|
|
49
|
+
if (judged.refusesDispatcher && dependency.name === DISPATCHER) {
|
|
50
|
+
refuse(dependency, 'named in a dependency list');
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function dispatcherParameters(node) {
|
|
55
|
+
return node.kind === 'constructor'
|
|
56
|
+
? node.value.params.filter((candidate) => parameterTypeName(candidate) === DISPATCHER)
|
|
57
|
+
: [];
|
|
58
|
+
}
|
|
59
|
+
/** Production files of application/ and infrastructure/; the module file, the tests and everything outside a context are not judged. */
|
|
60
|
+
function judgedAs(file) {
|
|
61
|
+
const { location } = file;
|
|
62
|
+
if (location.area !== 'context' || file.isTest) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
const [folder = ''] = location.inside;
|
|
66
|
+
if (location.layer === 'application') {
|
|
67
|
+
return { place: `application/${folder}`, refusesDispatcher: folder === 'commands' || folder === 'queries' };
|
|
68
|
+
}
|
|
69
|
+
if (location.layer !== 'infrastructure') {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
place: `infrastructure/${folder}`,
|
|
74
|
+
refusesDispatcher: folder === 'persistence' && file.path.endsWith('.repository.ts'),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function isPull(node) {
|
|
78
|
+
return node.callee.type === AST_NODE_TYPES.MemberExpression && propertyName(node.callee) === PULL;
|
|
79
|
+
}
|
|
80
|
+
function importsDispatcher(specifier) {
|
|
81
|
+
if (specifier.type !== AST_NODE_TYPES.ImportSpecifier) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const { imported } = specifier;
|
|
85
|
+
return (imported.type === AST_NODE_TYPES.Identifier ? imported.name : imported.value) === DISPATCHER;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=domain-events-dispatched-on-save.js.map
|