Skip to content

Commit

Permalink
Merge pull request withfig#225 from withfig/feat/allow_empty_subcomma…
Browse files Browse the repository at this point in the history
…nd_option_arrays_on_root

[INTERNAL] feat: update no-empty-array-values rule
  • Loading branch information
cstrnt committed May 25, 2021
2 parents 6e95369 + 587dbb6 commit 5e9e72d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions scripts/eslint-plugin-fig-linter/rules/no-empty-array-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ module.exports = {
create: function (context) {
return {
Property(node) {
if (
node.key.name === "options" ||
node.key.name === "subcommands" ||
node.key.name === "args"
) {
const keyName = node.key.name;
if (["options", "subcommands", "args"].includes(keyName)) {
// This rule should not be applied to subcommands and
// options on the root object
if (
node.parent &&
node.parent.parent &&
node.parent.parent.parent &&
node.parent.parent.parent.parent &&
node.parent.parent.parent.parent.type ===
"ExportNamedDeclaration" &&
keyName !== "args"
)
return;

if (node.value && node.value.type === "ArrayExpression") {
if (node.value.elements.length === 0) {
context.report({
Expand Down

0 comments on commit 5e9e72d

Please sign in to comment.