Does anybody know how to check nodejs code to code standards automatically? I'm looking for some features like codesniffer but for node.js (express framework).

有帮助吗?

解决方案

You can use JSHint for node. Install it globally:

sudo npm install jshint -g

Basic usage:

jshint foo.js 
  foo.js: line 7, col 23, Missing semicolon.

You can create a custom configuration file named .jshintrc that contain JSON JSHint options, and JSHint will pick them up. Example of a .jshintrc file:

{
    "strict": "true",
    "smarttabs": "true"
}

You can read more about how to configure JSHint on their documentation page.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top