我想要一个非常简单的eslint规则,以确保每个文件的顶部行说‘哦’。这样的东西似乎可以工作--但是如果没有节点,我怎么context.report它呢?或者,我如何才能获得一个节点,该节点是文件的第一行?我是否应该使用在'return‘中的事件上声明的回调(如果是,是哪个事件)?谢谢!
'use strict';
function checkFirstLine (context) {
if (context.getSourceCode().lines[0] !== 'ouch') {
// How do I context.report without a node?
}
}
module.exports = {
meta : {
docs : {
description : 'check first line',
category : 'Possible Errors',
recommended : true
},
},
create : function (context) {
checkFirstLine (context);
return {};
}
};发布于 2016-08-18 21:10:38
刚刚弄明白了,我可以使用:
context.report(context.getSourceCode().ast, 'Cripes');https://stackoverflow.com/questions/39019024
复制相似问题