Home > Blockchain >  How to turn of semicolon error in a Eslint.js file and typescrip
How to turn of semicolon error in a Eslint.js file and typescrip

Time:11-20

I want to use semicolons in my typescript files, but eslint is giving me an error Extra semicolon.eslint@typescript-eslint/semi now I went to the docs and it tells me to put this in my eslint file

"rules": {
    // Note: you must disable the base rule as it can report incorrect errors
    "semi": "off",
    "@typescript-eslint/semi": "warn"
  }

The problem is that my eslint file is a .js file not a .json file so I can't put "@typescript-eslint/semi": "warn" because it gives me an error

Edit: this is the eslit.js file

module.exports = {
  env: {
    browser: true,
    es2021: true
  },
  extends: [
    'plugin:react/recommended',
    'plugin:react/jsx-runtime',
    'standard-with-typescript'
  ],
  overrides: [],
  parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
    project: ['./tsconfig.json']
  },
  plugins: ['react'],
  rules: {
    semi: 'off'
  }
};

CodePudding user response:

Just add it into rules, the exaclty same way
DO NOT FORGET THE QUOTES

  plugins: ['react'],
  rules: {
    semi: 'off',
    "@typescript-eslint/semi": "warn" // < just add it
  }
};
  • Related