Linting configuration for verkstedt projects
See DESIGN.md.
npx @verkstedt/lint@latest .Details
-
Install:
npm install --save-dev eslint prettier @verkstedt/lint
If you are using TypeScript, also:
npm install --save-dev jiti
-
Make 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: {}, }), ]);
Details
-
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 --fix -
Commit.
-
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.
This package does not use the TypeScript API itself and works with
whichever typescript your project installs. typescript-eslint,
however, still needs the TypeScript 6 API. To lint a TypeScript 7
project, install both, using the aliases recommended by the TypeScript
team:
npm install --save-dev typescript@npm:@typescript/typescript6 @typescript/native@npm:typescript@7This gives you:
tscfrom TypeScript 7 (via@typescript/native), used by your build and type checkstypescriptresolving to the TypeScript 6 API (via@typescript/typescript6), used bytypescript-eslintand editorstsc6if you ever need the TypeScript 6 compiler explicitly
Both TypeScript versions declare a tsc binary and npm links whichever
it installs last. If npx tsc --version reports TypeScript 6 after
adding the aliases, run a clean install (npm ci) to get TypeScript 7.
Editors that load node_modules/typescript will find only the API
re-export there, without the bundled lib.*.d.ts files. Point your
editor’s TypeScript at node_modules/@typescript/old (TypeScript 6)
or node_modules/@typescript/native (TypeScript 7) instead.
Note
TODO When typescript-eslint version with TypeScript 7
support ships, remove this section.
npx eslint .Running this for the first time might ask you to install some additional packages.
Tests are organised as separate packages. They are set up as npm workspaces.
Running npm test will run eslint in all workspace test
packages.
To check how the current config behaves in real projects, run
npm run test-consumers. It clones every repository in the verkstedt
GitHub organisation that depends on @verkstedt/lint, installs this
working copy into each of them and runs eslint.
Run with NODE_DEBUG=@verkstedt/lint to see some debug logs.
-
No accessibility (
jsx-a11y) rules for now.eslint-plugin-jsx-a11yhas not yet shipped ESLint 10 support; the upstream PR is open at jsx-eslint/eslint-plugin-jsx-a11y#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.
- GHSA-238p-pmpm-9mq7
katex - GHSA-vfj7-8cjw-p6xm
braces- no update path exists, disputed by the library author
- doesn’t affect us, as we only match patterns we write ourselves
npm audit fix --forcedowngradeseslint-plugin-lingui