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

Add new rule template-no-let-reference #1939

Merged
merged 3 commits into from
Nov 3, 2023

Conversation

patricklx
Copy link
Contributor

@patricklx patricklx commented Aug 22, 2023

resolves #1897

if (!scope) {
return { scope: findParentScope(scopeManager, nodePath) };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

needed to fix the current scope, as the references should be added in the scope where the references are and not where the variable definition is

@@ -399,6 +386,20 @@ function convertAst(result, preprocessedResult, visitorKeys) {
registerNodeInScope(node, scope, variable);
}
}

if ('blockParams' in node) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

needed to move this down. this creates the scope for elementnodes and mustache blocks.
it should do this after creating the references, as otherwise the current scope would be the element or mustache block itself

"ember/use-ember-data-rfc-395-imports": "error",
"ember/template-no-let-reference": "error"
Copy link
Member

@bmish bmish Aug 22, 2023

Choose a reason for hiding this comment

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

The set of recommended rules should only be updated during a major release. If you like, we can enable it as recommended at that time.

@patricklx patricklx mentioned this pull request Oct 31, 2023
@patricklx patricklx force-pushed the template-no-let-reference branch 7 times, most recently from ecd1507 to d7e52d8 Compare November 2, 2023 10:51
@NullVoxPopuli
Copy link
Contributor

needs rebase it looks like

}

export default <template>{{foo}}</template>;
````
Copy link
Member

Choose a reason for hiding this comment

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

There's an extra tick.

@@ -73,6 +73,7 @@ module.exports = {
"ember/require-tagless-components": "error",
"ember/require-valid-css-selector-in-test-helpers": "error",
"ember/routes-segments-snake-case": "error",
"ember/template-no-let-reference": "error",
Copy link
Member

Choose a reason for hiding this comment

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

Can we have a separate PR to enable any rules as recommended? It's more clear what's going on then and will be better for the resulting changelog. Normally, we never create rules at the same time as enabling them as recommended.

@bmish bmish changed the title add template-no-let-reference rule Add new rule template-no-let-reference Nov 2, 2023
@bmish bmish merged commit 372f6b8 into ember-cli:master Nov 3, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New rule to lint against referencing let variables in <template>
3 participants