quick-lint-js

Find bugs in JavaScript programs.

E0081: missing name of exported class

In modules, classes can be exported by name or by default. It is an error to export an unnamed class by name:

export class {
  render() {
    return React.createElement(
      "h1",
      null,
      `Hello, ${this.props.name}!`,
    );
  }
}

To fix this error, export the class by default:

// Import using:
// import MyComponent from "./MyComponent.mjs";
export default class {
  render() {
    return React.createElement(
      "h1",
      null,
      `Hello, ${this.props.name}!`,
    );
  }
}

Alternatively, give a name to the class:

// Import using:
// import {MyComponent} from "./MyComponent.mjs";
export class MyComponent {
  render() {
    return React.createElement(
      "h1",
      null,
      `Hello, ${this.props.name}!`,
    );
  }
}

Introduced in quick-lint-js version 0.2.0.

Documentation for other errors