@lunit/eslint-config
A TypeScript ESLint ruleset designed for Lunit projects based on @rushstack/eslint-config.
This ESLint configuration is only available for TypeScript projects.
Installation
npm install --save-dev @lunit/eslint-config
Usage
Getting Started
@lunit/eslint-config v2.x is configured using the ESLint Flat Config approach.
For information regarding ESLint Flat Config, please refer to the relevant ESLint Blog post.
To use it, add @lunit/eslint-config to your eslint.config.js file as follows.
If you are using TypeScript ESLint rules, please remove them.
This is already being used in Rushstack ESLint, causing conflict issues.
ESM
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import { defineConfig, globalIgnores } from "eslint/config";
import eslintConfig from '@lunit/eslint-config';
export default defineConfig([
globalIgnores(["dist"]),
{
files: ["**/*.{ts,tsx}"],
extends: [
js.configs.recommended,
reactHooks.configs.flat["recommended-latest"],
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
lunitEslintConfig,
]);
CommonJS
const js = require("@eslint/js");
const globals = require("globals");
const reactHooks = require("eslint-plugin-react-hooks");
const reactRefresh = require("eslint-plugin-react-refresh");
const { defineConfig, globalIgnores } = require("eslint/config");
const lunitEslintConfig = require('@lunit/eslint-config');
module.exports = defineConfig([
globalIgnores(["dist"]),
{
files: ["**/*.{ts,tsx}"],
extends: [
js.configs.recommended,
reactHooks.configs.flat["recommended-latest"],
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
lunitEslintConfig,
]);
If you created the app using vite,
please refer to the information below.
If the tsconfig.json file is separate and the actual rules are applied in tsconfig.app.json,
please configure it as follows.
rushstack eslint config internally follows the rules set in tsconfig,
so you must link the corresponding JSON file.
ESM
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import { defineConfig, globalIgnores } from "eslint/config";
import eslintConfig from '@lunit/eslint-config';
export default defineConfig([
globalIgnores(["dist"]),
{
files: ["**/*.{ts,tsx}"],
extends: [
js.configs.recommended,
reactHooks.configs.flat["recommended-latest"],
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
{
...eslintConfig,
languageOptions: {
parserOptions: {
project: ["./tsconfig.app.json"],
tsconfigRootDir: import.meta.dirname,
},
},
}
]);
CommonJS
const js = require("@eslint/js");
const globals = require("globals");
const reactHooks = require("eslint-plugin-react-hooks");
const reactRefresh = require("eslint-plugin-react-refresh");
const { defineConfig, globalIgnores } = require("eslint/config");
const lunitEslintConfig = require('@lunit/eslint-config');
module.exports = defineConfig([
globalIgnores(["dist"]),
{
files: ["**/*.{ts,tsx}"],
extends: [
js.configs.recommended,
reactHooks.configs.flat["recommended-latest"],
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
{
...lunitEslintConfig,
languageOptions: {
parserOptions: {
project: ["./tsconfig.app.json"],
tsconfigRootDir: __dirname,
},
},
}
]);
Advanced
Override rushstack eslint rule
If you wish to modify the Rushstack ESLint rule, please refer to the code below.
ESM
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import { defineConfig, globalIgnores } from "eslint/config";
import eslintConfig from '@lunit/eslint-config';
export default defineConfig([
globalIgnores(["dist"]),
{
files: ["**/*.{ts,tsx}"],
extends: [
js.configs.recommended,
reactHooks.configs.flat["recommended-latest"],
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
{
...lunitEslintConfig,
rules: {
...lunitEslintConfig.rules,
'@rushstack/no-new-null': 'error',
},
}
]);
CommonJS
const js = require("@eslint/js");
const globals = require("globals");
const reactHooks = require("eslint-plugin-react-hooks");
const reactRefresh = require("eslint-plugin-react-refresh");
const { defineConfig, globalIgnores } = require("eslint/config");
const lunitEslintConfig = require('@lunit/eslint-config');
module.exports = defineConfig([
globalIgnores(["dist"]),
{
files: ["**/*.{ts,tsx}"],
extends: [
js.configs.recommended,
reactHooks.configs.flat["recommended-latest"],
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
{
...lunitEslintConfig,
rules: {
...lunitEslintConfig.rules,
'@rushstack/no-new-null': 'error',
},
}
]);
Migrate 1.x to 2.x
Since migration to the ESLint flat config is required,
please refer to the official ESLint documentation guide below.