"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Disable Eslint Rules for a Specific Line?

How to Disable Eslint Rules for a Specific Line?

Published on 2024-11-06
Browse:611

How to Disable Eslint Rules for a Specific Line?

Eslint Rule Disabling for a Specific Line

In JSHint, linting rules can be disabled for a particular line using the syntax:

/* jshint ignore:start */
$scope.someVar = ConstructorFunction();
/* jshint ignore:end */

For eslint, there are several ways to achieve a similar effect.

Disable Next Line

To disable the next line only, use:

// eslint-disable-next-line no-use-before-define
var thing = new Thing();

Disable Single Line

Alternatively, use the single-line syntax:

var thing = new Thing(); // eslint-disable-line no-use-before-define

Disable All Rules for a Line

If you wish to disable all eslint rules for a given line, you can use:

var thing = new Thing() // eslint-disable-line

Refer to the eslint documentation for more details.

Release Statement This article is reprinted at: 1729204396 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3