ESLint InterlaceESLint Interlace
Plugin: import-nextRules

no-barrel-file

ESLint rule documentation for no-barrel-file

šŸ“” Live from GitHub — This documentation is fetched directly from no-barrel-file.md and cached for 6 hours.

šŸ’¼ This rule is enabled in the following configs: recommended, typescript. šŸ’” This rule is automatically fixable by the --fix CLI option.

Disallow barrel files that harm build performance and tree-shaking efficiency

Rule Details

This rule aims to prevent issues related to barrel-file.

Options

[
  {
    "type": "object",
    "properties": {
      "threshold": {
        "type": "number",
        "minimum": 1,
        "default": 3,
        "description": "Minimum number of re-exports to consider a file a barrel"
      },
      "allowedPaths": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "default": [],
        "description": "Regex patterns for paths where barrel files are allowed"
      },
      "barrelPatterns": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "default": [
          ".*[/\\\\]index\\.(ts|tsx|js|jsx|mts|mjs)$"
        ],
        "description": "File patterns considered barrel candidates"
      },
      "allowWithLocalExports": {
        "type": "boolean",
        "default": false,
        "description": "Allow barrel files that also export local declarations"
      },
      "reexportRatio": {
        "type": "number",
        "minimum": 0,
        "maximum": 1,
        "default": 0.8,
        "description": "Maximum allowed ratio of re-exports to total exports"
      }
    },
    "additionalProperties": false
  }
]

Implementation

OWASP Foundation

  • Category: A00:2021 - General Security

Edit this page on GitHub →

On this page

No Headings