Search code examples
javascriptgruntjsjscs

How can I get jscs to use the --fix option from grunt?


Using grunt-jscs, I'd like to have it use the --fix option to automatically reformat code. How can I pass the command-line option to jscs? I've tried adding args & options, but can't get it to work.

My gruntfile has:

jscs: {
    all: {
        src: [
            '*.js',
        ]
    },
    options: {
        config: "/path/to/.jscsrc",
    }
},

Solution

  • The fix option is available in grunt-jscs as of v1.8.0.

    Specify it like this:

    jscs: {
      src: "path/to/files/*.js",
      options: {
        fix: true,
        config: ".jscsrc"
      }
    }