Skip to content

omnicajs/eslint-plugin-dependencies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

983 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

ESLint Plugin Dependencies

Version GitHub License

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 eslint

Next, install @omnicajs/eslint-plugin-dependencies:

npm install --save-dev @omnicajs/eslint-plugin-dependencies

Usage

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.

About

ESLint plugin for sorting and structuring import and export declarations.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors