-
Notifications
You must be signed in to change notification settings - Fork 144
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: allow baseElement and container in prefer-screen-queries #201
feat: allow baseElement and container in prefer-screen-queries #201
Conversation
} | ||
const isWithinFunction = node.init.callee.name === 'within'; | ||
// TODO add the custom render option #198 | ||
const usesRenderOptions = node.init.callee.name === 'render' && usesContainerOrBaseElement(node.init); |
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.
I left this comment as a reminder we need to address custom renders here 😅
lib/rules/prefer-screen-queries.ts
Outdated
function usesContainerOrBaseElement(node: TSESTree.CallExpression) { | ||
const secondArgument = node.arguments[1] | ||
return isObjectExpression(secondArgument) && secondArgument.properties.some((property) => isProperty(property) && isIdentifier(property.key) && ALLOWED_RENDER_PROPERTIES_FOR_DESTRUCTURING.includes(property.key.name)) | ||
} |
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.
Point of discussion: This should not be declared in top of the file? I don't know if we're following some pattern, but generally I prefer to put all utilities before default export
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.
I thought we had a linter rule for this.
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.
We don't have something to for this as far as I remember. In some rules is at the top, in others at the bottom.
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.
We don't have something to for this as far as I remember. In some rules is at the top, in others at the bottom.
Can we add this rule? or is not necessary?
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.
I'm not sure which ESLint rule cover this, but I guess it's better to address it on a separate ticket as it will implies fixing all reported issues (which is not directly related to this rule).
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.
Hmmm I really thought it was included in the recommended config, and that I moved all the utilities to the top because I had linting errors 🤔
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.
just in case I moved it above 😅
lib/rules/prefer-screen-queries.ts
Outdated
function usesContainerOrBaseElement(node: TSESTree.CallExpression) { | ||
const secondArgument = node.arguments[1] | ||
return isObjectExpression(secondArgument) && secondArgument.properties.some((property) => isProperty(property) && isIdentifier(property.key) && ALLOWED_RENDER_PROPERTIES_FOR_DESTRUCTURING.includes(property.key.name)) | ||
} |
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.
I thought we had a linter rule for this.
That's right. We will address the checking |
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.
I added couple of comments, but the implementation itself looks fine. Thanks!
d784a34
to
db61b10
Compare
🎉 This PR is included in version 3.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
closes #188
One thing I noticed from this rule is that it does not check
screen
is imported from RTL, nor anything about custom renders. Not sure if we should all of that for the v4 in #198 or if checking imports should be done in a separated ticket for the current version and then enhanced with custom renders for the v4... I'll assume it will be easier to do everything directly in v4 to avoid doing weird rebases but I want to know your opinion folks.For this PR I just stick with the feature requested