eslint-plugin-misc

ESLint plugin

This project is maintained by iliubinskii

prefer-only-export

ESLint plugin / prefer-only-export

Requires only export if given AST element is found.

module.exports = {
  plugins: ["misc"],
  rules: {
    "misc/prefer-only-export": [
      "error",
      {
        selector: string | string[]
      }
    ]
  }
};

| Option | Description | Default | | :—– | :———- | :—— |

selector AST selector []

Examples of incorrect code

/*
eslint misc/prefer-only-export: [
  error,
  {
    selector: "Program > ExportNamedDeclaration > ClassDeclaration"
  }
]
*/
export class SampleClass {}
export const x = 1;

Examples of correct code

/*
eslint misc/prefer-only-export: [
  error,
  {
    selector: "Program > ExportNamedDeclaration > ClassDeclaration"
  }
]
*/
export class SampleClass {}