eslint-plugin-hallelujah-fsd-plugin
v0.1.0
Published
looking for use relative imports inside one module
Maintainers
Readme
eslint-plugin-hallelujah-fsd-plugin
ESLint plugin for enforcing FSD (feature-sliced design) import rules, ensuring proper layer boundaries and relative imports within modules.
looking for use relative imports inside one module
Installation
You'll first need to install ESLint:
npm i eslint --save-devNext, install eslint-plugin-hallelujah-fsd-plugin:
npm install eslint-plugin-hallelujah-fsd-plugin --save-devUsage
Add hallelujah-fsd-plugin to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
{
"plugins": ["hallelujah-fsd-plugin"]
}Then configure the rules you want to use under the rules section.
{
"rules": {
"hallelujah-fsd-plugin/rule-name": 2
}
}Configurations
layer-imports
Description: Ensures that files in higher layers only import from lower layers.
| Property | Type | Default Value | Description |
| ---------------------- | ------ | ------------- | ------------------------------------------------------------------------------ |
| alias | string | '' | Prefix for absolute imports, e.g., '@'. Used to normalize paths. |
| ignoreImportPatterns | array | [] | List of glob patterns to ignore during checks. For example: ['**/store/**']. |
Example usage:
{
"rules": {
"hallelujah-fsd-plugin/layer-imports": [
"error",
{
"alias": "@",
"ignoreImportPatterns": ["**/store/**", "**/config/**"]
}
]
}
}path-checker
Description: Ensures that only relative imports are used inside a single module.
| Property | Type | Default Value | Description |
| ------------------- | ------ | ------------- | -------------------------------------------------------------------------- |
| alias | string | '' | Prefix for absolute imports, used to correctly determine the module layer. |
| testFilesPatterns | array | [] | Glob patterns for test files. Allows special imports in test files. |
Example usage:
{
"rules": {
"hallelujah-fsd-plugin/path-checker": [
"error",
{
"alias": "@",
"testFilesPatterns": ["**/*.test.ts", "**/*.spec.ts"]
}
]
}
}public-api-imports
Description: Ensures that absolute imports are only done via the Public API (index.ts or testing.ts) of the corresponding layer.
| Property | Type | Default Value | Description |
| ------------------- | ------ | ------------- | -------------------------------------------------------------------- |
| alias | string | '' | Prefix for absolute imports. |
| testFilesPatterns | array | [] | Glob patterns for test files where testing.ts imports are allowed. |
{
"rules": {
"hallelujah-fsd-plugin/public-api-imports": [
"error",
{
"alias": "@",
"testFilesPatterns": ["**/*.test.ts", "**/*.spec.ts"]
}
]
}
}Rules
🔧 Automatically fixable by the --fix CLI option.
| Name | Description | 🔧 | | :----------------------------------------------------- | :--------------------------------------------- | :-- | | layer-imports | checks to import lower layers in higher layers | | | path-checker | look for path being relative in one module | 🔧 | | public-api-imports | checks imports to be FSD ruled | 🔧 |
