Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the comparison between JSLint and JSHint and ESLint

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

What is the comparison between JSLint and JSHint and ESLint? for this question, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

Recently, I have been writing projects in React, but I did not configure the support for JSX and ES6 before my Vim configuration, and then I watched the pile report all kinds of displeasure, so I continued to struggle, by the way, adding some knowledge to record it.

Mainstream JS Lint tools and their introduction

JavaScript has been developed for a long time, and the corresponding Lint tools emerge one after another. Here are some mainstream Lint tools (actually some XD that I have used).

JSLint

JSLint was developed by Douglas Crockford and is probably the earliest JavaScript Lint tool. Its name comes from the famous C language tool Lint. Lao Tao reported to warning what he thought was not Good Parts, and also mentioned in its documentation that you should gladly accept all JSLint suggestions. Recently, I have seen that Lao Tao is still updating the project, and there is an online experience tool on the official website, so you can try it. By the way, if you want to use this tool, I suggest you take a look at Lao Tao's video on the JavaScript programming style on YouTube, which is still very humorous.

JSHint

JSHint is an open source project implemented by Anton Kovalyov JSLint-based code. Because most people were oppressed by JSLint during the JSLint period, compared with JSHint, it was more friendly and easier to configure, so it quickly developed and was supported by many IDE and editors. However, because it is developed based on JSLint, it has inherited some of the original problems, such as it is not easy to expand, it is not easy to locate specific rules according to the error report, and so on. Although it seems to have been discussed before, there is still no good solution. Fortunately, it has developed well, many of the problems encountered can find relevant solutions on the Internet, and the documentation is also very good.

ESLint

ESLint was developed by Nicholas C. Zakas in 2013, its original intention is to enable developers to customize their own linting rules, and it provides a set of quite complete plug-in mechanism, you can freely extend, dynamically load configuration rules, and it can easily locate specific rules according to the error. And what I like about it is that the documentation is very detailed, which is probably necessary for flexibility. I would also like to mention here that ESLint was not originally intended to create a repetitive wheel, but that the author's needs in actual use did not get a response from the JSHint team, so he combined JSHint at that time with another code-style inspection tool JSCS to write ESLint with code style check and custom plug-in extension functions.

Comparison between JSLint,JSHint and ESLint

Each of these three tools has its own characteristics. I just want to make a comparison. If you choose, it will be fine if you look at your personal needs.

Advantages of JSLint

The configuration has been decided by the old way and can be used immediately out of the box.

Deficiency

Limited configuration options, many rules cannot be disabled

The standard is strict, and there will be a warning for those who do not conform to the good style that the old way thinks. (this one depends on whether you fully agree with the old way).

Poor scalability

Cannot locate the corresponding rule according to the error

Advantages of JSHint

There are a lot of parameters to configure

Support for configuration files for ease of use

Supports some common class libraries

Support for basic ES6

Deficiency

Custom rules are not supported

Cannot locate the corresponding rule according to the error

Advantages of ESLint

The default rules contain rules for JSLint and JSHint, which are easy to migrate (this must be intentional XD)

Can be configured to both warning and error levels, or simply disable it

Support for plug-in extensions

You can customize rules

You can locate the corresponding rule according to the error

Support for ES6

The only tool that supports JSX

Deficiency

Some custom configuration is required (because it is too flexible, but the documentation is very detailed)

Slow (it's slower than the other two)

Vim support

We all use Syntastic to configure

Vim configuration of JSLint

There is a version of jslint.vim that is of course too old. We don't have to do it this way.

Install jslint

Sudo npm install jslint-g

Add the following configuration to vimrc

Let g:syntastic_javascript_checkers = ['jslint'] Vim configuration of JSHint

Install jshint

Sudo npm install jshint-g

Add the following configuration to vimrc

Let g:syntastic_javascript_checkers = ['jshint']

You can also use the stand-alone plug-in jshint.vim

Vim configuration of ESLint sudo npm install eslint-g

Add the following configuration to vimrc

Let g:syntastic_javascript_checkers = ['eslint']

Here is a very important question. Remember to add a configuration file, which can be found on the official website or in the warehouse configured by my vim.

This is the answer to the question about what is the comparison between JSLint and JSHint and ESLint. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report