eslint-config
ESLint rules used by Lumar (formerly DeepCrawl).
Installation
Add eslint-config-deepcrawl and its peer dependencies to your package.json:
yarn add --dev \
eslint-config-deepcrawl \
eslint@^10.0.0
Usage
Update your eslint.config.mjs file:
import eslintConfigDeepcrawl from "eslint-config-deepcrawl";
export default [...eslintConfigDeepcrawl];
Recommendations
TypeScript
Have these options enabled in your tsconfig.json file:
{
"compilerOptions": {
"noImplicitAny": true,
"strictPropertyInitialization": true
}
}
or enable @typescript-eslint/typedef rule.
Prettier
Apart from ESLint, it is recommended to use the following Prettier configuration:
{
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "lf",
"plugins": ["prettier-plugin-packagejson"],
"printWidth": 120,
"quoteProps": "as-needed",
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}
with lint-staged pre-commit hook done via husky.
Migrating from v16
v17 replaces eslint-plugin-jest with @vitest/eslint-plugin. To upgrade:
Rename every
jest/*rule reference in youreslint.config.*tovitest/*. For example,"jest/expect-expect"becomes"vitest/expect-expect". ESLint silently ignores unknown rule names set to"off", so if you miss a rename, your override stops working without an error.If you still use Jest, the same rules lint Jest tests, because the test APIs are largely compatible. However, these rules are gone:
no-deprecated-functions,no-exportandno-jasmine-globalshave no Vitest equivalent, andvitest/no-done-callbackis deprecated because Vitest does not supportdonecallbacks. The Jest-only globals (jest,fit,xit,xtest,xdescribe) are no longer declared either.@typescript-eslint/unbound-methodis replaced byvitest/unbound-methodin TypeScript files. The Vitest rule reports the same problems but allows passing a method toexpect()(for exampleexpect(client.getAccount).toHaveBeenCalled()) and tovi.mocked(). Rename anyeslint-disablecomments and config overrides for@typescript-eslint/unbound-methodtovitest/unbound-method. Remove the disable comments that only worked around mock expectations. Old disable comments are reported as unused.Vitest globals are required.
vitest/no-importing-vitest-globalsreports imports ofdescribe,it,expect,viand the other globals fromvitest. Type imports such asMockare still allowed. Enable globals in your Vitest config and add the global types to yourtsconfig.json:// vitest.config.ts export default defineConfig({ test: { globals: true } });{ "compilerOptions": { "types": ["vitest/globals"] } }eslint --fixremoves the imports.Tests must use
it, nottest, both at the top level and insidedescribe(vitest/consistent-test-it).eslint --fixrenames them.These rules are new. Most of them can be fixed with
eslint --fix:- From the Vitest recommended preset:
vitest/no-import-node-test,vitest/no-unneeded-async-expect-function,vitest/prefer-called-exactly-once-withandvitest/require-local-test-context-for-concurrent-snapshots. - Added by this config:
vitest/no-test-return-statement,vitest/prefer-comparison-matcher,vitest/prefer-equality-matcher,vitest/prefer-hooks-in-order,vitest/prefer-hooks-on-top,vitest/prefer-mock-promise-shorthand,vitest/prefer-to-contain,vitest/prefer-to-have-length,vitest/prefer-todo,vitest/prefer-vi-mockedandvitest/require-awaited-expect-poll.
- From the Vitest recommended preset:
Migrating from v15
v16.0.0 fixed the @stylistic/max-len ignore pattern, which had been
exempting every line, so long lines started to report errors. v16.0.1 then
removed @stylistic/max-len altogether and left line length to Prettier.
If you upgrade straight to v16.0.1 or later, you don't need to change
anything. If you added overrides to work around v16.0.0, you can remove them.
Migrating from v14
v15 upgrades to ESLint 10 and replaces eslint-plugin-import with its
maintained fork eslint-plugin-import-x. To upgrade:
- Bump
eslintto^10.0.0(drop ESLint 9). - Rename every
import/*rule reference in youreslint.config.*toimport-x/*— e.g."import/no-default-export"→"import-x/no-default-export". ESLint silently ignores unknown rule names set to"off", so a missed rename turns into a silent loss of your override. - Remove
@types/eslint__jsfrom yourdevDependenciesif you have it —@eslint/js@10now ships its own type definitions.
No other consumer changes are required; the rest of the ruleset is unchanged.