简体   繁体   中英

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

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'
  }
};

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
  }
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM