Recipe: Basic ESLint and TypeScript Settings
This page describes how to set up Akitainu so that you can run ESLint and TypeScript type checking through Akitainu.
Install Packages
npm install -D akitainu akitainu-checker-eslint akitainu-checker-typescript eslint typescript
Set up .akitainurc.js
Define two rules in .akitainurc.js
as follows.
module.exports = {
rules: [
{
source: ["akitainu:source-static", {
files: ["./src/**/*.ts", "./src/**/*.tsx"]
}],
checker: "akitainu-checker-eslint"
},
{
source: ["akitainu:source-static", {
files: ["./src/**/*.ts", "./src/**/*.tsx"]
}],
checker: ["akitainu-checker-typescript", {
// relative to .akitainurc.js
tsconfig: "./tsconfig.json"
}]
}
]
}
Run Akitainu
Run Akitainu by any means you like. For example, you can register an npm script:
{
"scripts": {
"lint": "akitainu"
}
}
Running akitainu
will run both ESLint and TypeScript as specified.
This command exits with a non-zero exit code when there is any lint error.
Note: running TypeScript through akitainu
does not emit transpiled result. If you need transpiled result (e.g. you are not using Webpack, Babel or such to handle TypeScript source), you need to run tsc
separately.