Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@mlaursen/eslint-config
Advanced tools
A reusable eslint config that I use for most of my projects.
Starting at 5.0.0
, I only support eslint@^9
or greater.
npm install -D eslint @mlaursen/eslint-config
Then create an eslint.config.mjs
with the following:
// @ts-check
import { config, configs, gitignore } from "@mlaursen/eslint-config";
// choose the config you want to use:
// somewhat strict type checking
export default config(gitignore(import.meta.url), ...configs.frontend);
// strict type checking
export default config(gitignore(import.meta.url), ...configs.frontendTypeChecking(import.meta.dirname));
// NOTE: This is recommended for strict type checking. Callable as:
// `cross-env STRICT_TYPING=true eslint "**/*.{ts,tsx,mts,mtsx,js,jsx,mjs,cjs}`
//
// strict type checking with an environment variable. uncomment the following
// line to enable it in your editor
// const strict = true || process.env.STRICT_TYPING === 'true';
const strict = process.env.STRICT_TYPING === 'true';
const frontend = strict ? configs.frontendTypeChecking(import.meta.dirname) : configs.frontend
export default (gitignore(import.meta.url), ...frontend);
The config
export is the typescript-eslint.config()
function to provide type
definitions and gitignore
automatically ignores files from linting based on
your .gitignore
rules.
I normally just use the frontend
or frontendTypeChecking
configs, but the
others can be used individually if needed.
The base config is automatically used by the typescript config and is just the eslint.configs.recommended
and a few other stylistic changes.
This should not be used if the typescript or typescriptTypeChecking configs are used.
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.base);
This extends the base config and the tseslint.configs.strict
config. It also includes a few stylistic choices for type
behavior and disabled strict rules in test files.
Only this rule or typescripttypechecking should be used. They should not be used together.
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.typescript);
This is the same as the typescript config but also includes the tseslint.configs.strictTypeCheckedOnly
config.
Only this rule or typescript should be used. They should not be used together.
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.typescriptTypeChecking(import.meta.dirname));
This only enables the eslint-plugin-jest.configs['flat/recommended]
rules on tests files.
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.jest);
This only enables the eslint-plugin-jest-dom.configs['flat/recommended]
rules on tests files.
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.jestDom);
This enables the eslint-plugin-testing-library/.configs["flat/react]
plugin and rules on test files.
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.testingLibraryReact);
This enables the eslint-plugin-testing-library/.configs["flat/dom]
plugin and rules on test files.
This should not be used with the testingLibraryReact rules
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.testingLibraryDom);
This enables the eslint-plugin-react
and eslint-plugin-react-hooks
:
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.react);
This enables eslint-plugin-jsx-a11y
:
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.jsxA11y);
This is a small wrapper around the @next/eslint-plugin-next
that works with eslint v9.
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.next);
This is my normal frontend repo setup with react
, jsxA11y
, jest
,
jest-dom
, typescript
, testing-library/react
.
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.frontend);
Same as the frontend, but enables the strict type checking.
// @ts-check
import { config, configs } from "@mlaursen/eslint-config";
export default config(...configs.frontendTypeChecking(import.meta.dirname));
5.2.0
Features:
Fixes:
@typescript-eslint/unified-signatures
since you get better type inference with separate signaturesno-undef
and removed globals since I use typescriptFAQs
An eslint config used by mlaursen for most projects.
We found that @mlaursen/eslint-config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.