Skip to content

Instantly share code, notes, and snippets.

@santoshshinde2012
Created May 29, 2024 06:14
Show Gist options
  • Save santoshshinde2012/29308ff5866f61a9d5dce64f4d670728 to your computer and use it in GitHub Desktop.
Save santoshshinde2012/29308ff5866f61a9d5dce64f4d670728 to your computer and use it in GitHub Desktop.
Setup eslint for typescript project

Step 1: Installation

npm install --save-dev eslint @eslint/js @types/eslint__js typescript typescript-eslint

Step 2: Configuration

  • We used the below configuration to configure eslint, and in our case, we are using the eslint.config.mjs file.
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
  {
    // config with just ignores is the replacement for `.eslintignore`
    ignores: ['**/build/**', '**/dist/**', 'coverage', 'docker'],
  },

  // recommended eslint config
  eslint.configs.recommended,

  // strict: a superset of recommended that includes more opinionated rules which may also catch bugs.
  ...tseslint.configs.strict,

  // stylistic: additional rules that enforce consistent styling without significantly catching bugs or changing logic.
  ...tseslint.configs.stylistic,
);

Step 3: Running ESLint

  • Add below script in package.json
"lint": "eslint .",
"lint-fix": "eslint --fix .",
  • Run Command
npm run lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment