quick-lint-js

Find bugs in JavaScript programs.

JSX linting

quick-lint-js supports JSX in JavaScript and TypeScript code. Different web frameworks, such as React.js, treat JSX differently. quick-lint-js has different diagnostics for different frameworks.

JSX modes

quick-lint-js has a configurable JSX mode which determines which diagnostics are reported, if any, for invalid JSX use.

quick-lint-js's JSX modes
JSX mode Description
"auto" (default) See below
"react" React.js
"none" JSX is allowed, but no framework-specific
diagnostics are reported

You can specify the JSX mode explicitly by creating a quick-lint-js.config file. This is useful if quick-lint-js fails to automatically detect your framework. For example:

{
  "jsx-mode": "react"
}
quick-lint-js.config which lints JSX as React.js without needing import "react";

Specifying a JSX mode in quick-lint-js.config was introduced in quick-lint-js version 3.1.0. Prior to version 3.1.0, the JSX mode was always "react".

"auto" JSX mode

By default, quick-lint-js's JSX mode is "auto". If the JSX mode is "auto", then quick-lint-js will guess which framework you are using based on import statements in your code:

quick-lint-js's JSX mode heuristics
Import Guessed JSX mode
import React from "react"; "react"
import ReactDOM from "react-dom"; "react"
import ReactDOM from "react-dom/client"; "react"
import ReactDOM from "react-dom/server"; "react"
(none of the above import statements) "none"
(multiple JSX modes detected) "none"

The "auto" JSX mode was introduced in quick-lint-js version 3.1.0.

React.js ("react" JSX mode)

quick-lint-js detects misuse of JSX with the React.js framework if the JSX mode is "react".

React.js-specific diagnostics: E0191, E0192, E0193

import React from "react";

export function CommentButton({onClick}) {
  return (
    <button
      onclick={onClick}
      accesskey="c"
      class="red-button"
    >
      Comment
    </button>
  );
}
Demonstration of different React-specific diagnostics in quick-lint-js

The "react" JSX mode was introduced quick-lint-js version 2.0.0. The "react" JSX mode was the default JSX mode until quick-lint-js version 3.1.0.