-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: no-depends-on-boolean-flag
rule
#447
Conversation
no-depends-on-boolean-flag
rule
@@ -10,6 +10,8 @@ jobs: | |||
linux-unit-tests: | |||
needs: yarn-lockfile-check | |||
uses: salesforcecli/github-workflows/.github/workflows/unitTestsLinux.yml@main | |||
with: | |||
skipTsDepCheck: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opt-in way to disable the ts-dep-check, see: salesforcecli/github-workflows#120
this is a devDep so it's ok to ship TS
@@ -90,6 +91,7 @@ const recommended = { | |||
'sf-plugin/no-default-and-depends-on-flags': 'error', | |||
'sf-plugin/only-extend-SfCommand': 'warn', | |||
'sf-plugin/spread-base-flags': 'warn', | |||
'sf-plugin/no-depends-on-boolean-flag': 'warn', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warn instead of error because there are cases where depending on a boolean flag works as expected:
flag1
is boolean and has no default value/noallowNo
flag2
depends onflag1
there's no way flag1
can have a value if it's not passed in. Still, the warning should push users to double-check and future-proof their code 😉
f.value.callee.type == AST_NODE_TYPES.MemberExpression && | ||
f.value.callee.property.type == AST_NODE_TYPES.Identifier && | ||
f.value.callee.property.name === 'boolean' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommended: 'recommended', | ||
}, | ||
messages: { | ||
message: 'Cannot create a flag that `dependsOn` a boolean flag', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the message say more, something like, "use the relationships
property with a when
function".
* refactor: pr review * refactor: min/max/default
@mshanemc this PR has a ton of commits, make sure to squash-merge it when QA is done. |
Closes: #446
Adds a new
no-depends-on-boolean-flag
rule, see: https://github.com/salesforcecli/eslint-plugin-sf-plugin/blob/cd/depend-on-boolean-flag/docs/rules/no-depends-on-boolean-flag.mdDidn't do the autofix because I'm not sure it would be a good default and added more complexity (had to handle flags with
relationships
already defined, what if you really wanted it to depend on value, etc).@W-16320656@