UNPKG

1.02 kBJavaScriptView 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 url: "https://eslint.org/docs/rules/no-void"
18 },
19
20 schema: []
21 },
22
23 create(context) {
24
25 //--------------------------------------------------------------------------
26 // Public
27 //--------------------------------------------------------------------------
28
29 return {
30 UnaryExpression(node) {
31 if (node.operator === "void") {
32 context.report({ node, message: "Expected 'undefined' and instead saw 'void'." });
33 }
34 }
35 };
36
37 }
38};