tslint.json的配置項說明

tslint.json的配置項說明css

 
extends: 內設配置項名稱
rules: 規則
{
//ts專用
adjacent- overload- signaturestrue, // Enforces function overloads to be consecutive.
ban- comma- operatortrue, //禁止逗號運算符。
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) $"}], //禁止導入帶有反作用的語句
no- inferrable- types:[ true, "ignore-params", "ignore-properties"], //不容許將變量或參數初始化爲數字,字符串或布爾值的顯式類型聲明。
no- internal- module: true//不容許內部模塊
no- magic- numbers: [ true,1,2,3], //不容許在變量賦值以外使用常量數值。當沒有指定容許值列表時,默認容許-1,0和1
no- namespace: [ true, "allpw-declarations"], //不容許使用內部modules和命名空間
no- non- null- assertion: true , //不容許使用!後綴操做符的非空斷言。
no- parameter- reassignment: true, //不容許從新分配參數
no- reference: true, // 禁止使用/// <reference path=> 導入 ,使用import代替
no- unnecessary- type- assertiontrue, //若是類型斷言沒有改變表達式的類型就發出警告
no- var- requirestrue, //不容許使用var module = require("module"),用 import foo = require('foo')導入
only- arrow- functions:[ true"allow-declarations""allow-named-functions"], //容許箭頭表達式,不須要傳統表達式 ; 容許獨立的函數聲明 ;容許表達,function foo() {}但不是function() {}
prefer- for- of: true, //建議使用for(..of)
promise- function- async: true, 要求異步函數返回promise
typedef: [ true, "call-signature", "parameter", "member-variable-declaration"], //須要定義的類型存在
typedef- whitespacetrue, //類型聲明的冒號以前是否須要空格
unified- signaturestrue, //重載能夠被統一聯合成一個

//function 專用
await- promisetrue, //警告不是一個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 要有括號
forin: true, //用for in 必須用if進行過濾
import- blacklist: true, //容許使用import require導入具體的模塊
label- postion: true, //容許在do/for/while/swith中使用label
no- arg: true, //不容許使用 argument.callee
no- bitwise: true, //不容許使用按位運算符
no- conditional- assignmen: true, //不容許在do-while/for/if/while判斷語句中使用賦值語句
no- consoletrue, //不能使用console
no- construct: true, //不容許使用 String/Number/Boolean的構造函數
no- debuggertrue, //不容許使用debugger
no- duplicate- super: true, //構造函數兩次用super會發出警告
no- empty: true, //不容許空的塊
no- eval: true, //不容許使用eval
no- floating- promises: true, //必須正確處理promise的返回函數
no- for- in- array: true, //不容許使用for in 遍歷數組
no- implicit- dependencies: true, //不容許在項目的package.json中導入未列爲依賴項的模塊
no- inferred- empty- object- typetrue//不容許在函數和構造函數中使用{}的類型推斷
no- invalid- template- stringstrue, //警告在非模板字符中使用${
no- invalid- thistrue, //不容許在非class中使用 this關鍵字
no- misused- new: true, //禁止定義構造函數或new class
no- null- keyword: true, //不容許使用null關鍵字
no- object- literal- type- assertiontrue, //禁止objext出如今類型斷言表達式中
no- return- awaittrue, //不容許return await
arrow- parenstrue, //箭頭函數定義的參數須要括號
}
 
 

 

  
  "quotemark":[true, "single","avoid-escape"], //引號的使用規則
  "semicolon":[true, "never", "ignore-interfaces"], //分號的使用規則
  "indent":[true, "tabs", 2], //使用Tab進行縮進,每次強制縮進2個字符
  "typedef-whitespace": false, //在類型定義的時候,是否容許使用空格, 使用false,表示不對此項進行校驗,不啓用此項的校驗
  "whitespace": false, //空格的校驗
  "member-access": false, //類成員的顯示可見性聲明,即顯示定義一個類的成員是否可見,即對類成員定義public | static 等
  "one-line": false, //要求指定的標記與它們以前的表達式位於同一行
  "trailing-comma": [true, { //對尾隨逗號的校驗
  "multiline": {
  "objects": "ignore",
  "arrays": "never",
  "functions": "never",
  "typeLiterals": "ignore"
  },
  "esSpecCompliant": true //是否容許尾隨逗號出如今剩餘變量中
  }]
相關文章
相關標籤/搜索