4.0.0 • Published 11 months ago

@cruk/eslint-config v4.0.0

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

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-config

Monorepo 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 .
4.0.0

11 months ago

3.1.1

1 year ago

3.0.1

2 years ago

3.0.0

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago