2014-02-19 51 views
3

我使用VS 2013打字稿的0.95版本,但棉短絨失敗TS編譯出現錯誤:jquery.d.ts編譯失敗:TsLint:超過行的最大長度

TsLint: app.ts checked. TsLint: jquery.d.ts compilation failed: TsLint: exceeds maximum line length of 140

的jquery.d .ts文件確實有長度超過140的行,但我無法找到tslint配置文件來編輯最大行長度值。

我正在使用WebEssentials 2013,我沒有安裝tslint作爲包(NPM或Nuget)的一部分。

任何人都可以指向正確的方向嗎?我想這可能會更容易設置編譯/林外的VS現在..

謝謝。

回答

4

我認爲max-line-length警告是針對單行的長度,而不是針對文件中的行數。

您可以打破長排來縮小尺寸,或者簡單地忽略不是「您的代碼」的文件。

/* tslint:disable */ 
// the jquery type definition 
/* tslint:enable */ 

或建立自己的配置:

-c, --config: 
    The location of the configuration file that tslint will use to 
    determine which rules are activated and what options to provide 
    to the rules. If no option is specified, the config file named 
    tslint.json is used, so long as it exists in the path. 
    The format of the file is { rules: { /* rules list */ } }, 
    where /* rules list */ is a key: value comma-seperated list of 
    rulename: rule-options pairs. Rule-options can be either a 
    boolean true/false value denoting whether the rule is used or not, 
    or a list [boolean, ...] where the boolean provides the same role 
    as in the non-list case, and the rest of the list are options passed 
    to the rule that will determine what it checks for (such as number 
    of characters for the max-line-length rule, or what functions to ban 
    for the ban rule). 

https://www.npmjs.org/package/tslint

+0

對不起,史蒂夫,你誤解了我的問題。 1)我知道這是線的長度(「有長度超過140線」 - 從上面)。 2)我沒有更改jquery.d.ts文件,因爲它是在DefinitelyTyped回購([link] https://github.com/borisyankov/DefinitelyTyped)上創建並存儲的第三方標準。 3)它在Visual Studio 2013中,並且沒有--config開關。 – Astravagrant

+0

嗨史蒂夫,我想我會嘗試在[Github](https://github.com/borisyankov/DefinitelyTyped/pull/1711)上編輯該文件,並且已經開始了拉取請求,但是沒有TS理解來重構幾個接口定義。我優先考慮不必更改默認值(因爲,爲什麼)和開箱即用的W.E. 2013年整合。 – Astravagrant

+0

如果TSLint獲得了牽引力,那麼默認情況下,項目可能會願意將忽略規則添加到'.d.ts'文件。您希望TSLint檢查*您的*代碼而不是*外部*代碼和定義是否正確? – Fenton

6

可以修改tslint配置文件來改變最大線路長度閾值。它使用分層配置系統,因此您可以根據創建/修改tslint.conf文件的位置來確定更改的範圍。

By default, configuration is loaded from tslint.json, if it exists in the current path, or the user's home directory, in that order. (source...)

在我的Windows計算機上的全局配置文件位於C:\Users\My.Username這裏更改將適用於所有項目。在Visual Studio的根目錄下創建或修改文件意味着配置設置將只應用於該項目,並將覆蓋全局配置文件。

您需要修改的最大線長度的具體配置選項稱爲max-line-length,並會是這個樣子:

"max-line-length": [true, 140] 

更改140值,延長線的允許長度或更改truefalse禁用最大行長度規則。


或者,你可以做什麼史蒂夫在其他的答案已經建議,但你並不需要完全禁用tslint,因爲你可以禁用特定的規則。對於語法是:

,因此會使用:

/*tslint:disable:max-line-length*/ 

禁用該文件的最大線長度的規則。

tslint website上詳細解釋了所有配置選項和特定於規則的禁用。