]> git.proxmox.com Git - pve-eslint.git/blame - eslint/tests/fixtures/testers/rule-tester/no-test-global.js
import 8.23.1 source
[pve-eslint.git] / eslint / tests / fixtures / testers / rule-tester / no-test-global.js
CommitLineData
eb39fafa
DC
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
8f9d1d4d 10"use strict";
eb39fafa 11
8f9d1d4d
DC
12module.exports = {
13 meta: {
14 type: "problem",
15 schema: [],
16 },
17 create(context) {
18 return {
19 "Program": function(node) {
20 var globals = context.getScope().variables.map(function (variable) {
21 return variable.name;
22 });
eb39fafa 23
8f9d1d4d
DC
24 if (globals.indexOf("test") === -1) {
25 context.report(node, "Global variable test was not defined.");
26 }
27 if (globals.indexOf("foo") !== -1) {
28 context.report(node, "Global variable foo should not be used.");
29 }
eb39fafa 30 }
8f9d1d4d
DC
31 };
32 },
eb39fafa 33};