UNPKG

eslint-plugin-sf-plugin

Version:
44 lines (43 loc) 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.jsonFlag = 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"); const commands_1 = require("../shared/commands"); const flags_1 = require("../shared/flags"); exports.jsonFlag = eslint_utils_1.RuleCreator.withoutDocs({ meta: { docs: { description: 'Do not allow creation of json flag', recommended: 'recommended', }, messages: { message: 'It is not necessary to add a --json flag. That flag is provided by sfCommand/oclif', }, type: 'problem', schema: [], }, defaultOptions: [], create(context) { return (0, commands_1.isInCommandDirectory)(context) ? { Property(node) { if ((0, flags_1.isFlag)(node) && (0, commands_1.ancestorsContainsSfCommand)(context)) { if (node.key.type === utils_1.AST_NODE_TYPES.Identifier && node.key.name === 'json') { context.report({ node, messageId: 'message', }); } } }, } : {}; }, });