eslint-plugin-export-default-identifier
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

export-default-identifier

An eslint plugin that only allows export default to export specific types of expressions.

By default, only allows Identifier expressions, i.e. named variables. Excludes all anonymous classes, functions, and objects. This was originally created for use with TypeDoc, which does not generate proper JSDOC documentation for anonymous export defaults.

NOTE: Equivalent to import/no-anonymous-default-export:

"import/no-anonymous-default-export": ["error", {
  "allowArray": false,
  "allowArrowFunction": false,
  "allowAnonymousClass": false,
  "allowAnonymousFunction": false,
  "allowCallExpression": false,
  "allowLiteral": false,
  "allowObject": false
}]

Install

npm install --save-dev export-default-identifier

Usage

Add to your .eslintrc.json:

{
  "plugins": [
    "export-default-identifier",
  ],
  ...
  "rules": {
    "export-default-identifier/export-default-identifier": "error"
  }
}

Specify exactly which types can be exported as default:

"export-default-identifier/export-default-identifier": ["error", {
  "types": ["Identifier"]
}]

Rule details

Examples of incorrect code:

export default {}
export default function test() {}

✔️ Examples of correct code:

const myExport = {}
export default myExport

Examples of incorrect code with [{"types":["Identifier","FunctionDeclaration"]}] options:

export default {}

✔️ Examples of correct code with [{"types":["Identifier","FunctionDeclaration"]}] options:

const myExport = {}
export default myExport

export default function test() {}

Resources

Package Sidebar

Install

npm i eslint-plugin-export-default-identifier

Weekly Downloads

227

Version

0.3.0

License

ISC

Unpacked Size

9.2 kB

Total Files

14

Last publish

Collaborators

  • raine