gulp-eslint: How to configure the "no-use-before-define" rule

1.7k Views Asked by At

I'm trying to turn off the "no-use-before-define" rule for functions, but leave it active for variables and classes.

In the documentation found here http://eslint.org/docs/rules/no-use-before-define it says that this is the correct configuration syntax:

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

When I run with that though I get this error:

[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)

I know that the gulp-eslint syntax is a little bit different from the official eslint configuration syntax.

I can't figure out what the gulp-eslint syntax is for the { "functions": false, "classes": true, "variables ": true } bit though. There doesn't seem to be any documentation for it anywhere.

2

There are 2 best solutions below

0
On

This answer doesn't explain how to do the custom configuration but it does explain how to get the functionality that I was originally after.

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

"nofunc" is basically just a shortcut command for { "functions": false, "classes": true, "variables ": true }

I get the feeling that this is actually a bug in gulp-eslint and there is no actual way to do custom settings using the plugin.

0
On

You have an extra space in your rule, just after the word 'variables':

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

This is illegal and would generate an error.