5.0.2 • Published 4 months ago

@gurja/eslint-config v5.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@gurja/eslint-config

Configuring ESLint is always annoying and can even be a nightmare sometimes. This package includes a few opinionated configs

Setup

You can install it with npm, Yarn or pnpm

# npm
npm i -D @gurja/eslint-config eslint

# Yarn
yarn add -D @gurja/eslint-config eslint

# pnpm
pnpm add -D @gurja/eslint-config eslint

Inside eslint.config.js (or eslint.config.mjs if you don't have "type": "module" on your package.json):

import { config, configs } from "@gurja/eslint-config";

export default config(
  configs.react({ vite: true }),
  // any other ESLint config you'd want to add as well
);

Available Configs

Base

All others configs inherit from this one. It includes the ESLint recommended rules and TypeScript ESLint's recommended, strict, stylistic rules and their type checked counterparts.

Node

Just like Base, but also includes the Node globals

React

Includes eslint-plugin-react, eslint-plugin-react-hooks, eslint-plugin-jsx-a11y and eslint-plugin-react-compiler

Next

Includes all of React's plugins, and @next/eslint-plugin-next

Jest

Includes all of Base, and eslint-plugin-jest

Advanced Setup

Here's a kitchen sink example:

// eslint.configs.mjs
import config, { globals } from "@gurja/eslint-config";
import react from "@gurja/eslint-config/react";
import next from "@gurja/eslint-config/next";
import disableTypeChecking from "@gurja/eslint-config/disableTypeChecking";

export default config(
  // by default it uses the tsconfig.json at the same level as the eslint config file for type linting
  {
    files: ["packages/jquery-app/**/*.js"],
    languageOptions: {
      globals: globals.jquery,
    },
  },
  {
    files: ["packages/react-project/**/*.{ts,tsx}"],
    extends: react({ vite: true }),
  },
  {
    files: ["packages/next-project/**/*.{ts,tsx,js,jsx}"],
    extends: next,
    rules: {
      "react-compiler/react-compiler": "off", // customize your rules if you find it necessary
    },
  },
  disableTypeChecking, // you can disable type linting, make sure to user this at the end
);