You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've seen your talk at SnowCamp 2022 and I asked if you used any tools to prevent breaking the rule of the Domain dependencies: no dependencies from Domain to the outside world. I think there is actually a tool that can help with that: eslint and one of its plugins, eslint-plugin-import. You probably already know eslint which is widely-used to lint files and detect problems. eslint-plugin-import has many rules but one rule is of particular interest to this problem: import/no-restricted-paths. It allows you to define "zones" from either a folder or a glob, and define specific restrictions on each zone. You can prevent files from one folder from importing files from other defined folders. Using this rule, we can prevent the Domain from importing files from the Adapters.
Shortly before the talk, I watched your video "Hands-on Front : La clean architecture dans le web" and was really inspired to give it a try. I did not go for the full "Clean Architecture", just "Hexagonal Architecture" for now. Anyway, please check out this example of an .eslintrc file that defines rules to prevent dependencies from the Domain to the Adapters. There are also separate rules for each "type" of adapters to prevent adapters from the UI depending directly on other adapters from REST API for example.
The rules do not prevent all dependencies though: you are still allowed to depend on libs from node_modules. If one wants to completely isolate the Domain from libs, the rule should be refined to make it stricter.
I hope this can help ! 🙂
The text was updated successfully, but these errors were encountered:
Hello 👋
I've seen your talk at SnowCamp 2022 and I asked if you used any tools to prevent breaking the rule of the Domain dependencies: no dependencies from Domain to the outside world. I think there is actually a tool that can help with that: eslint and one of its plugins, eslint-plugin-import. You probably already know
eslint
which is widely-used to lint files and detect problems.eslint-plugin-import
has many rules but one rule is of particular interest to this problem:import/no-restricted-paths
. It allows you to define "zones" from either a folder or a glob, and define specific restrictions on each zone. You can prevent files from one folder from importing files from other defined folders. Using this rule, we can prevent the Domain from importing files from the Adapters.Shortly before the talk, I watched your video "Hands-on Front : La clean architecture dans le web" and was really inspired to give it a try. I did not go for the full "Clean Architecture", just "Hexagonal Architecture" for now. Anyway, please check out this example of an
.eslintrc
file that defines rules to prevent dependencies from the Domain to the Adapters. There are also separate rules for each "type" of adapters to prevent adapters from the UI depending directly on other adapters from REST API for example.The rules do not prevent all dependencies though: you are still allowed to depend on libs from
node_modules
. If one wants to completely isolate the Domain from libs, the rule should be refined to make it stricter.I hope this can help ! 🙂
The text was updated successfully, but these errors were encountered: