eslint-plugin-sf-plugin
Version:
Helpful eslint rules for sf plugins.
41 lines (40 loc) • 1.43 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.onlyExtendSfCommand = 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 commands_1 = require("../shared/commands");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
exports.onlyExtendSfCommand = eslint_utils_1.RuleCreator.withoutDocs({
meta: {
docs: {
description: 'Only allow commands that directly extend SfCommand',
recommended: 'recommended',
},
messages: {
message: 'In order to inherit default flags correctly, extend from SfCommand directly',
},
type: 'problem',
schema: [],
},
defaultOptions: [],
create(context) {
return (0, commands_1.isInCommandDirectory)(context)
? {
ClassDeclaration(node) {
// verify it extends SfCommand
if (!(0, commands_1.extendsSfCommand)(node, context) && node.id) {
context.report({
node: node.id,
messageId: 'message',
});
}
},
}
: {};
},
});
;