HTG Eslint plugin for enforcing modular structure
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-htg
:
$ npm install eslint-plugin-htg --save-dev
Add htg
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"htg"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"htg/no-deep-module-imports": "error"
}
}
You may set the following settings in your .eslintrc:
module.exports = {
settings: {
htg: {
path: {
'@modules/': 'src/modules/'
},
modules: [
'@modules/commons',
'@modules/models',
'@modules/components',
'@modules/features',
'@modules/pages',
]
}
},
}
Define path aliases for import resolution.
Provide an array of paths to directories containing modules.
Primary use for wildcards is to separate different applications. Imports between different applications are forbidden.
Wildcard support is minimal:
- Only a single wildcard is supported:
- Supported:
apps/*/features
- Not Supported:
apps/*/subapps/*/features
- Supported:
- Wildcards does not support partial directory matching:
- Supported:
apps/*/features
- Not Supported:
apps/prefix_*/features
- Supported: