关于vscode的使用技巧,可参考官网http://code.visualstudio.com/docs,user guide
1.tslint设置常用检测规则
参数吗 | 默认值 | 说明 |
---|---|---|
max-line-length | 120 | 一行允许最大的120个字符 |
one-line | true,"check-open-brace","check-catch","check-else","check-whitespace" | 检测大括号、catch语句、else语句、空格换行前要用空格 |
prefer-const | true | 检测是否可以优先使用const |
quotemark | true,"single" | 检测引号必须是单引号 |
semicolon | "always" | 要求必须以分号结尾,可改为false |
triple-equals | true,"allow-null-check" | 三目运算符空值检测 |
whitespace | true,"check-branch","check-decl","check-operator","check-separator","check-type" | 运算符、操作符、分隔符、类型声明要空格检测 |
component-selector | true,"element", "app", "kebab-case" | 组件选择器检测 |
member-ordering | true,"static-before-instance","variables-before-functions" | 组件内变量位置检测 |
comment-format | true,"check-space" | 注释规范,注释前要求空格 |
no-inferrable-types | true, "ignore-params" | 已赋值的变量不需要再加类型声明 |
typedef-whitespace | true,{"call-signature": "nospace","index-signature": "nospace","parameter": "nospace","property-declaration": "nospace","variable-declaration": "nospace"} | 加空格的规则检测 |
curly | true | 语句要求用大括号括起来 |
triple-equals | true | 要求用三个等号 |
no-unused-expression | true | 三目运算检测 |
取消检测改false即可
参数吗 | 默认值 | 说明 |
---|---|---|
max-line-length | 120 | 一行允许最大的120个字符 |
one-line | true,"check-open-brace","check-catch","check-else","check-whitespace" | 检测大括号、catch语句、else语句、空格换行前要用空格 |
prefer-const | true | 检测是否可以优先使用const |
quotemark | true,"single" | 检测引号必须是单引号 |
semicolon | "always" | 要求必须以分号结尾,可改为false |
triple-equals | true,"allow-null-check" | 三目运算符空值检测 |
whitespace | true,"check-branch","check-decl","check-operator","check-separator","check-type" | 运算符、操作符、分隔符、类型声明要空格检测 |
component-selector | true,"element", "app", "kebab-case" | 组件选择器检测 |
member-ordering | true,"static-before-instance","variables-before-functions" | 组件内变量位置检测 |
comment-format | true,"check-space" | 注释规范,注释前要求空格 |
no-inferrable-types | true, "ignore-params" | 已赋值的变量不需要再加类型声明 |
typedef-whitespace | true,{"call-signature": "nospace","index-signature": "nospace","parameter": "nospace","property-declaration": "nospace","variable-declaration": "nospace"} | 加空格的规则检测 |
curly | true | 语句要求用大括号括起来 |
triple-equals | true | 要求用三个等号 |
no-unused-expression | true | 三目运算检测 |
小技巧:
鼠标移动到tsling检测提示语句上,会弹出tslint检测结果,括号中显示的即为检测规则,如果想取消相应的检测规则,就可以在tslint.json中去掉
2.Settings Sync设置同步
功能:在不同电脑上的vscode之间同步vscode的设置
1)生成Github key
打开github账号进入Settings / Personal Access Tokens / Generate New Token
输入token名并选中gist后,点击按钮generate token
复制新生成的token。
2)打开vscode
按f1后输入sync
选择红色框中这一列后会弹出一个输入框,将复制的token黏贴进去后回车。
在其他电脑上的vscode也执行统一操作(确保是同一个token),就可以实现设置同步
debug for chrome
VS Code 1.14发布,可以直接Debug Angular应用了,推荐网页:
https://damoqiongqiu.github.io/web%E5%89%8D%E7%AB%AF/2017/07/12/debug-angular-inside-vscode.html