DocumentationGetting Started

Getting Started

JavaScript

Install

Terminal
npm install --save-dev @eslint-react/eslint-plugin

Setup

eslint.config.js
import react from "@eslint-react/eslint-plugin";
 
export default [
  {
    files: ["**/*.js", "**/*.jsx"],
    ...react.configs["recommended"],
    languageOptions: {
      parserOptions: {
        ecmaFeatures: {
          jsx: true,
        },
      },
    },
  },
  {
    files: ["**/*.js", "**/*.jsx"],
    rules: {
      // Put rules you want to override here
    },
  },
];

TypeScript

Install

Terminal
npm install --save-dev typescript-eslint @eslint-react/eslint-plugin

Setup

eslint.config.js
 
// @ts-check
import react from "@eslint-react/eslint-plugin";
import tseslint from "typescript-eslint";
 
export default tseslint.config({
  files: ["**/*.ts", "**/*.tsx"],
  extends: [
    react.configs["recommended"],
  ],
  languageOptions: {
    parser: tseslint.parser,
    parserOptions: {
      projectService: true,
    },
  },
  rules: {
    // Put rules you want to override here
  },
});

JavaScript with Babel

Terminal
npm install --save-dev @babel/core @babel/eslint-parser @babel/preset-env @babel/preset-react @eslint-react/eslint-plugin
eslint.config.js
import parser from "@babel/eslint-parser";
import react from "@eslint-react/eslint-plugin";
 
export default [
  {
    files: ["**/*.js", "**/*.jsx"],
    languageOptions: {
      parser,
      parserOptions: {
        requireConfigFile: false,
        babelOptions: {
          babelrc: false,
          configFile: false,
          presets: ["@babel/preset-env", "@babel/preset-react"],
        },
      },
    },
  },
];