Skip to content

Commit

Permalink
tools: auto fix custom eslint rule
Browse files Browse the repository at this point in the history
This implements an eslint fixer function to auto insert common.hasCryto check if messed out.

Refs: nodejs#16636
  • Loading branch information
shobhitchittora committed Oct 31, 2017
1 parent 46ca177 commit d9e0f5f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/eslint-rules/crypto-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,16 @@ module.exports = function(context) {

function report(nodes) {
nodes.forEach((node) => {
context.report(node, msg);
context.report({
node,
message: msg,
fix: (fixer) => {
return fixer.insertTextAfter(
node,
'\n\nif (!common.hasCrypto)\n\tcommon.skip("missing crypto");'
);
}
});
});
}

Expand Down

0 comments on commit d9e0f5f

Please sign in to comment.