noUselessEmptyExport
このコンテンツはまだ日本語訳がありません。
Summary
Section titled “Summary”- Rule available since: v1.0.0
- Diagnostic Category: lint/complexity/noUselessEmptyExport
- This rule is recommended, which means is enabled by default.
- This rule has a safe fix.
- The default severity of this rule is information.
- Sources:
How to configure
Section titled “How to configure”{  "linter": {    "rules": {      "complexity": {        "noUselessEmptyExport": "error"      }    }  }}Description
Section titled “Description”Disallow empty exports that don’t change anything in a module file.
An empty export {} is sometimes useful to turn a file that would otherwise be a script into a module.
Per the TypeScript Handbook Modules page:
In TypeScript, just as in ECMAScript 2015, any file containing a top-level import or export is considered a module. Conversely, a file without any top-level import or export declarations is treated as a script whose contents are available in the global scope.
However, an export {} statement does nothing if there are any other top-level import or export in the file.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”import { A } from "module";export {};code-block.js:2:1 lint/complexity/noUselessEmptyExport  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ℹ This empty export is useless because there’s another export or import.
  
    1 │ import { A } from “module”;
  > 2 │ export {};
      │ ^^^^^^^^^^
    3 │ 
  
  ℹ This import makes useless the empty export.
  
  > 1 │ import { A } from “module”;
      │ ^^^^^^
    2 │ export {};
    3 │ 
  
  ℹ Safe fix: Remove this useless empty export.
  
    1 1 │   import { A } from “module”;
    2   │ - export·{};
    3 2 │   
  
export const A = 0;export {};code-block.js:2:1 lint/complexity/noUselessEmptyExport  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ℹ This empty export is useless because there’s another export or import.
  
    1 │ export const A = 0;
  > 2 │ export {};
      │ ^^^^^^^^^^
    3 │ 
  
  ℹ This export makes useless the empty export.
  
  > 1 │ export const A = 0;
      │ ^^^^^^
    2 │ export {};
    3 │ 
  
  ℹ Safe fix: Remove this useless empty export.
  
    1 1 │   export const A = 0;
    2   │ - export·{};
    3 2 │   
  
export {};Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.