@omnicajs/eslint-plugin-dependencies
v0.0.2
Published
ESLint plugin for sorting and structuring import and export declarations.
Downloads
6,440
Maintainers
Readme
ESLint Plugin Dependencies
An ESLint plugin focused on consistent import / export declaration order and
structure.
This plugin defines rules for sorting and structuring import and export
declarations.
All rules are automatically fixable.
Documentation
See docs.
Installation
You'll first need to install ESLint v8.45.0 or greater:
npm install --save-dev eslintNext, install @omnicajs/eslint-plugin-dependencies:
npm install --save-dev @omnicajs/eslint-plugin-dependenciesUsage
Add @omnicajs/eslint-plugin-dependencies to the plugins section of the ESLint
configuration file and define the list of rules you will use.
Flat Config (eslint.config.js)
import dependencies from '@omnicajs/eslint-plugin-dependencies'
export default [
{
plugins: {
dependencies,
},
rules: {
'dependencies/sort-imports': [
'error',
{
type: 'natural',
order: 'asc',
},
],
},
},
]Legacy Config (.eslintrc.js)
module.exports = {
plugins: [
'dependencies',
],
rules: {
'dependencies/sort-imports': [
'error',
{
type: 'natural',
order: 'asc',
}
]
}
}Configs
The easiest way to use @omnicajs/eslint-plugin-dependencies is to use
ready-made configs. Config files use import/export rules from the plugin, but
you can override them.
Flat Config (eslint.config.js)
import dependencies from '@omnicajs/eslint-plugin-dependencies'
export default [
dependencies.configs['recommended-natural'],
]Legacy Config (.eslintrc.js)
module.exports = {
extends: [
'plugin:dependencies/recommended-natural-legacy',
],
}List of Configs
| Name | Description | | :------------------------------------------------------------------- | :------------------------------------------------------------------ | | recommended-alphabetical | Import/export rules with alphabetical sorting in ascending order | | recommended-natural | Import/export rules with natural sorting in ascending order | | recommended-line-length | Import/export rules with sorting by line length in descending order | | recommended-custom | Import/export rules with sorting by your own custom order |
Rules
🔧 Automatically fixable by the
--fix CLI option.
| Name | Description | 🔧 | | :------------------------------------------------------------- | :----------------------------------------- | :-- | | sort-export-attributes | Enforce sorted export attributes | 🔧 | | sort-exports | Enforce sorted exports | 🔧 | | sort-import-attributes | Enforce sorted import attributes | 🔧 | | sort-imports | Enforce sorted imports | 🔧 | | sort-named-exports | Enforce sorted named exports | 🔧 | | sort-named-imports | Enforce sorted named imports | 🔧 | | import-style | Enforce explicit module import style | 🔧 | | separate-type-imports | Enforce dedicated type import declarations | 🔧 | | separate-type-partitions | Enforce partitions for type-only imports | 🔧 |
Versioning Policy
This plugin is following Semantic Versioning and ESLint's Semantic Versioning Policy.
Contributing
See Contributing Guide.
