Set of TypeScript rules for eslint.
On your TypeScript application,
-
Install the necessary dependencies:
npm i -D eslint eslint-import-resolver-typescript eslint-config-oschweitzer eslint-config-prettier eslint-plugin-import eslint-plugin-prettier prettier @typescript-eslint/eslint-plugin @typescript-eslint/parser
-
Create a file named
.eslintrc.js
and paste the following codemodule.exports = { extends: ['eslint-config-oschweitzer'] };
-
Add a .prettierrc file in the root directory with the following content
{ "singleQuote": true, "trailingComma": "all" }
-
In your package.json, add these two scripts lines:
{ ... "scripts": { ... "lint": "npx eslint . --ext .ts,.tsx", "lint:fix": "npx eslint --fix . --ext .ts,.tsx", ... }, ... }
Now run npm run lint
to check if everything went well.
This linter will not work on JavaScript code.