Hello,
I'm trying to create a custom ESLint rule (v0.8.2) which prevents the use
of /* eslint-disable */ comments, but for some reason my context.report()
is not reporting violations as errors/warnings.
Does anybody have a couple minutes to take a look?
My .eslintrc file is pretty simple:
env:
node: true
rules:
no-alert: 1
no-eslint-disable: 2
My rules/no-eslint-disable.js is:
"use strict";
module.exports = function (context) {
var eslintEnableDisable = /^eslint-(enable|disable)/;
function checkComment(node) {
var value = node.value.trim();
if (eslintEnableDisable.test(value)) {
context.report(node, "Unexpected `eslint-disable` or `eslint-enable` in
content.");
console.error("errata!");
}
}
return {
"BlockComment": checkComment,
"LineComment": checkComment
};};
My app.js test case is:
/** * This is a copyright header. */
var foo = "bar"; // nice var bro
/*and a regular doc comment which may span multiple lines or include commented
out code.var bar = "foo"; // circular much? */
/* eslint-disable */var window = alert;/* eslint-enable */
When I run ESLint with my custom rule, I see my console.error()s but not
the warnings/errors via context.report().
$ eslint --rulesdir rules app.js
errata! `eslint-disable`
errata! `eslint-enable`
app.js
5:4 error foo is defined but never used no-unused-vars
✖ 1 problem
$ eslint -v # v0.8.2
--
You received this message because you are subscribed to the Google Groups
"ESLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.