Linting

Lint your project with the command npm run lint

package.json:

"scripts": {
// ...
"ts-silent-build": "tsc --project ./tsconfig.json --noEmit",
"prelint": "npm run ts-silent-build",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"prelint-fix": "npm run ts-silent-build",
"lint-fix": "eslint --fix . --ext .js,.jsx,.ts,.tsx",
// ...
}

Implementation

HaTs projects are pre-configured to lint using @typescript-eslint/parser.

.eslintrc.json:

{
// ...
"parser": "@typescript-eslint/parser",
"parserOptions": {
"tsconfigRootDir": ".",
"project": ["tsconfig.json"]
}
}

Notice that the parserOptions.project property points to your project's tsconfig.json file. This setting enables your linting process to catch TypeScript warnings and errors, most notably strictNullChecks and noImplicitAny.

Further Reading

Edit this page on GitHub

Happy TypeScript
©2022 👨🏾‍💻 Kamar Mack