JavaScript/typescript

来自康健生活
Kangkk​(留言 | 贡献)2020年8月2日 (日) 10:54的版本 (→eslint)

引言

eslint

 
npm install eslint --save-dev
npm install --save-dev typescript @typescript-eslint/parser
npm install --save-dev @typescript-eslint/eslint-plugin

配置

.eslintrc.js
module.exports = {
  parser: 'typescript-eslint-parser',
  plugins: [
    'typescript'
  ],
  rules: {
    // @fixable 必须使用 === 或 !==,禁止使用 == 或 !=,与 null 比较时除外
    'eqeqeq': [
      'error',
      'always', {
        null: 'ignore'
      }
    ],
    // 类和接口的命名必须遵守帕斯卡命名法,比如 PersianCat
    'typescript/class-name-casing': 'error'
  }
}