ESLintでカスタムルールを作成しています。
基本的:
module.exports = function (context) {
var file = context.getSource();
var fileName = context.getFilename();
var lines = file.split(/\n/);
lines.forEach(function(line, i){
// [...] validation logic
var report = {
message: 'Code style error.'
};
report.loc = {
line: i + 1,
col: 1 // I have some logic for this working
};
context.report(report);
});
return {}; // do I need this?
};
私のコードは探しているエラーを見つけることができますが、ESLint に報告するのに問題があります。
私は得る:
ルール 'test-rule' の読み込み中にエラーが発生しました: 未定義のプロパティ 'type' を読み取れません
AST をまったく使用していないので、どのように構成し、context.report(report);
このモジュールに を持たせる必要がありますか?return
私が欠けているものについて何か提案はありますか?