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

Add disableFix to scales/font-weights #71

Closed
siarheiyelin opened this issue Apr 1, 2021 · 3 comments
Closed

Add disableFix to scales/font-weights #71

siarheiyelin opened this issue Apr 1, 2021 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@siarheiyelin
Copy link

siarheiyelin commented Apr 1, 2021

What is the problem you're trying to solve?

Disable auto-fix for "scales/font-weights" rule. However the similar feature would be useful for other rules from this lib as well. The main reason is that auto-fix makes potentially breaking changes to the app functionality. E.g. when next rule is defined:
'scales/font-weights': [100, 300, 400, 500, 700]
And auto-fix is applied, then it's not always safe to replace font-weight to closest value from the list. I would prefer to fix it manually, because it either may require updating other CSS as well to make it work correctly. Or it may require updating list of allowed values.

What solution would you like to see?

Add some option like in the example below to all rules which make potentially breaking changes, e.g.:
'scales/font-weights': { [100, 300, 400, 500, 700], {
disableAutoFix: true,
}]

@jeddy3 jeddy3 changed the title Possibility to optionally disable autoFix for the rule. Add disableFix to scales/font-weights Apr 1, 2021
@jeddy3 jeddy3 added enhancement New feature or request help wanted Extra attention is needed labels Apr 1, 2021
@jeddy3
Copy link
Owner

jeddy3 commented Apr 1, 2021

Thanks for the request, for using the template and for writing up your use case clearly.

We can add a disableFix secondary option, as recommended in the writing plugin guidelines.

I know stylelint-order has this option: example code, tests and docs.

We should be able to use default parameters, i.e.:

const rule = (primary, secondary = { disableFix: false }, { fix }) => {
 ..
  if (
      !validateOptions(result, ruleName, {
        actual: primary,
        possible: hasNumericScale,
      },
      {
        actual: secondary,
        possible: {
          disableFix: Boolean,
        },
        optional: true,
      })
    )
      return;
   ..
   if (fix && !disableFix) { .. }
}

Would you like to contribute a pull request for this?

@vmohir
Copy link

vmohir commented Sep 18, 2021

The disableFix option should be available for all rules. In our use case, we just want to have a warning and fix them manually.

@jeddy3
Copy link
Owner

jeddy3 commented Sep 18, 2021

We recently added a disableFix option to stylelint itself which will work for rules in plugins too.

It'll be available in the next major release of stylelint.

@jeddy3 jeddy3 closed this as completed Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants