2017-04-15 92 views
1

我試圖關閉功能的"no-use-before-define"規則,但保留其對變量和類的激活狀態。gulp-eslint:如何配置「定義之前不使用」規則

在這裏http://eslint.org/docs/rules/no-use-before-define下的文檔,它說,這是正確的配置語法:

"no-use-before-define": ["error", { "functions": false, "classes": true, "variables ": true }] 

當我與運行,雖然我得到這個錯誤:

[21:00:46] Error: CLI: 
    Configuration for rule "no-use-before-define" is invalid: 
    Severity should be one of the following: 0 = off, 1 = warning, 2 = error (you passed "error"). 
    Value "[object Object]" must be an enum value. 

    at Object.validateRuleOptions (E:\01-Dans stuff\Projects\00 - YeoSword\YeoSword-git\node_modules\gulp-eslint\node_modules\eslint\lib\config\config-validator.js:102:15) 
    at CLIEngine.<anonymous> (E:\01-Dans stuff\Projects\00 - YeoSword\YeoSword-git\node_modules\gulp-eslint\node_modules\eslint\lib\cli-engine.js:421:19) 
    at Array.forEach (native) 
    at new CLIEngine (E:\01-Dans stuff\Projects\00 - YeoSword\YeoSword-git\node_modules\gulp-eslint\node_modules\eslint\lib\cli-engine.js:420:43) 
    at Object.gulpEslint (E:\01-Dans stuff\Projects\00 - YeoSword\YeoSword-git\node_modules\gulp-eslint\index.js:17:15) 
    at E:/01-Dans stuff/Projects/00 - YeoSword/YeoSword-git/gulp/tasks/eslint.js:24:16 
    at taskWrapper (E:\01-Dans stuff\Projects\00 - YeoSword\YeoSword-git\node_modules\undertaker\lib\set-task.js:13:15) 
    at bound (domain.js:287:14) 
    at runBound (domain.js:300:12) 
    at asyncRunner (E:\01-Dans stuff\Projects\00 - YeoSword\YeoSword-git\node_modules\async-done\index.js:36:18) 

我知道吞氣-eslint語法與官方eslint配置語法有點不同。

儘管如此,我不知道gulp-eslint語法對於{ "functions": false, "classes": true, "variables ": true }位是什麼。似乎沒有任何地方的任何文件。

回答

0

此答案不解釋如何執行自定義配置,但它確實解釋瞭如何獲取我原來的功能。

"no-use-before-define": [1, "nofunc"] 

"nofunc"基本上只是{ "functions": false, "classes": true, "variables ": true }

給我的感覺,這其實是一飲而盡,eslint一個bug,有做使用插件自定義設置沒有實際的方式快捷命令。

0

你在你的規則有一個額外的空間,只是這個詞「變量」後:

「不使用前方的定義」:「錯誤」,{「功能」:假的,「類」 :true,「variables」:true}]

這是違法的,會產生錯誤。