1 | /**
|
2 | * @fileoverview For ContentTask.spawn, this will automatically declare the
|
3 | * frame script variables in the global scope.
|
4 | * Note: due to the way ESLint works, it appears it is only
|
5 | * easy to declare these variables on a file-global scope, rather
|
6 | * than function global.
|
7 | *
|
8 | * This Source Code Form is subject to the terms of the Mozilla Public
|
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
|
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
11 | */
|
12 |
|
13 | ;
|
14 |
|
15 | /* eslint max-len:"off" */
|
16 |
|
17 | // -----------------------------------------------------------------------------
|
18 | // Rule Definition
|
19 | // -----------------------------------------------------------------------------
|
20 |
|
21 | var helpers = require("../helpers");
|
22 | var frameScriptEnv = require("../environments/frame-script");
|
23 |
|
24 | module.exports = function(context) {
|
25 | // ---------------------------------------------------------------------------
|
26 | // Public
|
27 | // ---------------------------------------------------------------------------
|
28 |
|
29 | return {
|
30 | "CallExpression[callee.object.name='ContentTask'][callee.property.name='spawn']": function(node) {
|
31 | for (let global in frameScriptEnv.globals) {
|
32 | helpers.addVarToScope(global, context.getScope(),
|
33 | frameScriptEnv.globals[global]);
|
34 | }
|
35 | }
|
36 | };
|
37 | };
|