Will Klein
function addTen(value) {
var sum = 0;
return value + 10
}
if (someCondition) {
if (someOtherCondition) {
added = addTen(someValue);
}
}
function addTen(value) {
return value + 10;
}
if (someCondition &&
someOtherCondition) {
added = addTen(someValue);
}
function addTen(value) {
var sum = 0;
return value + 10
}
no-unused-vars
semi
if (someCondition) {
if (someOtherCondition) {
added = addTen(someValue);
}
}
???
if (someCondition) {}
if (someCondition) {}
{
"type": "Program",
"body": [
{
"type": "IfStatement",
"test": {
"type": "Identifier",
"name": "someCondition"
},
"consequent": {
"type": "BlockStatement",
"body": []
},
"alternate": null
}
]
}
if (someCondition) {
if (someOtherCondition) {
added = addTen(someValue);
}
}
{
"type": "IfStatement",
"test": {
"type": "Identifier",
"name": "someCondition"
},
"consequent": {
"type": "BlockStatement",
"body": [
{
"type": "IfStatement",
"test": {
"type": "Identifier",
"name": "someOtherCondition"
},
"consequent": {
"type": "BlockStatement",
"body": [ ... ] } } ] } }
module.exports = function(context) {
return {
};
};
module.exports = function(context) {
return {
"IfStatement": function(node) {
}
};
};
module.exports = function(context) {
return {
"IfStatement": function(node) {
if (/* test some things */) {
context.report(node,
"Unexpected bad code.");
}
}
};
};
module.exports = function(context) {
return {
"IfStatement": function(node) {
var ancestors = context.getAncestors(),
parent = ancestors.pop(),
grandparent = ancestors.pop();
if (/* test some things */) {
context.report(node,
"Unexpected bad code.");
}
}
};
};
if (someCondition)
if (someOtherCondition) {}
if (someCondition)
if (someOtherCondition) {}
var ancestors = context.getAncestors(),
parent = ancestors.pop(),
grandparent = ancestors.pop();
if (parent.type === "IfStatement") {
context.report(node, "Unexpected bad code.");
}
if (someCondition) {
if (someOtherCondition) {}
}
var ancestors = context.getAncestors(),
parent = ancestors.pop(),
grandparent = ancestors.pop();
if (parent.type === "IfStatement" ||
(parent.type === "BlockStatement" &&
grandparent.type === "IfStatement")) {
context.report(node, "Unexpected bad code.");
}
if (someCondition) {
if (someOtherCondition) {}
}
var ancestors = context.getAncestors(),
parent = ancestors.pop(),
grandparent = ancestors.pop();
if (parent.type === "IfStatement" ||
(parent.type === "BlockStatement" &&
parent.body.length === 1 &&
grandparent.type === "IfStatement")) {
context.report(node, "Unexpected bad code.");
}
if (someCondition) {
doSomething();
if (someOtherCondition) {}
}
var ancestors = context.getAncestors(),
parent = ancestors.pop(),
grandparent = ancestors.pop();
if (parent.type === "IfStatement" ||
(parent.type === "BlockStatement" &&
parent.body.length === 1 &&
grandparent.type === "IfStatement" &&
parent === grandparent.consequent)) {
context.report(node, "Unexpected bad code.");
}
if (someCondition) {
doSomething();
} else {
if (someOtherCondition) {}
}
module.exports = function(context) {
return {
"IfStatement": function(node) {
var ancestors = context.getAncestors(),
parent = ancestors.pop(),
grandparent = ancestors.pop();
if (parent.type === "IfStatement" ||
(parent.type === "BlockStatement" &&
parent.body.length === 1 &&
grandparent.type === "IfStatement" &&
parent === grandparent.consequent)) {
context.report(node, "Unexpected bad code.");
}
}
};
};
Will Klein
http://willkle.in
@willslab