I recently set up Stylelint to run through my stylesheets but there's an error it's throwing that I'd rather keep as-is:
The error is that I'm not using a single space before the {
and while I'd like this to be true for most other instances for legibility I was hoping to keep this one.
Is it possible to either modify the rule to allow these sorts of indentation patterns or otherwise disable a rule for a block of CSS? The latter is not ideal but I'll take what I can get.
Otherwise I'll likely just ignore it.
I think the rule in question is block-opening-brace-space-before
.
If you want to only enforce a single space before the opening brace of multiline blocks and ignore single-line blocks, then you can do so using the rule's always-multi-line
primary option:
/* Enforce a single space before this opening brace */
a {
color: red;
}
/* Don't enforce anything before this opening brace */
a { color: red; }
There is, however, no option to specifically ignore the opening braces of single-line keyframe declaration blocks. If this is what you want then please raise a feature request issue.
Is it possible to either modify the rule to allow these sorts of indentation patterns
You can create a plugin that enforces the alignment of the open braces of single-line keyframe declaration blocks within each @keyframe.
otherwise disable a rule for a block of CSS?
You can use stylelint-disable commands to turn off the block-opening-brace-space-before
rule for this block of code.