This plugin helps to enforce import constraints according to the Onion Architecture.
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-onion-imports
:
npm install eslint-plugin-onion-imports --save-dev
Add onion-imports
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": ["onion-imports"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"onion-imports/onion-imports": [
"warn",
{
"layers": [
[
{ "name": "UI", "patterns": ["src/ui/"] },
{ "name": "Data Access", "patterns": ["src/data-access/"] }
],
{ "name": "Business Logic", "patterns": ["src/business-logic/"] },
{ "name": "Object Model", "patterns": ["src/object-model/"] }
]
}
]
}
}