A monster against bad code
npm init @eslint/config@latestFollow the base instructions and choose the options you want.
npm install @guimauvedigital/eslint-plugin-safety --save-devUpdate your eslint.config.mjs file to add the plugin:
import globals from "globals"
import safety from "@guimauvedigital/eslint-plugin-safety"
export default [
{
files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"],
languageOptions: {
globals: {...globals.browser, ...globals.node},
parser: "@typescript-eslint/parser",
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
project: "./tsconfig.json",
},
}
},
...safety.configs.all,
// Optionally add more rules specific to your project
]There are good ideas taken from The long-tail of type safety | App.js Conf 2023.
Update tsconfig.json and add the following settings:
{
"compilerOptions": {
"strict": true,
"strictNullChecks": true,
"noUncheckedIndexedAccess": true
}
}Checkout typescript-eslint plugin for more TypeScript specific rules.
This is often already installed when you create a new project with npm init @eslint/config@latest if TypeScript is
selected. We include it in our all configuration.
ts-reset is a package that adds extra TypeScript checks about typings.
Install it with npm i -D @total-typescript/ts-reset and create a
reset.d.ts file:
// Do not add any other lines of code to this file!
import "@total-typescript/ts-reset"