Skip to content

vladasmikalajunas/eslint-plugin-htg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-htg

HTG Eslint plugin for enforcing modular structure

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-htg:

$ npm install eslint-plugin-htg --save-dev

Usage

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"
    }
}

Settings

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',
            ]
        }
    },
}

settings.htg.path

Define path aliases for import resolution.

settings.htg.modules

Provide an array of paths to directories containing modules.

Wildcards for multi app support

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
  • Wildcards does not support partial directory matching:
    • Supported: apps/*/features
    • Not Supported: apps/prefix_*/features

Rules