UNPKG

eslint-plugin-sf-plugin

Version:
47 lines (46 loc) 1.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.noMessagesLoad = void 0; /* * Copyright (c) 2020, salesforce.com, inc. * All rights reserved. * Licensed under the BSD 3-Clause license. * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils"); const utils_1 = require("@typescript-eslint/utils"); exports.noMessagesLoad = eslint_utils_1.RuleCreator.withoutDocs({ meta: { docs: { description: 'Use Messages.loadMessages() instead of Messages.load()', recommended: 'recommended', }, messages: { message: 'Use Messages.loadMessages() instead of Messages.load()', }, type: 'problem', schema: [], fixable: 'code', }, defaultOptions: [], create(context) { return { CallExpression(node) { if (node.callee.type === utils_1.AST_NODE_TYPES.MemberExpression && node.callee.object.type === utils_1.AST_NODE_TYPES.Identifier && node.callee.object.name === 'Messages' && node.callee.property.type === utils_1.AST_NODE_TYPES.Identifier && node.callee.property.name === 'load' && node.arguments[0].type === utils_1.AST_NODE_TYPES.Literal && node.arguments[1].type === utils_1.AST_NODE_TYPES.Literal) { const replacementText = `Messages.loadMessages(${node.arguments[0].raw}, ${node.arguments[1].raw})`; context.report({ node: node.callee.property, messageId: 'message', fix: (fixer) => fixer.replaceText(node, replacementText), }); } }, }; }, });