@verkstedt/lint
v11.0.0
Published
Linting configuration for verkstedt projects
Readme
@verkstedt/lint
Linting configuration for verkstedt projects
Links
Technical design
See DESIGN.md.
Installation
Automatic
npx @verkstedt/lint@latest .Manual
Install:
npm install --save-dev eslint prettier @verkstedt/lintIf you are using TypeScript, also:
npm install --save-dev jitiMake your
tsconfig.jsonextend ours:{ "$schema": "https://json.schemastore.org/tsconfig", "extends": "@verkstedt/lint/tsconfig",Create
prettier.config.ts(orprettier.config.mjs)export { default as default } from '@verkstedt/lint/prettier';…and an empty
.prettierignore:touch .prettierignore[!NOTE] EsLint is set up to also use Prettier, so you don’t have to run it separately, but you can, if you e.g. want to do just the formatting in your editor.
Create
eslint.config.ts(oreslint.config.mjs)import { createVerkstedtConfig } from '@verkstedt/lint/eslint'; import { defineConfig } from 'eslint/config'; export default defineConfig([ await createVerkstedtConfig({ dir: import.meta.dirname, // If you have TypeScript files that are NOT included in your tsconfig (e.g. // config files or scripts), you specify them here. // https://typescript-eslint.io/packages/parser/#allowdefaultproject allowDefaultProject: ['*.config.*'], // Custom config for no-restricted-imports rule // https://eslint.org/docs/latest/rules/no-restricted-imports noRestrictedImportsConfig: {}, }), ]);
Migration from @verkstedt/eslint-config-verkstedt
Remove all
*eslint*,*prettier*and*stylelint*packages you have installed and remove old Prettier and EsLint config files.Commit as something like “chore: Remove old linting config”.
Run the script from Automatic installation above.
Commit.
Run
eslint --fixCommit.
Fix any remaining linting errors and commit.
Check if you need to restore any of customisation you had in your old config files (they may be included in new config files!). Consider not adding things back to keep config consistent across projects.
[!NOTE] In some codebases, you may get a lot of errors from
@typescript-eslint/no-explicit-anyand@typescript-eslint/no-unsafe-*rules. Best approach is to temporarily disable them and merge new config like that, but plan to refactor the codebase to enable them back.
First run
npx eslint .Running this for the first time might ask you to install some additional packages.
Tests
Tests are organised as separate packages. They are set up as npm workspaces.
Running npm test will run eslint in all workspace test
packages.
Debugging
Run with NODE_DEBUG=@verkstedt/lint to see some debug logs.
Known caveats
No accessibility (
jsx-a11y) rules for now.eslint-plugin-jsx-a11yhas not yet shipped ESLint 10 support; the upstream PR is open at https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/1081. Once that lands we will apply itsrecommendedconfig wheneverisFrontendis true. Also remove uninstalling the plugin ininstall.sh.Installation script overwrites
extendsintsconfig.json. If your project already extends something you should copy options from./typescript/tsconfig.base.jsonto yourtsconfigand keep yourextendsas it is.TypeScript is pinned to
^6.0.3 <6.1.0(in bothpeerDependenciesanddevDependencies). This may look surprising, buttypescript-eslintcaps itstypescriptpeer at<6.1.0, so we mirror that range here to keepnpm installresolving cleanly. Once atypescript-eslintrelease widens the cap, we can match it.
