@cruk/eslint-config v4.0.0
ESLint config
These are settings for ESLint
What it does
This setup lints your JavaScript and TypeScript code based on the current recommended best practices.
Installation
NPM
npm i -D @cruk/eslint-configMonorepo installation
If you are using a monorepo tool like NX with nx run many -t=eslint then you need to install dependencies for eslint in the root.
If you are using a monorepo tool like npm workspaces with npm run eslint --ws --if-present then you will need to install the eslint dependencies in each package
Configuration
Create (or update) an eslint.config.mjs file in the root of your repo or if you have a mono repo in the root of each package. This is especially recommended if you have a large monorepo with many packages because running eslint on all packages at the same time could exceed JS heap size limits.
Kitchen sink expample where older configs are also included using some compatability tools:
import { FlatCompat } from "@eslint/eslintrc";
import tsParser from "@typescript-eslint/parser";
import path from "path";
import { fileURLToPath } from "url";
import { fixupConfigRules } from "@eslint/compat";
import { config as crukConfig } from "@cruk/eslint-config";
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename); // get the name of the directory
const compat = new FlatCompat({
// import.meta.dirname is available after Node.js v20.11.0
baseDirectory: import.meta.dirname,
});
const config = [
...crukConfig,
...compat.config({
extends: ["next"],
settings: {
next: {
rootDir: ".",
},
},
}),
{
languageOptions: {
parser: tsParser,
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
},
},
rules: {
"@next/next/no-img-element": "off",
},
files: ["src/**/*.ts", "src/**/*.tsx", "playwright/**/*.ts"],
ignores: [".next", ".swc", "test-results", "node_modules"],
},
];
export default fixupConfigRules(config);You can test your setup is correct by running
npx eslint --fix-dry-run .11 months ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago