ESLint 在 TypeScript 未能好好工作

ESLint 的提示在 TypeScript 下没有好好工作。

enum is defined but never used

// xxx is defined but never used. eslint(no-unused-vars)
export enum UserRole {
  USER = 'user',
  ADMIN = 'admin',
}

这时该使用 TypeScriptopen in new window 的规则取而代之:

module.exports = {
  // ...
  rules: {
    'no-unused-vars': 'off',
    '@typescript-eslint/no-unused-vars': 'error'
  }
}

Cannot read property 'loc' of undefined

参考 Cannot read property 'loc' of undefinedopen in new window 修改:

module.exports = {
  // ...
  rules: {
    'indent': 'off',
    '@typescript-eslint/indent': [
      'error',
      2
    ]
  }
}

Cannot read property 'body' of null

module.exports = {
  // ...
  rules: {
    'no-useless-constructor': 'off',
    '@typescript-eslint/no-useless-constructor': 'error'
  }
}