@cruk/eslint-config
Version:
eslint rules for cruk typescript projects
111 lines (81 loc) • 3.46 kB
Markdown
These are settings for ESLint
This setup lints your JavaScript and TypeScript code based on the current recommended best practices.
- Node 22
- Node 24
```bash
npm i -D @cruk/eslint-config
```
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
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:
```js
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 .
```
1. Please update the version number in the package.json and follow the semver standards for version numbers.
2. Run `nvm use` to make sure that you are on the correct version of node.
3. Run `npm i` to make sure that the correct version in the lockfile.
4. Update the CHANGELOG.md which should list the changes for the release, instructions are at the bottom of the file.
5. These changes need to be merged into master.
1. Make sure that you have the correct permissions for the @cruk org on NPM.
2. 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.
3. Agree to all these steps release-it walks through and when Github opens up with the release click on the `Publish` button. If anything goes wrong release-it should roll back.
4. When it opens up github to create the release/tag, use auto generate to create the release notes.