Neutrino Typescript ESLint
Provides typescript integration with ESLint for neutrino projects.
ESLint replaces TSLint for linting TypeScript.
Existing JavaScript rules will be converted to support TypeScript, so you can combine this with base configurations
such as airbnb easily. See below for full details.
Installation
This package is intended for use with neutrinojs-typescript,
and any eslint
module (e.g. @neutrino/eslint
/ @neutrino/airbnb
/ etc.),
so you should already have those installed and configured.
-
Install dependencies:
npm install --save-dev neutrinojs-typescript-eslint
-
Include in .neutrinorc.js
:
const typescriptLint = require('neutrinojs-typescript-eslint');
module.exports = {
use: [
typescript(),
typescriptLint(),
eslint(),
node(),
],
};
-
Include type checking in package.json
scripts:
{
"scripts": {
"lint": "eslint --format codeframe --ext mjs,jsx,js,tsx,ts src test && tsc"
}
}
Note: if you are using eslint 7 or above, you can simplify the lint script:
{
"scripts": {
"lint": "eslint --format codeframe src test && tsc"
}
}
Options
typescriptLint({
typescriptFiles: ['*.ts', '*.tsx'],
recommended: true,
indent: false,
})
Note that indent
is false
by default due to
known issues with @typescript-eslint/indent.
Any unrecognised options are passed through to typescript-eslint-converter
.
Automatic rule conversion
This uses typescript-eslint-converter to
automatically convert Javascript rules to be TypeScript compatible.
All conversions only apply if an equivalent explicit configuration is not found.