jscs-dev/grunt-jscs

disabling rule when using config file and multiple targets

djusv opened this issue · 3 comments

djusv commented

I'm currently working on a project where I'm happily using grunt-jscs.
Only today I might have found a little issue with inline options.

When I have a config file with a specific rule and I want disable/ignore it in specific target
it doesn't work for me. See example setup below

// jscs config file
{
    "preset": "google",
    "disallowDanglingUnderscores": true
}

// gruntfile
jscs: {
    main: [ "path/to/files/*.js" ],
    options: {
        config: ".jscs",
    },
    secondary: {    
        files: {
            src: [ "path/to/more/files/**/*.js", "my-plugin.js" ]
        }
    },
    ternary: {
        options: {
            disallowDanglingUnderscores: null
        },
        files: {
            src: "happy-hippo.js"
        }
    }
}

I found a working workaround for me:

// jscs.js
JSCS.prototype.getOptions = function() {
.......
    if ( !~taskOptions.indexOf( option ) ) {
      var value = this.options[ option ];
      _options[ option ] = value === false ? null : value;
     }

This allowed me to do the following

    ternary: {
        options: {
            disallowDanglingUnderscores: false
         }

Are you open for submitting an failing test case for this issue?

djusv commented

It may take me some time but I'm willing to try.

djusv commented

this issue may be closed. After updating to the latest version,
I cannot seem to reproduce this issue anymore.