日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

[TypeScript] vs code TSLint常见错误解决方案

發(fā)布時(shí)間:2023/12/20 编程问答 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [TypeScript] vs code TSLint常见错误解决方案 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

TSLint是一個(gè)Typescrip{過濾}t驗(yàn)證工具,用于檢測(cè)代碼。


TSLint: comment must start with a space (comment-format)

注釋必須從一個(gè)空格開始(comment-format)

也就是說//之后必須跟隨一個(gè)空格。

“Missing semicolon.” : “缺少分號(hào).”,
“Use the function form of \”use strict\”.” : “使用標(biāo)準(zhǔn)化定義function.”,
“Unexpected space after ‘-’.” : “在’-'后面不應(yīng)出現(xiàn)空格.”,
“Expected a JSON value.” : “請(qǐng)傳入一個(gè)json的值.”,
“Mixed spaces and tabs.”: “空格和TAB重復(fù).”,
“Unsafe character.” : “不安全的字符.”,
“Line too long.”: “本行中的字符超過設(shè)定的最大長(zhǎng)度.”,
“Trailing whitespace.”: “本行末尾有過多無(wú)用空格.”,
“scrip{過濾}t URL.” : “腳本URL.”,
“Unexpected {a} in ‘{b}’.” : “在 ‘{b}’ 中不該出現(xiàn) {a}.”,
“Unexpected ‘{a}’.” : “不該在此出現(xiàn)’{a}’.”,
“Strings must use doublequote.” : “字符串需要用雙引號(hào)”,
“Unnecessary escapement.” : “不需要轉(zhuǎn)義”,
“Control character in string: {a}.” : “在字符串中出現(xiàn)了Control的字符”,
“Avoid \\’.” : “避免 \\”,
“Avoid \\v.” : “避免 \\v”,
“Avoid \\x-.” : “避免 \\x-”,
“Bad escapement.” : “錯(cuò)誤的轉(zhuǎn)義字符”,
“Bad number ‘{a}’.” : “錯(cuò)誤的數(shù)字 ‘{a}’”,
“Missing space after ‘{a}’.” : “在’{a}’之后缺少空格”,
“Don’t use extra leading zeros ‘{a}’.” : “不要再’{a}’的前面用多余的0″,
“Avoid 0x-. ‘{a}’.” : “避免使用 0x-. ‘{a}’.”,
“A trailing decimal point can be confused with a dot ‘{a}’.” : “在’{a}’中使用點(diǎn)尾隨小數(shù)點(diǎn)”,
“Unexpected comment.” : “不該在此處出現(xiàn)注釋”,
“Unescaped ‘{a}’.” : “沒有轉(zhuǎn)義 ‘{a}’”,
“Unexpected control character in regular expression.” : “在正則表達(dá)式中出現(xiàn)了control字符”,
“Unexpected escaped character ‘{a}’ in regular expression.” : “在正則表達(dá)式中出現(xiàn)了沒有轉(zhuǎn)義的字符 ‘{a}’”,
“Expected ‘{a}’ and instead saw ‘{b}’.” : “應(yīng)該用 ‘{a}’代替’{b}’”,
“Spaces are hard to count. Use {{a}}.” : “空格難以統(tǒng)計(jì),請(qǐng)使用 {{a}}”,
“Insecure ‘{a}’.” : “不安全的 ‘{a}’”,
“Empty class.” : “空的class”,
“Expected a number and instead saw ‘{a}’.”:“應(yīng)該用數(shù)字代替’{a}’”,
“‘{a}’ should not be greater than ‘{b}’.”:“‘{a}’不應(yīng)該比’{b}’大”,
“‘hasOwnProperty’ is a really bad name.”: “‘hasOwnProperty’是關(guān)鍵字”,
“‘{a}’ was used before it was defined.”:“‘{a}’未定義就已經(jīng)使用了.”,
“‘{a}’ is already defined.”:“‘{a}’被重復(fù)定義”,
“A dot following a number can be confused with a decimal point.”:“數(shù)字后面的一個(gè)點(diǎn)會(huì)被誤認(rèn)為是十進(jìn)制的小數(shù)點(diǎn)”,
“Confusing minusses” : “容易混淆的負(fù)數(shù)表達(dá)-”,
“Confusing plusses.” : “容易混淆的正數(shù)表達(dá)+”,
“Unmatched ‘{a}’.” : “無(wú)法匹配的’{a}’”,
“Expected ‘{a}’ to match ‘{b}’ from line {c} and instead saw ‘ozvdkddzhkzd’.”:“在行{c}中需要用’{a}’和’{b}’匹配,用來(lái)代替’ozvdkddzhkzd’”,
“Unexpected early end of program.”:“程序不可預(yù)期的提前終止”,
“A leading decimal point can be confused with a dot: ‘.{a}’.”:“‘{a}’前的點(diǎn)容易混淆成小數(shù)點(diǎn)”,
“Use the array literal notation [].”:“使用數(shù)組的符號(hào) []“,
“Expected an operator and instead saw ‘{a}’.”:“需要用一個(gè)符號(hào)來(lái)代替’{a}’”,
“Unexpected space after ‘{a}’.”:“在’{a}’之后不能出現(xiàn)空格”,
“Unexpected space before ‘{a}’.”:“在’{a}’之前不能出現(xiàn)空格”,
“Bad line breaking before ‘{a}’.”:“在’{a}’之前錯(cuò)誤的換行”,
“Expected ‘{a}’ to have an indentation at {b} instead at {c}.”:“‘{a}’需要在{c}而不是{b}處縮進(jìn)”,
“Line breaking error ‘{a}’.”:“換行錯(cuò)誤 ‘{a}’”,
“Unexpected use of ‘{a}’.”:“此處不能用’{a}’”,
“Bad operand.”:“錯(cuò)誤的操作數(shù)”,
“Use the isNaN function to compare with NaN.”:“使用isNaN來(lái)與NaN比較”,
“Confusing use of ‘{a}’.”:“容易混淆的’{a}’的使用”,
“Read only.”:“只讀的屬性”,
“‘{a}’ is a function.”:“‘{a}’是一個(gè)函數(shù)”,
‘Bad assignment.’:“錯(cuò)誤的賦值”,
“Do not assign to the exception parameter.”:“不要給額外的參數(shù)賦值”,
“Expected an identifier in an assignment and instead saw a function invocation.”:“在賦值的語(yǔ)句中需要有一個(gè)標(biāo)識(shí)符,而不是一個(gè)方法的調(diào)用”,
“Expected an identifier and instead saw ‘{a}’ (a reserved word).”:“需要有一個(gè)標(biāo)識(shí)符,而不是’{a}’(保留字符)”,
“Missing name in function declaration.”:“在方法聲明中缺少名稱”,
“Expected an identifier and instead saw ‘{a}’.”:“需要有一個(gè)標(biāo)識(shí)符,而不是’{a}’”,
“Inner functions should be listed at the top of the outer function.”:“內(nèi)部函數(shù)的聲明應(yīng)該放在此函數(shù)的頂部。”,
“Unreachable ‘{a}’ after ‘{b}’.”:“在’{b}’之后無(wú)法獲取’{a}’”,
“Unnecessary semicolon.”:“不必要的分號(hào)”,
“Label ‘{a}’ on {b} statement.”:“將’{a}’放在{b}的聲明中”,
“Label ‘{a}’ looks like a javascrip{過濾}t url.”:“‘{a}’看上去像一個(gè)js的鏈接”,
“Expected an assignment or function call and instead saw an expression”:“需要一個(gè)賦值或者一個(gè)函數(shù)調(diào)用,而不是一個(gè)表達(dá)式.”,
“Do not use ‘new’ for side effects.”:“不要用’new’語(yǔ)句.”,
“Unnecessary \”use strict\”.”:“不必要的\”use strict\”.”,
“Missing \”use strict\” statement.”:“缺少\”use strict\”的聲明”,
“Empty block.”:“空的模塊”,
“Unexpected /*member ‘{a}’.”:“不應(yīng)出現(xiàn) /*元素 ‘{a}’.”,
“‘{a}’ is a statement label.”:“‘{a}’是一個(gè)聲明”,
“‘{a}’ used out of scope.”:“‘{a}’使用超出范圍”,
“‘{a}’ is not allowed.”:“不允許使用’{a}’”,
“‘{a}’ is not defined.”:“‘{a}’沒有被定義”,
“Use ‘{a}’ to compare with ‘{b}’.”:“使用’{a}’與’{b}’相比”,
“Variables should not be deleted.”:“變量需要被刪除”,
“Use the object literal notation {}.”:“使用對(duì)象的文字符號(hào) {}”,
“Do not use {a} as a constructor.”:“不要使用{a}作為一個(gè)構(gòu)造對(duì)象”,
“The Function constructor is eval.”:“The Function constructor is eval.”,
“A constructor name should start with an uppercase letter.”:“一個(gè)構(gòu)造對(duì)象的名稱必須用大寫字母開頭.”,
“Bad constructor.”:“錯(cuò)誤的構(gòu)造對(duì)象”,
“Weird construction. Delete ‘new’.”:“構(gòu)造對(duì)象有誤,請(qǐng)刪除’new’”,
“Missing ‘()’ invoking a constructor.”:“缺少括號(hào)()”,
“Avoid arguments.{a}.”:“避免參數(shù).{a}.”,
“document.write can be a form of eval.”:“document.write是eval的一種形式”,
‘eval is evil.’:“盡量不要使用eval”,
“Math is not a function.”:“Math不是一個(gè)函數(shù)”,
“Missing ‘new’ prefix when invoking a constructor.”:“此處缺少了’new’”,
“Missing radix parameter.”:“缺少參數(shù)”,
“Implied eval is evil. Pass a function instead of a string.”:“傳遞一個(gè)函數(shù),而不是一個(gè)字符串”,
“Bad invocation.”:“錯(cuò)誤的調(diào)用”,
“['{a}'] is better written in dot notation.”:“['{a}']最好用點(diǎn).的方式”,
“Extra comma.”:“多余的逗號(hào)”,
“Don’t make functions within a loop.”:“不要用循環(huán)的方式創(chuàng)建函數(shù)”,
“Unexpected parameter ‘{a}’ in get {b} function.”:“在{b}方法中不該用到參數(shù)’{a}’”,
“Duplicate member ‘{a}’.”:“重復(fù)的’{a}’”,
“Expected to see a statement and instead saw a block.”:“此處應(yīng)該是語(yǔ)句聲明.”,
“Too many var statements.”:“過多var的聲明”,
“Redefinition of ‘{a}’.”:“‘{a}’被重復(fù)定義”,
“It is not necessary to initialize ‘{a}’ to ‘undefined’.”:“無(wú)需將’{a}’初始化為’undefined’”,
“Expected a conditional expression and instead saw an assignment.”:“此處需要一個(gè)表達(dá)式,而不是賦值語(yǔ)句”,
“Expected a ‘break’ statement before ‘case’.”:“在’case’之前需要有’break’.”,
“Expected a ‘break’ statement before ‘default’.”:“在’default’之前需要有’break’.”,
“This ‘switch’ should be an ‘if’.”:“此處’switch’應(yīng)該是’if’.”,
“All ‘debugger’ statements should be removed.”:“請(qǐng)刪除’debugger’的語(yǔ)句”,
“‘{a}’ is not a statement label.”:“‘{a}’不是一個(gè)聲明標(biāo)簽.”,
“Expected an assignment or function call and instead saw an expression.”:“需要一個(gè)語(yǔ)句或者一個(gè)函數(shù)調(diào)用,而不是一個(gè)表達(dá)式”,
“Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.”:“函數(shù)的聲明不能放在類似if的塊中,需要放在外部函數(shù)的頂部.”


針對(duì)自己項(xiàng)目中遇到的一些提示,做一些舉例說明:

1 [W099]:Mixed spaces and tabs

這個(gè)錯(cuò)誤是最常見的,意思是在同一行中,空格和Tab縮進(jìn)混合使用了,修改很簡(jiǎn)單,一般是刪除Tab縮進(jìn),全部改為空格。為了方便,我們可以把編輯器的Tab縮進(jìn)設(shè)置成2個(gè)或4個(gè)空格,來(lái)代替原有的縮進(jìn)。

2 [W030]:Expected an assignment or function call and instead saw an expression

這個(gè)錯(cuò)誤提示的很詭異,我是用如下代碼提示的這個(gè)錯(cuò)誤 index-1 <0 ? index = 0:index = index - 1;??這是一個(gè)逗號(hào)表達(dá)式,但是JSLInt認(rèn)為這里不應(yīng)該用表達(dá)式,而必須是一個(gè)函數(shù),所以,如果非常在乎這個(gè)錯(cuò)誤,就改為if else 語(yǔ)句吧

3 [W041]:Use '===' to compare with ...

這個(gè)錯(cuò)誤是說,我們要是用全等來(lái)代替等于,如果表達(dá)式兩邊的數(shù)據(jù)類型是一致的話,建議使用全等來(lái)判斷

4 [W033]:Missing semicolon

缺少分號(hào);這個(gè)一般都是自己忘記寫了吧,但是有一個(gè)需要注意的是,對(duì)于只有一句的結(jié)構(gòu),后面也需要寫分號(hào)。例如:if(index<0) {index=tcount-1} 這句代碼,正確寫法是if(index<0) {index=tcount-1;},我是經(jīng)常忘記這里寫分號(hào),汗...

其他還有一些錯(cuò)誤提示就對(duì)照一下改吧,要培養(yǎng)自己良好的代碼風(fēng)格和書寫習(xí)慣。

?

原文鏈接:https://www.itsvse.com/thread-5178-1-1.html

轉(zhuǎn)載于:https://www.cnblogs.com/changfeng1800/p/10986005.html

總結(jié)

以上是生活随笔為你收集整理的[TypeScript] vs code TSLint常见错误解决方案的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。