sajad torkamani

Install packages (remove eslint-config-prettier if not using prettier):

npm i -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-prettier

Init config file:

npx eslint --init

Edit config file:

module.exports = {
  env: {
    node: true,
  extends: [
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
  plugins: ['@typescript-eslint'],
  rules: {},

Add NPM script:

"scripts": { 
  "lint": "eslint . --ext .js,.ts"

Run ESLint:

npm run lint

Setup eslint-plugin-unused-imports

Install package:

npm i -D eslint-plugin-unused-imports

Add to plugins (keep other entries) in your ESLint config:

  "plugins": ["unused-imports"]

Add the following to the rules field:

"unused-imports/no-unused-imports": "warn", 
"unused-imports/no-unused-vars": [
        "vars": "all",
        "varsIgnorePattern": "^_",
        "args": "after-used",
        "argsIgnorePattern": "^_"

Setup eslint-plugin-simple-import-sort

Install package:

npm install --save-dev eslint-plugin-simple-import-sort

Configure .eslintrc:

  "plugins": ["simple-import-sort"],
  "rules": {
    "simple-import-sort/imports": "error",
    "simple-import-sort/exports": "error"
  "parserOptions": {
    "sourceType": "module",
    "ecmaVersion": "latest"

Leave a comment

Your email address will not be published. Required fields are marked *