Home > Web Front-end > JS Tutorial > Installation and configuration tutorial of Node debugging tool JSHint_javascript skills

Installation and configuration tutorial of Node debugging tool JSHint_javascript skills

WBOY
Release: 2016-05-16 16:46:37
Original
1693 people have browsed it

Now we introduce JSHint, a JS code verification tool for checking simple errors under Node.

For a detailed introduction to JSHint, please refer to http://www.jshint.com/about/. To put it bluntly, JSHint is a tool for checking whether the JS code is standardized. It can be used to check any (including server-side and client side) the standardization of JS code. It provides configuration methods, allowing developers to define which specification errors to check. This brings great convenience to developers, because during the development process, especially during team development, we often encounter various problems caused by non-compliance with specifications, or some common text Errors, such as using undefined functions or parameters, etc.

 1. Install JSHint.

Open the cmd command window and enter the following command:

Copy code The code is as follows:

npm install -g jshint //-g means Use
globally

Note: If it says that npm is not an internal or external command, then it is probably because you have not installed node or npm. For the specific installation process, please refer to http://dailyjs.com/2012/05/03/windows-and-node-1/.

 2. Run JSHint.

Open the cmd command window, use cd to switch to your corresponding application directory, and enter the command:

Copy code The code is as follows:

jshint my_app.js

Note: my_app.js is the file you intend to verify or check.

 3. Configure JSHint.

JSHint provides a configuration method so that you can define verification rules according to your team or hobbies. You can copy the default rule file from https://github.com/jshint/node-jshint/blob/master/.jshintrc.

Method 1: If you name the copied rule file as a .jshintrc file and place the file in the corresponding directory or parent directory, this rule file will be automatically retrieved and used when running JSHint.

Method 2: If you have not named the rule file a name that conforms to the rules (that is, use .jshintrc), you can manually specify the rule file when running JSHint. For example, you name the rule file jshint.json. Then you can use the following command to run JSHint and apply your rules:

Copy code The code is as follows:

jshint my_app.js --config /root/application/ jshint.json //Specify the rule file path

4. Configuration file rules.

There are many rules for configuration files, including the common use of semicolons, capitalization of the first letter of class constructor functions, etc. The specific rules will not be repeated one by one. Please refer to http://www.jshint.com/docs/.

By using the tool JSHint, many common errors or accidentally mistaken codes in your JS code will be checked. Of course, JSHint won't be powerful enough to catch all your errors. But don’t worry, there are several other debugging tools that can be used for Node. This time I will only introduce JSHint.

The above is my humble opinion. If there are any mistakes, please point them out. Welcome to exchange and discuss.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template