mansona / lint-to-the-future

A modern way to progressively update your code to the best practices
54 stars 7 forks source link

lint-to-the-future remove command #21

Open mansona opened 2 years ago

mansona commented 2 years ago

We want to be able to run the command npx lint-to-the-future remove "rule-name" and it would remove all rule-name ignores from every file that it happens in.

To be more specific, if you run npx lint-to-the-future list and it reported the following:

{
  '2022-09-30': {
    'lint-to-the-future-ember-template': {
      'no-redundant-landmark-role': [Array]
    },
    'lint-to-the-future-eslint': {
      'ember/no-empty-glimmer-component-classes': [Array],
      'ember/no-classic-components': [Array],
      'ember/no-classic-classes': [Array],
      'ember/require-tagless-components': [Array]
    }
  }
}

and then you ran the following command:

npx lint-to-the-future remove "ember/no-classic-classes"

running npx lint-to-the-future list again would report:

{
  '2022-09-30': {
    'lint-to-the-future-ember-template': {
      'no-redundant-landmark-role': [Array]
    },
    'lint-to-the-future-eslint': {
      'ember/no-empty-glimmer-component-classes': [Array],
      'ember/no-classic-components': [Array],
      'ember/require-tagless-components': [Array]
    }
  }
}

Implementation considerations:

rtablada commented 1 year ago

While it doesn't look for particular rules, I have implemented a autofix command in https://github.com/rtablada/pod-workflow-cli which will remove lint ignores for a given file or directory (with CLI input or an interactive file tree using inquirer).

While a some of that tool is currently coupled to a pod structure deprecation/lint flow, there could be prior art there that could be moved into a lint-to-the-future command

Consideration here though is that LTTF would likely want to move the logic of regex replacement and delegate that to the plugin.