UNPKG

@admc.com/eslint-plugin-sn

Version:
62 lines (53 loc) 1.7 kB
/* * This rule is for testing of the eslint-plugin-sn system itself (and maybe systems that integrate * it), not for end user developers checking their ServiceNow code. * * This was generated by Perplexity AI. */ "use strict"; const message = "Execution environment doesn't support let declarations. (Script-independent)"; const messageId = // eslint-disable-next-line prefer-template (require("path").basename(__filename).replace(/[.]js$/, "") + "_msg").toUpperCase(); const esLintObj = { meta: { type: "problem", docs: { description: "Check whether the execution environment supports let declarations (optionally inverted).", category: "Possible Problems", }, messages: {}, // One optional string option: "invert" schema: [ { enum: ["invert"], }, ], }, create: context => { // Read optional option: ["invert"] const invert = context.options[0] === "invert"; const ecmaVersion = context.parserOptions && context.parserOptions.ecmaVersion || 5; const supportsLet = ecmaVersion >= 6; // Effective condition: when should this rule report an error? // - Default config (no options): error when let is NOT supported. // - With ["error", "invert"]: error when let IS supported. const shouldError = invert ? supportsLet : !supportsLet; if (!shouldError) { // Nothing to do for this file return {}; } // Report once per file, on the Program node return { Program(node) { context.report({ node, messageId, }); }, }; }, }; esLintObj.meta.messages[messageId] = message; module.exports = esLintObj;