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

[BUG] require-computed-macros can autofix to self-referential macros #1118

Open
runspired opened this issue Mar 27, 2021 · 3 comments · May be fixed by #1121
Open

[BUG] require-computed-macros can autofix to self-referential macros #1118

runspired opened this issue Mar 27, 2021 · 3 comments · May be fixed by #1121
Labels

Comments

@runspired
Copy link

Given the following (admittedly incorrect) computed usage

storeIds: computed("storeIds", "line", function() {
        return this.storeIds;
    }),

This rule will convert it to the following, which blows up since the self-referential nature becomes more evident when an alias is installed under the hood.

storeIds: computed.reads('storeIds')

A better conversion would be

storeIds: null
@bmish
Copy link
Member

bmish commented Mar 27, 2021

I wonder if it's worth creating a separate rule no-self-referencing-computed-properties?

@runspired
Copy link
Author

@bmish for the first example, absolutely. But since an existing rule also modifies that first example we'd have to make sure they didn't interfere with each other. It's also unlikely you end up with a self-referential computed using a macro without using autofix since it results in application errors almost immediately. Running this on a large app turned out to be problematic since now I'm chasing down self-referentials. Trying to decide whether to patch this rule to convert them better or if I submit a new rule.

@bmish
Copy link
Member

bmish commented Mar 28, 2021

I actually think the new rule no-self-referencing-computed-properties should catch both macro and non-macro computed properties. No reason to limit it to just one computed property form. This new rule would serve to make it clear that something is likely seriously wrong with the self-referencing computed property in a way that requires user attention.

If we make any changes to require-computed-macros, I would just remove the autofix for this situation. I would not consider it acceptable to autofix to storeIds: null as that's a behavior change and hides the fact that something is broken and needs manual attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants