如何在 windows 上创建 JSCS 配置文件

How to create a JSCS config file on windows

当我尝试创建 JSCS 配置文件时:

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

我收到以下错误:

safeContextKeyword option requires string or array value

我应该传递什么参数?什么是安全上下文关键字?

初学NPM和JSCS,请见谅

JSCS 抱怨我没有配置文件,所以我想弄清楚如何创建一个。

JSCS looks for a config file在这些地方,除非你用--config选项手动指定:

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.

我通过以下方式解决了这个问题:

  1. 创建一个名为 .jscsrc 的新文件。 Windows Explorer 可能不允许您这样做,因此可能需要使用命令行。
  2. 将以下内容复制到其中。这是否是您要使用的预设并不重要。该命令将覆盖它。
{
  "preset": "jquery",
  "requireCurlyBraces": null // or false
}
  1. 通过 运行 执行以下命令验证它是否有效:

运行命令

jscs --auto-configure .jscsrc