兩個(gè)文章中找的蔬胯。什湘。。
rules: 規(guī)則
{
//ts專用
adjacent-overload-signatures : true, // Enforces function overloads to be consecutive.
ban-comma-operator:true, //禁止逗號(hào)運(yùn)算符竣贪。
ban-type: [true, ["object","User {} instead."],["string"]] //禁止類型
member-access: [true , "no-public"||"check-accessor"|| "check-constructor" || "check-parameter-property" ] , //類成員必須聲明 private public ....
member-order: [true, {order:....}], //類聲明排序
no-any: true,//不需使用any類型
no-empty-interface:true //禁止空接口 {}
no-import-side-effect: [true, {"ignore-module": "(\\.html|\\.css)$"}], //禁止導(dǎo)入帶有副作用的語句
no-inferrable-types:[true, "ignore-params", "ignore-properties"]研叫, //不允許將變量或參數(shù)初始化為數(shù)字,字符串或布爾值的顯式類型聲明关面。
no-internal-module:true坦袍, //不允許內(nèi)部模塊
no-magic-numbers: [true,1,2,3], //不允許在變量賦值之外使用常量數(shù)值。當(dāng)沒有指定允許值列表時(shí)等太,默認(rèn)允許-1,0和1
no-namespace: [ true,"allpw-declarations"], //不允許使用內(nèi)部modules和命名空間
no-non-null-assertion: true , //不允許使用!后綴操作符的非空斷言捂齐。
no-parameter-reassignment: true, //不允許重新分配參數(shù)
no-reference: true, // 禁止使用/// <reference path=> 導(dǎo)入 ,使用import代替
no-unnecessary-type-assertion: true, //如果類型斷言沒有改變表達(dá)式的類型就發(fā)出警告
no-var-requires: true, //不允許使用var module = require("module"),用 import foo = require('foo')導(dǎo)入
only-arrow-functions:[true缩抡,"allow-declarations"奠宜,"allow-named-functions"], //允許箭頭表達(dá)式,不需要傳統(tǒng)表達(dá)式 瞻想; 允許獨(dú)立的函數(shù)聲明 压真;允許表達(dá),function foo() {}但不是function() {}
prefer-for-of:true, //建議使用for(..of)
promise-function-async: true, 要求異步函數(shù)返回promise
typedef: [true, "call-signature", "parameter", "member-variable-declaration"], //需要定義的類型存在
typedef-whitespace: true, //類型聲明的冒號(hào)之前是否需要空格
unified-signatures: true, //重載可以被統(tǒng)一聯(lián)合成一個(gè)
//function 專用
await-promise: true, //警告不是一個(gè)promise的await
ban: [
true,
"eval",
{"name": "$", "message": "please don't"},
["describe", "only"],
{"name": ["it", "only"], "message": "don't focus tests"},
{
"name": ["chai", "assert", "equal"],
"message": "Use 'strictEqual' instead."
},
{"name": ["*", "forEach"], "message": "Use a regular for loop instead."}
],
curly: true, //for if do while 要有括號(hào)
forin:true, //用for in 必須用if進(jìn)行過濾
import-blacklist:true, //允許使用import require導(dǎo)入具體的模塊
label-postion: true, //允許在do/for/while/swith中使用label
no-arg:true, //不允許使用 argument.callee
no-bitwise:true, //不允許使用按位運(yùn)算符
no-conditional-assignmen: true, //不允許在do-while/for/if/while判斷語句中使用賦值語句
no-console:true, //不能使用console
no-construct: true, //不允許使用 String/Number/Boolean的構(gòu)造函數(shù)
no-debugger: true, //不允許使用debugger
no-duplicate-super: true, //構(gòu)造函數(shù)兩次用super會(huì)發(fā)出警告
no-empty:true, //不允許空的塊
no-eval: true, //不允許使用eval
no-floating-promises: true, //必須正確處理promise的返回函數(shù)
no-for-in-array: true, //不允許使用for in 遍歷數(shù)組
no-implicit-dependencies: true, //不允許在項(xiàng)目的package.json中導(dǎo)入未列為依賴項(xiàng)的模塊
no-inferred-empty-object-type: true蘑险, //不允許在函數(shù)和構(gòu)造函數(shù)中使用{}的類型推斷
no-invalid-template-strings: true, //警告在非模板字符中使用${
no-invalid-this:true, //不允許在非class中使用 this關(guān)鍵字
no-misused-new: true, //禁止定義構(gòu)造函數(shù)或new class
no-null-keyword: true, //不允許使用null關(guān)鍵字
no-object-literal-type-assertion:true, //禁止objext出現(xiàn)在類型斷言表達(dá)式中
no-return-await:true, //不允許return await
arrow-parens: true, //箭頭函數(shù)定義的參數(shù)需要括號(hào)
}
"quotemark":[true, "single","avoid-escape"], //引號(hào)的使用規(guī)則
"semicolon":[true, "never", "ignore-interfaces"], //分號(hào)的使用規(guī)則
"indent":[true, "tabs", 2], //使用Tab進(jìn)行縮進(jìn)滴肿,每次強(qiáng)制縮進(jìn)2個(gè)字符
"typedef-whitespace": false, //在類型定義的時(shí)候,是否允許使用空格, 使用false佃迄,表示不對(duì)此項(xiàng)進(jìn)行校驗(yàn),不啟用此項(xiàng)的校驗(yàn)
"whitespace": false, //空格的校驗(yàn)
"member-access": false, //類成員的顯示可見性聲明泼差,即顯示定義一個(gè)類的成員是否可見贵少,即對(duì)類成員定義public | static 等
"one-line": false, //要求指定的標(biāo)記與它們之前的表達(dá)式位于同一行
"trailing-comma": [true, { //對(duì)尾隨逗號(hào)的校驗(yàn)
"multiline": {
"objects": "ignore",
"arrays": "never",
"functions": "never",
"typeLiterals": "ignore"
},
"esSpecCompliant": true //是否允許尾隨逗號(hào)出現(xiàn)在剩余變量中
}]