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

Support if/else route definitions in no-shadow-route-definition rule #1297

Merged
merged 1 commit into from Sep 20, 2021

Conversation

raido
Copy link
Contributor

@raido raido commented Sep 14, 2021

This PR is an attempt support if else statements for route definitions.

We are building prefix key from block statements ranges that are within given if statement block and use it for routeMap lookup.

Closes #1268

@raido raido marked this pull request as ready for review September 14, 2021 07:50
@raido
Copy link
Contributor Author

raido commented Sep 14, 2021

@bmish 🤞 for a review :)

!isNestedRouteWithSamePath(routeInfo)
) {
const existingRouteInfo = routeMap.get(routeInfo.route.fullPathWithGenericParams);
const routeLookupKey = `${routeInfo.route.blockStatementsTreePrefix}::${routeInfo.route.fullPathWithGenericParams}`;
Copy link
Contributor Author

@raido raido Sep 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For routes that are not within if else blocks, key will look like ::<path> - we could set it global::<path> for easier understanding what's the contents of route map. 🤷‍♂️

@bmish bmish added the Bug label Sep 16, 2021
@bmish bmish changed the title fix(no-shadow-route): support if else statements for route definitions Support if/else route definitions in no-shadow-route-definition rule Sep 16, 2021
Copy link
Member

@bmish bmish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic in this rule is kind of hard to follow, but this looks good based on the test case. Thanks.

@raido
Copy link
Contributor Author

raido commented Sep 20, 2021

It sure has grown over time more complex than original implementation.

Refactoring it should be done in another PR though.

@bmish bmish merged commit 863afc7 into ember-cli:master Sep 20, 2021
@raido raido deleted the fix-if-else-no-shadow-route branch September 27, 2021 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no-shadow-route-definition ignores conditions
2 participants