@groww-tech/eslint-plugin-internal
Version:
ESLint Plugin with customized rules as per requirement and preferences of devs in Groww.
24 lines (23 loc) • 517 B
JavaScript
module.exports = {
meta: {
docs: {
description: 'Avoid negation unary if else',
}
}
,
create(context) {
return {
IfStatement(node) {
if (node.consequent && node.alternate && !node.alternate.consequent) {
if (node.test.type === "UnaryExpression" && node.test.operator === "!") {
context.report({
node,
message: "Not expected negation here",
loc: node.loc,
});
}
}
}
}
}
}