Opinionated ESLint config with sensible defaults.
npm install @nkzw/eslint-config
In your .eslintrc.js
or .eslintrc.cjs
:
module.exports = {
extends: ['@nkzw'],
};
Then run pnpm eslint .
or npm eslint .
.
Use this configuration if these principles resonate with you:
- Error, Never Warn: People tend to ignore warnings. There is little value in only warning about potentially problematic code patterns. Either it's an issue or not. Errors force the developer to address the problem either by fixing it or explicitly disabling the role in that location.
- Strict, consistent code style: If there are multiple ways of doing something, or there is a new language construct or best practice, this configuration will suggest the most strict and consistent solution.
- Prevent Bugs: Problematic patterns such as
instanceof
are not allowed. This forces developers to choose more robust patterns. This configuration disallows usage ofconsole
ortest.only
so that you don't end up with unintended logging in production or CI failures. If you want to log to the console in your production app, use another function that callsconsole.log
to distinguish between debug logs and intentional logs. - Fast: Slow rules are avoided if possible. For example, it is recommended to use the fast
noUnusedLocals
check in TypeScript instead of theno-unused-vars
rules. - Don't get in the way: Rules that get in the way or are too subjective are disabled. Rules with autofixers are preferred over rules without them.
This configuration consists of the most useful and least annoying rules from the following eslint plugins:
typescript-eslint
eslint-import-resolver-typescript
eslint-plugin-unicorn
eslint-plugin-import
eslint-plugin-sort-keys-fix
eslint-plugin-typescript-sort-keys
eslint-plugin-react
eslint-plugin-react-hooks
eslint-plugin-no-instanceof
eslint-plugin-no-only-tests
This configuration is meant to be used with:
- TypeScript and the
noUnusedLocals
setting. - Prettier and the
@ianvs/prettier-plugin-sort-imports
.