包详细信息

eslint-plugin-no-barrel-files

art0rz395.6kISC1.2.1

ESLint plugin to disallow barrel files.

eslint, plugin, addon, extension

自述文件

eslint-plugin-no-barrel-files

ESLint plugin to disallow barrel files.

Why?

Barrel files can slow down your build/tests, can cause circular dependencies, and makes tree shaking more difficult.

Rules

  • no-barrel-files ```js // fail export * from "./foo";

import Foo from "./foo"; export default Foo;

import Foo from "./foo"; export { Foo };

export { Moo } from './Moo'; export { default as Moo } from './Moo';

// pass const Foo = 'baz'; function Bar() {} class Baz {}

export default Foo; export { Bar, Baz }

import { Moo } from './Moo'; export const Baz = Moo;


## Usage

### Install
```shell
npm install eslint-plugin-no-barrel-files --save-dev

ESLint config

This plugin supports both flat config and legacy config.

Flat config (ESLint 9+)

import noBarrelFiles from "eslint-plugin-no-barrel-files";

export default [
  noBarrelFiles.flat,
];

Legacy config (ESLint <9)

module.exports = {
    plugins: ['no-barrel-files'],
    rules: {
        'no-barrel-files/no-barrel-files': 'error'
    }
}

Contributing

If you need any additional features or you find a bug, feel free to submit a pull request or submit an issue.

更新日志

1.2.1 (2025-02-04)

Bug Fixes

  • module: #7 missing types in build (e88c6fb)

1.2.0 (2024-11-08)

Features

1.1.2 (2024-11-03)

Bug Fixes

  • use correct flag for installation (9784934)

1.1.1 (2024-05-29)

Bug Fixes

  • #2 with named exports, the exported name instead of the local name would be checked (86ae096)

1.1.0 (2023-08-24)

Features

1.0.0 (2023-08-24)

Features