UNPKG

1.37 kBJavaScriptView Raw
1/**
2 * @fileoverview Reject defining Cc/Ci/Cr/Cu.
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"use strict";
10
11// -----------------------------------------------------------------------------
12// Rule Definition
13// -----------------------------------------------------------------------------
14
15const componentsBlacklist = ["Cc", "Ci", "Cr", "Cu"];
16
17module.exports = function(context) {
18
19 // ---------------------------------------------------------------------------
20 // Public
21 // --------------------------------------------------------------------------
22
23 return {
24 "VariableDeclarator": function(node) {
25 if (node.id.type == "Identifier" && componentsBlacklist.includes(node.id.name)) {
26 context.report(node,
27 `${node.id.name} is now defined in global scope, a separate definition is no longer necessary.`);
28 }
29
30 if (node.id.type == "ObjectPattern") {
31 for (let property of node.id.properties) {
32 if (componentsBlacklist.includes(property.value.name)) {
33 context.report(node,
34 `${property.value.name} is now defined in global scope, a separate definition is no longer necessary.`);
35 }
36 }
37 }
38 }
39 };
40};