From a71d1bf55976b43263589ab5d0553595f333ff7a Mon Sep 17 00:00:00 2001 From: Alfonso Noriega Date: Thu, 18 Jun 2026 12:49:53 +0200 Subject: [PATCH] Handle spread flags in command flags lint rule --- .../rules/command-flags-with-env.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/eslint-plugin-cli/rules/command-flags-with-env.js b/packages/eslint-plugin-cli/rules/command-flags-with-env.js index fbbcf0b73e7..3e281e42ad3 100644 --- a/packages/eslint-plugin-cli/rules/command-flags-with-env.js +++ b/packages/eslint-plugin-cli/rules/command-flags-with-env.js @@ -10,22 +10,22 @@ module.exports = { create(context) { return { PropertyDefinition(node) { - if (node.key.name === 'flags') { - node.value.properties.forEach((flag) => { - const arguments = flag.value?.arguments ?? [] - const argument = arguments[0] - if (!argument) { - return - } - const properties = argument.properties.map((property) => property.key.name) - if (!properties.includes('env')) { - context.report( - argument, - 'Flags must specify the environment variable that represents the flag through the env property', - ) - } - }) - } + if (node.key.name !== 'flags') return + + const flags = node.value?.properties ?? [] + flags.forEach((flag) => { + const argument = flag.value?.arguments?.[0] + if (!argument?.properties) { + return + } + const properties = argument.properties.map((property) => property.key.name) + if (!properties.includes('env')) { + context.report( + argument, + 'Flags must specify the environment variable that represents the flag through the env property', + ) + } + }) }, } },