extends:
內設配置項名稱
rules:
規則
{
//ts專用
adjacent-
overload-
signatures :
true,
// Enforces function overloads to be consecutive.
ban-
comma-
operator:
true,
//禁止逗號運算符。
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-
assertion:
true,
//若是類型斷言沒有改變表達式的類型就發出警告
no-
var-
requires:
true,
//不容許使用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-
whitespace:
true,
//類型聲明的冒號以前是否須要空格
unified-
signatures:
true,
//重載能夠被統一聯合成一個
//function 專用
await-
promise:
true,
//警告不是一個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-
console:
true,
//不能使用console
no-
construct:
true,
//不容許使用 String/Number/Boolean的構造函數
no-
debugger:
true,
//不容許使用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-
type:
true,
//不容許在函數和構造函數中使用{}的類型推斷
no-
invalid-
template-
strings:
true,
//警告在非模板字符中使用${
no-
invalid-
this:
true,
//不容許在非class中使用 this關鍵字
no-
misused-
new:
true,
//禁止定義構造函數或new class
no-
null-
keyword:
true,
//不容許使用null關鍵字
no-
object-
literal-
type-
assertion:
true,
//禁止objext出如今類型斷言表達式中
no-
return-
await:
true,
//不容許return await
arrow-
parens:
true,
//箭頭函數定義的參數須要括號
}