JavaScript/typescript:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第7行: 第7行:
</syntaxhighlight>}}
</syntaxhighlight>}}
=== 配置 ===
=== 配置 ===
===  AlloyTeam ESLint ===
{{shc|<syntaxhighlight lang="bash">
npm install --save-dev eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-alloy</syntaxhighlight>|$}}
=== 部署配置 ===
{{hc|.eslintrc.js|<syntaxhighlight lang="javascript">
{{hc|.eslintrc.js|<syntaxhighlight lang="javascript">
module.exports = {
module.exports = {
  parser: 'typescript-eslint-parser',
     extends: [
  plugins: [
        'alloy',
    'typescript'
        'alloy/typescript',
  ],
  rules: {
     // @fixable 必须使用 === 或 !==,禁止使用 == 或 !=,与 null 比较时除外
    'eqeqeq': [
      'error',
      'always', {
        null: 'ignore'
      }
     ],
     ],
     // 类和接口的命名必须遵守帕斯卡命名法,比如 PersianCat
     env: {
     'typescript/class-name-casing': 'error'
        // 您的环境变量(包含多个预定义的全局变量)
  }
        // Your environments (which contains several predefined global variables)
}</syntaxhighlight>}}
        //
        // browser: true,
        // node: true,
        // mocha: true,
        // jest: true,
        // jquery: true
     },
    globals: {
        // 您的全局变量(设置为 false 表示它不允许被重新赋值)
        // Your global variables (setting to false means it's not allowed to be reassigned)
        //
        // myGlobal: false
    },
    rules: {
        // 自定义您的规则
        // Customize your rules
    }
};</syntaxhighlight>}}

2020年8月2日 (日) 12:31的版本

引言

eslint

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

配置

AlloyTeam ESLint

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

部署配置

.eslintrc.js
module.exports = {
    extends: [
        'alloy',
        'alloy/typescript',
    ],
    env: {
        // 您的环境变量(包含多个预定义的全局变量)
        // Your environments (which contains several predefined global variables)
        //
        // browser: true,
        // node: true,
        // mocha: true,
        // jest: true,
        // jquery: true
    },
    globals: {
        // 您的全局变量(设置为 false 表示它不允许被重新赋值)
        // Your global variables (setting to false means it's not allowed to be reassigned)
        //
        // myGlobal: false
    },
    rules: {
        // 自定义您的规则
        // Customize your rules
    }
};