1 | /**
|
2 | * @fileoverview Require .ownerGlobal instead of .ownerDocument.defaultView.
|
3 | *
|
4 | * This Source Code Form is subject to the terms of the Mozilla Public
|
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
|
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
7 | */
|
8 |
|
9 | ;
|
10 |
|
11 | // -----------------------------------------------------------------------------
|
12 | // Rule Definition
|
13 | // -----------------------------------------------------------------------------
|
14 |
|
15 | module.exports = function(context) {
|
16 |
|
17 | // ---------------------------------------------------------------------------
|
18 | // Public
|
19 | // --------------------------------------------------------------------------
|
20 |
|
21 | return {
|
22 | "MemberExpression": function(node) {
|
23 | if (node.property.type != "Identifier" ||
|
24 | node.property.name != "defaultView" ||
|
25 | node.object.type != "MemberExpression" ||
|
26 | node.object.property.type != "Identifier" ||
|
27 | node.object.property.name != "ownerDocument") {
|
28 | return;
|
29 | }
|
30 |
|
31 | context.report(node,
|
32 | "use .ownerGlobal instead of .ownerDocument.defaultView");
|
33 | }
|
34 | };
|
35 | };
|