@putstack/eslint-config-typescript v2.6.0
An ESLint configuration by Putro
This ESLint setup should let any new (or existing) projects adhere to best practices within TypeScript and write fewer bugs as a result! The default version is quite strict, so an existing project might opt for using the base version, see more under Usage.
Installation
To install this package run the following command in the terminal in the root directory of your application.
pnpm install -D @putstack/eslint-config-typescript
OR
npm install --save-dev @putstack/eslint-config-typescript
OR
yarn add -D @putstack/eslint-config-typescript
Usage
Ensure that your ESLint configuration is setup to utilize TypeScript's type checking API by following this guide. Note that if you're using this in a monorepo, you SHOULD keep "project":"true"
despite that the guide says otherwise.
Add this to your config by editing your .eslintrc.cjs or equivalent.
{
extends: ['@putstack/typescript'],
}
If the default is too strict on an existing project, you can also use the base
to exclude some of the more strict rules.
To see what is dincluded in which package, please view this section.
{
extends: ['@putstack/typescript/base']
}
Example
This project uses the configuration on itself, as seen in the root .eslintrc.cjs file.
ESLint rules
ESLint PLugins and Configurations
This is a list of the plugins and configurations that are extended from.
Base
Plugins
- @typescript-eslint/plugin - A large amount of TypeScript related ESLint rules, using the recommended type checking rules.
- eslint-plugin-progress - Report progress when running ESLint. Useful for large projects with thousands of files, so it's obvious that something is running!
- eslint-plugin-sonarjs - Code smell, bug detection, cognitive complexity and more.
- eslint-plugin-import - ESLint plugin with rules that help validate proper imports.
- eslint-import-resolver-typescript - This plugin adds
TypeScript
support toeslint-plugin-import
.
Configurations
- eslint:recommended - The set of rules which are recommended for all projects by the ESLint team, indicated by the ✅ on the rule list.
- plugin:@typescript-eslint/recommended-type-checked - To see a full list of the rules, click here.
- plugin:@typescript-eslint/stylistic-type-checked - To see a full list of the rules, click here.
- plugin:sonarjs/recommended - Using sonarjs recommended setup to catch general code smells.
- plugin:import/recommended - The set of import rules recommended by eslint-plugin-import.
- plugin:import/typescript - The set of import rules recommended by eslint-plugin-import for TypeScript.
Recommended
Recommended extends the base setup further to add additional rules, therefore it also includes all the rules above.
Plugins
- eslint-plugin-unicorn - This plugin provides more than 100 powerful ESLint rules of which many are auto-fixable making it easy to fix any issues that arise!