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

Rules that need autofixers

Open bmish opened this issue 3 years ago • 3 comments

List of rules where it should be easy / practical / useful to implement an autofixer:

This is a good "help wanted" / "first issue" for anyone who wants to help out and claim one or more of these.

Same issue for ember-template-lint: https://github.com/ember-template-lint/ember-template-lint/issues/2571

bmish avatar Aug 07 '22 03:08 bmish

@tgvrssanthosh I created a list of all the Ember array functions/properties we need to handle to track progress. Thanks for working on this.

bmish avatar Oct 07 '22 17:10 bmish

@bmish it seems a bit dangerous to me to have autofixers for the array prototype rule since we can't actually reliably detect if this rule is a false positive or not. iirc ESLint supports fixers as suggestions too, instead of unconditional replacements. this might be a better option for these cases.

Turbo87 avatar Oct 18 '22 06:10 Turbo87

@Turbo87 it's a fair concern. We made the call to proceed with the autofixer because:

  1. The autofixer is obviously dramatically more useful in terms of mass migration compared to suggestions which must be applied individually via the editor UI. The autofixer gives us a better chance of successfully moving the community away from array prototype extensions.
  2. This rule is now opt-in (no longer recommended) so users would presumably be more thoughtful about enabling it.
  3. The rule doc calls out the limitations of the rule regarding false positives in detail. I also previously added heuristics to help mitigate the false positives, although it's not possible to fully mitigate them.
  4. We avoided autofixing reactivity/observability-related functions or properties (as called out in the rule doc).

If it still becomes a problem, we could consider adding an option to the rule that controls whether it's an autofix or suggestion.

bmish avatar Oct 18 '22 13:10 bmish