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 ignore: ["first-nested"] options #3179

Merged
merged 1 commit into from Feb 20, 2018

Conversation

4 participants
@jeddy3
Member

jeddy3 commented Feb 19, 2018

Which issue, if any, is this issue related to?

Closes #3178

Is there anything in the PR that needs further explanation?

No, it's self-explanatory.

@ntwb

ntwb approved these changes Feb 20, 2018

LGTM 👍

@jeddy3 jeddy3 merged commit 173a090 into master Feb 20, 2018

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.002%) to 95.525%
Details

@jeddy3 jeddy3 deleted the issue-3178 branch Feb 20, 2018

@jeddy3

This comment has been minimized.

Member

jeddy3 commented Feb 20, 2018

  • Added: ignore: ["first-nested"] to at-rule-empty-line-before (#3179).
  • Added: ignore: ["first-nested"] to rule-empty-line-before (#3179).
@@ -262,6 +262,22 @@ The following patterns are *not* considered violations:
a {}
```
#### `"after-comment"`

This comment has been minimized.

@AlexWayfer

This comment has been minimized.

@jeddy3

jeddy3 Feb 21, 2018

Member

Good spot. Would you like to create to PR to fix this?

This comment has been minimized.

@AlexWayfer
@AlexWayfer

This comment has been minimized.

AlexWayfer commented Feb 21, 2018

@jeddy3

This comment has been minimized.

Member

jeddy3 commented Feb 21, 2018

From here:

  • Use "ignore" when you want the rule to simply skip-over a particular pattern.
  • Use "except" when you want to invert the primary option for a particular pattern.

The ignore option is used when you don't want stylelint to enforce anything for that pattern.

@AlexWayfer

This comment has been minimized.

AlexWayfer commented Feb 21, 2018

Thank you, @jeddy3.

Are there cases (examples) for these rules? I see the issue, but I don't see examples, just "let's make it here like in other rules".

Small explanation: we have except: ["first-nested"] in our projects, and I'm not sure, should we switch to ignore or not.

@jeddy3

This comment has been minimized.

Member

jeddy3 commented Feb 21, 2018

I see the issue, but I don't see examples, just "let's make it here like in other rules".

An option is generally added to a rule when someone has made a specific request and stated their use case e.g. here's the issue that requests the except: ["after-same-name"] option for at-rule-empty-line-before.

Are there cases (examples) for these rules?

The use case of the new ignore options added in this PR can be found in the original issue (#3178) that this PR closes. It's a bit brief I'm afraid, so I understand the confusion. A more detailed use case can be found in the issue that requests the ignore: ["first-nested"] option for declaration-empty-line-before i.e. these options are useful if you use another tool, e.g. prettier, to pretty-print the empty-line before the first nested nodes.

(I've added a link from the original issue to this more detailed use case to make it easier for future users to understand why these two new options were added).

Small explanation: we have except: ["first-nested"] in our projects, and I'm not sure, should we switch to ignore or not.

If you want stylelint to enforce a convention for the first nest node, then stick with except: ["first-nested"]. If you want to stylelint to ignore the first nest node because, perhaps, you use another tool to enforce a convention, then use ignore.

@AlexWayfer

This comment has been minimized.

AlexWayfer commented Feb 21, 2018

Thank you.

Why except option is not named as invert? 😬

I think, "enforce a convention" and "invert the primary option" are pretty different means.

I think I still can't understand except option, but I understood ignore option from the first time.

But OK, I think it's my bad. I understood that if you have always as primary option, then except will set never for listed cases, and vice-versa. And ignore doesn't set any pimary option for listed cases at all.

@jeddy3

This comment has been minimized.

Member

jeddy3 commented Feb 21, 2018

Why except option is not named as invert? 😬

We have to go back a couple of years to answer that one... it seems we borrowed the word from eslint.

I think it still works well enough, though. Take the indentation rule for example:

"indentation": [2, { "except": ["param"] } ]

i.e. indent by 2 spaces except for params.

Unlike words like "always" and "never", there isn't an intuitive inverted value for the number 2. So, "except" might not be the perfect word but it works well enough in a fair few contexts.

I understood that if you have always as primary option, then except will set never for listed cases, and vice-versa. And ignore doesn't set any pimary option for listed cases at all.

Yes, that's correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment