Search code examples
node.jsnpmjscsgulp-jscs

How to create a JSCS config file on windows


When I try to create a JSCS config file:

C:\Blog\BlogWeb>jscs --auto-configure "C:\Blog\BlogWeb\temp.jscs"

I get the following error:

safeContextKeyword option requires string or array value

What parameter am I supposed to pass? What is a safecontextkeyword?

New to NPM and JSCS, please excuse ignorance.


Solution

  • JSCS was complaining that I didn't have a config file, so I was trying to figure out how to create one.

    JSCS looks for a config file in these places, unless you manually specify it with the --config option:

    jscs it will consequentially search for jscsConfig option in package.json file then for .jscsrc (which is a just JSON with comments) and .jscs.json files in the current working directory then in nearest ancestor until it hits the system root.

    I fixed this by:

    1. Create a new file named .jscsrc. Windows Explorer may not let you do this, so may need to use the command line.
    2. Copy the following into it. It doesn't matter if this is the preset you want to use or not. The command will overwrite it.
    {
      "preset": "jquery",
      "requireCurlyBraces": null // or false
    }
    
    1. Verify that it works by running a command such as:

    run the command

    jscs --auto-configure .jscsrc