eslint-plugin-ember icon indicating copy to clipboard operation
eslint-plugin-ember copied to clipboard

ember/no-assignment-of-untracked-properties-used-in-tracking-contexts should not be fixable

Open ginomiglio opened this issue 4 years ago • 4 comments

Since there are multiple ways to fix this error, the autofixer should not arbitrarily choose one. I had to disable this rule in the project I'm working on because it's adding calls to set() when what I really needed to do was make the property @tracked.

(As a side note, it also added an import from @ember/object that conflicted with an existing import, causing a different lint error. There may be an unrelated problem with that rule.)

cc @bmish

ginomiglio avatar Oct 13 '20 21:10 ginomiglio

(Can the autofixer read rule options? Maybe it could be off by default and the fix strategy could be configurable.)

ginomiglio avatar Oct 13 '20 21:10 ginomiglio

Thanks for bringing this up. I am interested to consider how we can optimize our linting for Ember Octane best practices including using tracked properties.

If needed, we could have multiple autofixing strategies configurable by a rule option:

  • autofixStrategy = set - current fixing strategy, changes this.x = 123 to set(this, 'x', 123) for untracked properties
  • autofixStrategy = tracked - potential new strategy, would add @tracked x if it sees this.x = 123 for an untracked property
    • Open question: Assuming the user is on Ember Octane, would this fix be safe, or would this always be too aggressive of a fix to make?
  • autofixStrategy = none - potential new strategy

There's another open question about what the default should be. Once all supported Ember LTS versions are 3.16 or above, we can change defaults to be targeted at Ember Octane.

@mongoose700 @rwjblue @Turbo87 thoughts?

bmish avatar Oct 14 '20 21:10 bmish

I think the customizable autofix makes sense.

mongoose700 avatar Oct 14 '20 22:10 mongoose700

@bmish https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions might be relevant for this

Turbo87 avatar Oct 25 '20 14:10 Turbo87