UNPKG

767 BJavaScriptView Raw
1/**
2 * @fileoverview Rule to flag references to the undefined variable.
3 * @author Michael Ficarra
4 */
5"use strict";
6
7//------------------------------------------------------------------------------
8// Rule Definition
9//------------------------------------------------------------------------------
10
11module.exports = function(context) {
12
13 return {
14
15 "Identifier": function(node) {
16 if (node.name === "undefined") {
17 var parent = context.getAncestors().pop();
18 if (!parent || parent.type !== "MemberExpression" || node !== parent.property || parent.computed) {
19 context.report(node, "Unexpected use of undefined.");
20 }
21 }
22 }
23 };
24
25};
26
27module.exports.schema = [];