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

Fix Option for Removing Zombies #153

Open
simon-lammes opened this issue Dec 27, 2023 · 1 comment
Open

Fix Option for Removing Zombies #153

simon-lammes opened this issue Dec 27, 2023 · 1 comment

Comments

@simon-lammes
Copy link

Feature: Fix Option for Removing Zombies

As a devoloper, I would like to run this linter with a fix option so that all zombies are automatically removed.

When is this useful?

  • When integrating this linter into an existing project, you might find 100+ zombies that you don't want to remove manually.
  • When removing pages in an existing project, you might want to remove all their translations automatically.

Propsed API

I propose adding a --fix flag, similar to eslint.

With this option, all errors that can be fixed will be fixed and all other errors will be outputted as usual.

The performed fixes are also part of the CLI output (ResultCliModel), but a very consice output like "9 fixes applied" would be sufficient.

Proposed Internal Implementation

IRule is extended with an optional fix method. It outputs a new ResultFixModel containing the fixed ResultErrorModel array and the modified/fixed FileLanguageModel (aka. specified translations in en.json).

After running all lints and excluding ignoredKeys, we run all available fix methods. If the outputted FileLanguageModel differs from the original, we persist those changes. We also remove all errors that were being fixed.

Alternatives

I considered extending the ErrorTypes enum with a fix value but this would have some disadvantages:

  • The purpose of the enum would be ambiguous. The enum should only describe the significance of the error ("disabled", "warning", "error") and not what we should do with it.
  • It would be overkill. We either want "just lint" or we want to apply fixes. There is no need for something more flexible.
  • It would deviate from eslint's API convention for no good reason.

Considerations

Does this feature fit well within the scope of this project or would it make more sense to consider it a separate project? Personally, I think it fits well because this feature would benefit from existing functionality and configurations such as ignoredKeys, customRegExpToFindKeys etc.

@itekaf What do you think about this proposal and would you consider looking into a PR (from anyone) addressing this feature?

@itekaf
Copy link
Owner

itekaf commented Dec 27, 2023

@simon-lammes
thats sounds great! Greate feture and if something will be create PR I will be happy :) Or I can implement this future on future

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

No branches or pull requests

2 participants