Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions packages/eslint-plugin-cli/rules/command-flags-with-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
}
})
},
}
},
Expand Down
Loading