eslint-plugin-orderly-functions
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

wakatime GitHub npm npm GitHub issues GitHub stars GitHub Release codecov Size typescript

An ESLint plugin to sort exported function declarations alphabetically while respecting their dependencies.

Installation

You'll first need to install ESLint:

npm install eslint --save-dev
# or
yarn add -D eslint
# or
pnpm i -D eslint
npm install -D eslint-plugin-orderly-functions
# or
yarn add -D eslint-plugin-orderly-functions
# or
pnpm i -D eslint-plugin-orderly-functions

Usage

In your ESLint configuration file (.eslintrc.js or eslint.config.js for ESLint v9+), add the plugin and configure the rule.

// eslint.config.js for ESLint v9+ (flat config)
import orderlyFunctions from 'eslint-plugin-orderly-functions';

export default [
    {
        plugins: {
            'orderly-functions': orderlyFunctions,
        },
        rules: {
            'orderly-functions/sort-functions': 'error',
        },
    },
];

Enabling the Autofixer:

// eslint.config.js
import orderlyFunctions from 'eslint-plugin-orderly-functions';

export default [
    {
        plugins: {
            'orderly-functions': orderlyFunctions,
        },
        rules: {
            'orderly-functions/sort-functions': [
                'error',
                {
                    enableFixer: true,
                },
            ],
        },
    },
];

Note: Enabling the autofixer will reorder your exported functions according to the rule. Use it with caution and ensure you have proper version control and testing in place.

Rule Details

This rule enforces that exported functions are sorted alphabetically while respecting their dependencies.

Options

  • enableFixer (boolean, default: false): Enables the autofixer to automatically reorder functions.

Examples of incorrect code:

export const c = () => {
    return a() + b();
};
export const a = () => 'a';
export const b = () => 'b';

Examples of correct code:

export const a = () => 'a';
export const b = () => 'b';
export const c = () => {
    return a() + b();
};

Package Sidebar

Install

npm i eslint-plugin-orderly-functions

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

27.2 kB

Total Files

9

Last publish

Collaborators

  • ragaeeb