Skip to content
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

Conversation

gndelia
Copy link
Collaborator

@gndelia gndelia commented Jul 26, 2020

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

@gndelia gndelia added the enhancement New feature or request label Jul 26, 2020
@gndelia gndelia self-assigned this Jul 26, 2020
}
const isWithinFunction = node.init.callee.name === 'within';
// TODO add the custom render option #198
const usesRenderOptions = node.init.callee.name === 'render' && usesContainerOrBaseElement(node.init);
Copy link
Collaborator Author

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 😅

renatoagds
renatoagds previously approved these changes Jul 27, 2020
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))
}
Copy link
Contributor

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

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor

@renatoagds renatoagds Jul 27, 2020

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?

Copy link
Member

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).

Copy link
Member

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 🤔

Copy link
Collaborator Author

@gndelia gndelia Jul 29, 2020

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 😅

docs/rules/prefer-screen-queries.md Outdated Show resolved Hide resolved
docs/rules/prefer-screen-queries.md Outdated Show resolved Hide resolved
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))
}
Copy link
Member

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.

@Belco90
Copy link
Member

Belco90 commented Jul 27, 2020

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

That's right. We will address the checking screen imported on #198. As mentioned in that ticket, after using the mechanism in a couple of rules should be easy to apply it to remaining ones.

Copy link
Member

@Belco90 Belco90 left a 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!

docs/rules/prefer-screen-queries.md Outdated Show resolved Hide resolved
tests/lib/rules/prefer-screen-queries.test.ts Show resolved Hide resolved
@gndelia gndelia force-pushed the prefer-screen-queries/feature/dont-warn-if-base-element-is-used branch from d784a34 to db61b10 Compare July 29, 2020 11:34
@Belco90 Belco90 merged commit b6fcc42 into master Jul 29, 2020
@Belco90 Belco90 deleted the prefer-screen-queries/feature/dont-warn-if-base-element-is-used branch July 29, 2020 19:16
@Belco90
Copy link
Member

Belco90 commented Jul 29, 2020

🎉 This PR is included in version 3.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

prefer-screen-queries: Don't warn if using the baseElement option
4 participants