stylefmt
stylefmt copied to clipboard
Option to follow only rules described in .stylelintrc
Hey, it's great that you added support for .stylelintrc
!
I started using it in my project and I have noticed that, apparently, stylefmt
uses a merging strategy when choosing rules: it follows .stylelintrc
rules and also applies stylefmt
's standard ones for the rules it didn't find/recognize in .stylelintrc
.
For instance, I follow stylelint-config-standard rules, where a block like
.selector-x { width: 10%; }
is allowed. Having a .stylelintrc
with these simple contents
{
"extends": "stylelint-config-standard"
}
does not raise an error or a warning when running stylelint
for a block like the one ^. However, it gets auto formatted into
.selector-x {
width: 10%;
}
when I run stylefmt
.
I think it would be great if there was a CLI option --only-stylelint
or something like that which when passed would force stylefmt
to format only the rules found/recognized in .stylelintrc
file and do not do anything extra.
@cbrwizard nice idea, I'd be interested in this as well.
This tool is a strong candidate at my organization, but the enforcement of default rules is a current point of contention. Stylelint does explicitly state that rules are off by default, where as stylefmt will have default values applied for rules even if they are omitted. This seems to be a design difference between stylefmt and the project it is based off of.
Are there plans to realign this difference and allow rules to be off unless they are turned on, such as how stylelint works?
And maybe a better question, would you even want PRs that try to add this behavior? :smile:
Now, stylefmt can handle many stylelint rules, so I decided to implement --onlyStylelint
option. :)
Same issue here. It makes Stylefmt format all places, which are acceptable by Stylelint config file.
It would be great to see --onlyStylelint
, but I'd say it would be more appropriate to make external config file mandatory and instead add --defaultRules
which will apply default rules, because so far Stylefmt goings against Stylelint paradigm, where config isn't default, but completely declarative.
I'd like to see stylefmt
have no rules set by default, then you can choose to enable the rules in the .stylelintrc
/ stylefmt as required.
Is this fixed ? I have the same issue. Thanks
I'm also confused about the state of this issue, and I think it's a vital one to address. Stylefmt making opinionated changes to code that on occasion directly counter what is set in .stylelintrc
seems wrong.
Take, for example, this Stylelint setting: "value-list-comma-newline-after": "always"
This enforces that any declaration with multiple values be formatted on multiple lines. However, Stylefmt automatically reformats value lists to be on one line. So in this case, Stylefmt actually creates a linting error.
I think it's essential that Stylefmt becomes a no-defaults tool so that it is in sync with the tool it uses for configuration.
@morishitter can you confirm, is --onlyStylelint
in the current version (just checking as nothing in the readme regarding it). Thanks for this great tool 👍
@benfrain; I'm afraid not... I can't seem to find it anywhere in the repository: https://github.com/morishitter/stylefmt/search?utf8=%E2%9C%93&q=onlyStylelint.
@morishitter, an update on this would be greatly appreciated.