Skip to content

Latest commit

 

History

992 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.57.0, v9, or v10:

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 (ESLint 8–9 only)

ESLint v10 no longer supports .eslintrc.* files. Use the flat config example above with ESLint v10.

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 (ESLint 8–9 only)

ESLint v10 no longer supports legacy shareable configs. Use the flat preset above with ESLint v10.

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

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages