eslint- 插图型标注
对ESLint的TypeScript支持. (此还入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出入入入入入入入入入入入入入入入入入入入入入出入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入
以下内容为即将上映的1.0.0版. 请参见当前国家预防机制版本(0.14.0)的标签
安装
你首先需要安装 ESLint 语录数字 :
$ npm i eslint --save-dev
下一个,安装 typescript 如果你还没有做到:
$ npm i typescript@~3.1.1 --save-dev
最后安装 eslint-plugin-typescript数字 :
$ npm install eslint-plugin-typescript --save-dev
说明: 如果在全球安装了 ESLint(使用 -g 您必须安装 eslint-plugin-typescript 在全球.
使用量
添加 eslint-plugin-typescript/parser 页:1 parser 字段和 typescript 到您的插件区 .eslintrc 配置文件 :
{
"parser": "eslint-plugin-typescript/parser",
"plugins": ["typescript"]
}
注意: 插件提供了自己的版本 @typescript-eslint/parser 通过 eslint-plugin-typescript/parser。 。 。 .
这有助于我们保证插件和剖析器之间的100%兼容性 .
然后在规则章节下配置您想要使用的规则 .
{
"parser": "eslint-plugin-typescript/parser",
"plugins": ["typescript"],
"rules": {
"typescript/rule-name": "error"
}
}
您也可以同时启用所有推荐规则 。 添加 plugin:typescript/recommended 扩展中:
{
"extends": ["plugin:typescript/recommended"]
}
支持的规则
密钥: havy check mark:=推荐,:扳手:=可修复
| 名称 | 说明 | : 重度 检查 标记 : | :扳手: |
|---|---|---|---|
typescript/adjacent-overload-signatures | 要求成员连续超负荷(adjacent-overload-signatures 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/array-type | 需要使用其中之一 T[] 或者说 Array<T> 用于数组(array-type 从 TSLint 调取) | : 重度 检查 标记 : | :扳手: |
typescript/ban-types | 强制使用该类型(ban-types 从 TSLint 调取) | : 重度 检查 标记 : | :扳手: |
typescript/camelcase | 强制骆驼Case命名公约 | : 重度 检查 标记 : | |
typescript/class-name-casing | 需要PascalCased类和接口名称(class-name 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/explicit-function-return-type | 要求明确函数和分类方法的返回类型 | : 重度 检查 标记 : | |
typescript/explicit-member-accessibility | 要求对类属性和方法进行明确的无障碍修改(member-access 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/generic-type-naming | 强制命名通用类型变量 | ||
typescript/indent | 执行一致缩进indent 从 TSLint 调取) | : 重度 检查 标记 : | :扳手: |
typescript/interface-name-prefix | 要求接口名称前缀 I (单位:千美元)interface-name 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/member-delimiter-style | 界面和类型字符需要特定成员分隔符样式 | : 重度 检查 标记 : | :扳手: |
typescript/member-naming | 通过能见度对阶级成员实施命名公约. | ||
typescript/member-ordering | 要求一致的成员声明命令(member-ordering 从 TSLint 调取) | ||
typescript/no-angle-bracket-type-assertion | 强制使用 as Type 主张而不是 <Type> 断言(no-angle-bracket-type-assertion 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/no-array-constructor | 否定通用 Array 构造器 | : 重度 检查 标记 : | :扳手: |
typescript/no-empty-interface | 取消空接口声明( N)no-empty-interface 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/no-explicit-any | 放弃使用 any 类型(no-any 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/no-extraneous-class | 禁止使用类作为命名空间( E)no-unnecessary-class 从 TSLint 调取) | ||
typescript/no-inferrable-types | 将变量或参数初始化为数字、字符串或布尔的明示类型声明取消。 ()no-inferrable-types 从 TSLint 调取) | : 重度 检查 标记 : | :扳手: |
typescript/no-misused-new | 强制执行有效的定义 new 财务报告和审定财务报表 constructor. (中文(简体) )no-misused-new 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/no-namespace | 停止使用自定义的TypeScript模块和命名空间(no-namespace 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/no-non-null-assertion | 使用 ! 后缀运算符( e)no-non-null-assertion 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/no-object-literal-type-assertion | 禁止对象字词在类型断言表达式中出现(no-object-literal-type-assertion 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/no-parameter-properties | 取消在类构造器中使用参数属性。 ()no-parameter-properties 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/no-this-alias | 取消别名 this (单位:千美元)no-this-assignment 从 TSLint 调取) | ||
typescript/no-triple-slash-reference | 否定 /// <reference path="" /> 评论意见(no-reference 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/no-type-alias | 停止使用类型别名( N)interface-over-type-literal 从 TSLint 调取) | ||
typescript/no-unused-vars | 取消未使用的变量( E)no-unused-variable 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/no-use-before-define | 在定义变量之前停止使用变量 | : 重度 检查 标记 : | |
typescript/no-var-requires | 除导入语句外, 停止使用必要语句(no-var-requires 从 TSLint 调取) | : 重度 检查 标记 : | |
typescript/prefer-interface | 将界面声明置于类型文字之上(T = {.})(interface-over-type-literal 从 TSLint 调取) | : 重度 检查 标记 : | :扳手: |
typescript/prefer-namespace-keyword | 要求使用 namespace 关键词而不是 module 用于声明自定义类型脚本模块的关键字 。 ()no-internal-module 从 TSLint 调取) | : 重度 检查 标记 : | :扳手: |
typescript/type-annotation-spacing | 要求类型说明前后的相距一致(typedef-whitespace 从 TSLint 调取) | : 重度 检查 标记 : | :扳手: |