ESLint configuration for TypeScript
MIT License
Shared linting configuration.
First, install ESLint and this plugin:
$ npm i -D eslint @mtth/eslint-plugin
Then reference this plugin in .eslintrc.js
:
module.exports = {
plugins: ['@mtth'],
extends: ['plugin:@mtth/typescript'], // One of the configurations below.
// Project-specific configuration...
};
typescript
, defaults for a TypeScript project. The corresponding parser isThis plugin is best used in combination with this prettier configuration and the following convenience scripts:
{
"fix": "npm run pretty && npm run lint -- --fix",
"lint": "eslint '{src,test}/**/*.{ts,tsx}'",
"pretty": "prettier --write '{src,test}/**/*.{ts,tsx}'"
}
We also recommend enabling pre-commit hooks with husky
and lint-staged
. For
example, within your package.json
:
{
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.ts": [
"prettier --write",
"eslint --fix"
]
}
}