Nodejs + jshint Automated static code checking

Source: Internet
Author: User

1. Purpose

Automated static code checking and improved code quality before committing to code

2. Preparation 1. Nodejs Installation:

Official address: http://nodejs.org/

Installation instructions: Download the corresponding version according to the computer configuration to install

To check if the installation was successful:

2. Install Grunt:

GRUNTJS Official website: http://www.gruntjs.org/

Installation Instructions:

1. Go to the command line and install the Grunt library.

2. Install GRUNT-CLI (you can run the grunt command directly at the command line after installation)

3. Check whether the installation is successful:

3. Installing Jshint

Go to the command line and execute:

4. Install the Grunt-jshint library:

3. Create grunt Automation Engineering 1. Loading grunt, Jshint plugins:

Go to the root directory where you want to automate the inspection (hereinafter referred to as the project directory ), and perform preparation steps 2, 3, 4.

2. Create a Package.json file

Go to the project directory and do the following: NPM Init

3. Create Gruntfile.js

Create the Gruntfile.js file manually in the project directory.

4. Configure Gruntfile

1, configure the wrapper function of grunt.

2. Initialize the configuration (Task configuration) object.

3. Read our project configuration Package.json file and store it in the Pkg property.

4. Add the task.

      • Files settings must be set to the root directory first
      • When configuring files that you do not want to be checked, add a "!" to the front. For example: files:[' script/*.js ', '!script/*.min.js ']
      • Externally introduced JSHINTRC files:

5, load the required grunt plug-in

6. Registration Tasks

7, the complete gruntfile.js

4. Running

      1. Go to command line

  

  

2 Running a configured task

Appendix:

Jshint option:http://www.jshint.com/docs/options/

Nodejs + jshint Automated static code checking

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.