UNPKG

965 BJavaScriptView Raw
1/**
2 * @fileoverview Rule to disallow use of void operator.
3 * @author Mike Sidorov
4 */
5"use strict";
6
7//------------------------------------------------------------------------------
8// Rule Definition
9//------------------------------------------------------------------------------
10
11module.exports = {
12 meta: {
13 docs: {
14 description: "disallow `void` operators",
15 category: "Best Practices",
16 recommended: false
17 },
18
19 schema: []
20 },
21
22 create(context) {
23
24 //--------------------------------------------------------------------------
25 // Public
26 //--------------------------------------------------------------------------
27
28 return {
29 UnaryExpression(node) {
30 if (node.operator === "void") {
31 context.report({ node, message: "Expected 'undefined' and instead saw 'void'." });
32 }
33 }
34 };
35
36 }
37};