]> git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/fixtures/testers/rule-tester/no-test-global.js
b5fa4c3bf929f6744e242de400a80ca0fa1b8fe1
[pve-eslint.git] / eslint / tests / fixtures / testers / rule-tester / no-test-global.js
1 /**
2 * @fileoverview Test rule to flag if the global var `test` is missing;
3 * @author Mathias Schreck
4 */
5
6 //------------------------------------------------------------------------------
7 // Rule Definition
8 //------------------------------------------------------------------------------
9
10 module.exports = function(context) {
11 "use strict";
12
13 return {
14 "Program": function(node) {
15 var globals = context.getScope().variables.map(function (variable) {
16 return variable.name;
17 });
18
19 if (globals.indexOf("test") === -1) {
20 context.report(node, "Global variable test was not defined.");
21 }
22 if (globals.indexOf("foo") !== -1) {
23 context.report(node, "Global variable foo should not be used.");
24 }
25 }
26 };
27 };