mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
755 B
26 lines
755 B
10 years ago
|
/**
|
||
|
* @fileoverview Rule to flag blocks with no reason to exist
|
||
|
* @author Brandon Mills
|
||
|
*/
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
// Rule Definition
|
||
|
//------------------------------------------------------------------------------
|
||
|
|
||
|
module.exports = function(context) {
|
||
|
|
||
|
return {
|
||
|
"BlockStatement": function (node) {
|
||
|
// Check for any occurrence of BlockStatement > BlockStatement or
|
||
|
// Program > BlockStatement
|
||
|
var parent = context.getAncestors().pop();
|
||
|
if (parent.type === "BlockStatement" || parent.type === "Program") {
|
||
|
context.report(node, "Block is nested inside another block.");
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
};
|