]> git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-delete-var.js
41021bd46a7b99e32287e5654d9c0e2d3c5a91e8
[pve-eslint.git] / eslint / lib / rules / no-delete-var.js
1 /**
2 * @fileoverview Rule to flag when deleting variables
3 * @author Ilya Volodin
4 */
5
6 "use strict";
7
8 //------------------------------------------------------------------------------
9 // Rule Definition
10 //------------------------------------------------------------------------------
11
12 /** @type {import('../shared/types').Rule} */
13 module.exports = {
14 meta: {
15 type: "suggestion",
16
17 docs: {
18 description: "Disallow deleting variables",
19 recommended: true,
20 url: "https://eslint.org/docs/rules/no-delete-var"
21 },
22
23 schema: [],
24
25 messages: {
26 unexpected: "Variables should not be deleted."
27 }
28 },
29
30 create(context) {
31
32 return {
33
34 UnaryExpression(node) {
35 if (node.operator === "delete" && node.argument.type === "Identifier") {
36 context.report({ node, messageId: "unexpected" });
37 }
38 }
39 };
40
41 }
42 };