![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/node_modules/eslint/lib/rules/ |
/**
* @fileoverview Rule to disallow use of the new operator with the `Symbol` object
* @author Alberto RodrÃguez
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "problem",
docs: {
description: "Disallow `new` operators with the `Symbol` object",
recommended: true,
url: "https://eslint.org/docs/latest/rules/no-new-symbol"
},
schema: [],
messages: {
noNewSymbol: "`Symbol` cannot be called as a constructor."
}
},
create(context) {
const sourceCode = context.sourceCode;
return {
"Program:exit"(node) {
const globalScope = sourceCode.getScope(node);
const variable = globalScope.set.get("Symbol");
if (variable && variable.defs.length === 0) {
variable.references.forEach(ref => {
const idNode = ref.identifier;
const parent = idNode.parent;
if (parent && parent.type === "NewExpression" && parent.callee === idNode) {
context.report({
node: idNode,
messageId: "noNewSymbol"
});
}
});
}
}
};
}
};