JSLint notepad++ Use

Source: Internet
Author: User

1.JSLint Introduction

JSLint defines a set of coding conventions that are stricter than the language defined by the ECMA. These coding conventions draw on years of rich coding experience, with an age-old programming principle as a tenet: to do does not mean to do. JSLint will mark the coding practices that it believes to have, and it will also point out which are obvious errors, prompting you to develop good JavaScript coding habits.

2.notepad++ Installing the JSLint plugin

1. Install notepad++ (development tools/Npp_v6.7.5_installer.1426044595.exe, do not install the latest version of NPP, use the JSLint bug)

2. Installing the JSLint Plugin

Open notepad++, open plug-in management display in plugins-plug-in management (Plugin manager)

Select JSLint and install in available, plug-in installation is successful

3.JSlint using 3.1 operation

1. Randomly open a JS file and select the plugin >>jslint>>jslint current file.

In the console can also be quick debugging, in the wrong place right click to select Show can directly locate the wrong location

JSLint allow to test JS and other files, set the language of the file to JavaScript

3.2 Configuration

Because jslint default definition of a lot of protocols, can all do naturally better. But we can actually relax the statute according to the needs of the project.

The plugin >>jslint>>option contains some options, as configured.

Predefindes Description: Here you can enter some global variables of the system to reduce error hints.

Current global variables:

Showopmsg,dojo,esri,jquery,ext,myapp,getconfig,getlocalconfig,highcharts,getctrl,setconfig,setlocalconfig, Showopms,bmap,transmodelstodatas,bmap_navigation_control_large,bmap_anchor_top_left,bmap_normal_map,bmap_ Satellite_map, bmap_hybrid_map3.3 description

JSLint may mark some of the structural errors as questionable coding practices, some of which are listed below (the complete list can refer to JSLint's documentation)http://www.jslint.com/lint.html.

①jslint requires all lines of code to end with semicolons. Although JavaScript does allow newline characters as line terminators, it is generally considered ambiguous and a bad coding style.

② using the IF and for statements must enclose the statement block with curly braces.

③ is different from other programming languages, in JavaScript, blocks are not scoped as variables. JavaScript only supports function-level scopes. As a result, jslint only accepts blocks that are part of function, if, switch, while, as, do, and try statements, and other blocks are flagged as errors.

④var can only be declared once, and must be declared before being used.

⑤jslint code that appears after a return, break, continue, or throw statement is marked as unreachable. These statements must be followed by a closing curly brace.

⑥ combined with ext, the common error is missing or more spaces, the function is missing use strict:missing ' use strict ' statement.,{} unaligned, the variable is undefined, the code is not in the desired position, etc. Most of these can be configured in option to verify whether or not.

⑦for in statement

Avoid traversing all the attributes on the prototype chain, and suggest the following notation:

For (name in object) {

if (Object.hasownproperty (name)) {

....

}

}

4. References

1. Use JSLint to check JavaScript code in notepad++

http://www.oschina.net/question/54100_25561

2.IBM documentation (using JSLint to ensure code quality)

http://www.ibm.com/developerworks/cn/web/1105_linlin_jslint/

Attached-jstool

Jstool is a good JS, JSON format tool.

It is convenient to use the notepad++ plugin jstool format code before using the JSLint specification code. Format the code to reduce the number of errors that need to be modified.

JSLint notepad++ Use

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.