Pedro
Pedro

Reputation: 21

ESLint says that semicolons are missing even after adding them

I have the following typescript interface on my project:

`

export default interface User {
    avatar: string;
    email: string;
    name: string;
}

`

After formatting with Prettier, ESLint keeps telling me that there are missing semicolons at the end of the code, now formatted like this:

`

export default interface User {
    avatar: string;
    cpf: string;
    email: string;
    name: string;
};;;;;;;;;;;

`

I could keep formatting and saving forever and it would still add semicolons at the end of that line

I have the following .eslintrc in my project

`

 module.exports = {
  env: {
    browser: true,
    es6: true
  },
  extends: [
    'plugin:react/recommended',
    'standard'
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly'
  },
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaFeatures: {
      jsx: true
    },
    ecmaVersion: 2018,
    sourceType: 'module'
  },
  plugins: [
    'react',
    '@typescript-eslint'
  ],
  rules: {
    "semi": [2, "always"]
  }
}

`

Upvotes: 2

Views: 5210

Answers (2)

Klemen Košir
Klemen Košir

Reputation: 266

I filed the issue at https://github.com/typescript-eslint/typescript-eslint/issues/1695, and they responded that this is expected behavior, as you need to disable semi, and enable @typescript-eslint/semi instead.

Upvotes: 4

Benoit Messiaen
Benoit Messiaen

Reputation: 224

I always use semi rules as never. See documentation here

module.exports = {
  env: {
    browser: true,
    es6: true
  },
  extends: [
    'plugin:react/recommended',
    'standard'
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly'
  },
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaFeatures: {
      jsx: true
    },
    ecmaVersion: 2018,
    sourceType: 'module'
  },
  plugins: [
    'react',
    '@typescript-eslint'
  ],
  rules: {
    "semi": [2, "never"]
  }
}

Not sure if one is better than the other, but in your case it should patch your problem. I'm surprised it is on always; did you set it yourself?

Upvotes: -1

Related Questions