1

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.

Hoppe
  • 6,508
  • 17
  • 60
  • 114
  • The `--auto-configure` option should be used in conjunction with a path to a JS file, or directory of JS files, to create a `.jscsrc` based on an available [preset](http://jscs.info/overview#presets). See the [`safeContextKeyword`](http://jscs.info/rule/safeContextKeyword) rule for what it does and what's required as a configuration parameter. – miqh Oct 15 '15 at 00:02
  • I read these again and they still aren't clear to me. I tried a few different parameters, i.e. a directory, a few permutations of .\jscrc, to no avail. Am I supposed to install a preset first? @miqid – Hoppe Oct 16 '15 at 21:30
  • 1
    Presets (11 at the time of writing) should already come with JSCS when installing via npm. To be clear, you don't run `--auto-configure` with the path specified as anything to do with a `.jscsrc` file. You run it over a directory containing your project's JS source files to help JSCS determine what exceptions to add in place with the preset you've chosen. Here's some sample output - http://i.imgur.com/d9DMv3h.png – miqh Oct 17 '15 at 02:53
  • Thanks that was very helpful. JSCS was complaining that I didn't have a config file, which was the root of all of this – Hoppe Oct 21 '15 at 20:33

1 Answers1

4

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

Daniels Šatcs
  • 526
  • 6
  • 18
Hoppe
  • 6,508
  • 17
  • 60
  • 114