简体   繁体   English

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

[英]How to create a JSCS config file on windows

When I try to create a JSCS config file: 当我尝试创建JSCS配置文件时:

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

I get the following error: 我收到以下错误:

safeContextKeyword option requires string or array value safeContextKeyword选项需要字符串或数组值

What parameter am I supposed to pass? 我应该传递什么参数? What is a safecontextkeyword? 什么是安全上下文关键字?

New to NPM and JSCS, please excuse ignorance. NPM和JSCS的新手,请原谅。

JSCS was complaining that I didn't have a config file, so I was trying to figure out how to create one. JSCS抱怨我没有配置文件,因此我试图弄清楚如何创建一个配置文件。

JSCS looks for a config file in these places, unless you manually specify it with the --config option: 除非您使用--config选项手动指定,否则JSCS在这些位置查找配置文件

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. 然后,它将在package.json文件中搜索jscsConfig选项,然后在当前工作目录中搜索.jscsrc(这是带有注释的JSON)和.jscs.json文件,然后在最近的祖先中搜索,直到到达系统根目录为止。

I fixed this by: 我通过以下方式解决了这个问题:

  1. Create a new file named .jscsrc. 创建一个名为.jscsrc的新文件。 Windows Explorer may not let you do this, so may need to use the command line. Windows资源管理器可能不允许您执行此操作,因此可能需要使用命令行。
  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 jscs-自动配置.jscsrc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM