@cruk/eslint-config
v5.0.0
Published
eslint rules for cruk typescript projects
Readme
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.
Compatability
- Node 22
- Node 24
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.
Example
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 .Releases
Pre-release
- Please update the version number in the package.json and follow the semver standards for version numbers.
- Run
nvm useto make sure that you are on the correct version of node. - Run
npm ito make sure that the correct version in the lockfile. - Update the CHANGELOG.md which should list the changes for the release, instructions are at the bottom of the file.
- These changes need to be merged into master.
Releasing
- Make sure that you have the correct permissions for the @cruk org on NPM.
- Run the release script with
npm run release
This should use release-it to allow you to select the same version number as stated in the package JSON and it should take care of the rest:
- it runs npm ci
- it does the build
- it makes and pushes the tag
- it releases the build lib to NPM
- it requests if you want to document the release on github and autogenerates the release notes.
- Agree to all these steps release-it walks through and when Github opens up with the release click on the
Publishbutton. If anything goes wrong release-it should roll back. - When it opens up github to create the release/tag, use auto generate to create the release notes.
