Urara-Blog/node_modules/.pnpm-store/v3/files/33/ab20ee15be72f08feb3849f98522eb4adf759c534ab15c9d29aad0853b5194c8e9e770944b8d2b56eac23988b8c248be3b97ee0bec55335bccb5bcb390520d
2022-08-14 01:14:53 +08:00

42 lines
976 B
Text

/**
* @fileoverview Rule to flag when deleting variables
* @author Ilya Volodin
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Disallow deleting variables",
recommended: true,
url: "https://eslint.org/docs/rules/no-delete-var"
},
schema: [],
messages: {
unexpected: "Variables should not be deleted."
}
},
create(context) {
return {
UnaryExpression(node) {
if (node.operator === "delete" && node.argument.type === "Identifier") {
context.report({ node, messageId: "unexpected" });
}
}
};
}
};