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 previous selector line number to message of no-duplicate-selectors #2415

Merged
merged 2 commits into from
Mar 15, 2017

Conversation

hudochenkov
Copy link
Member

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

#2303

Is there anything in the PR that needs further explanation?

Should I find a way to report precise line for duplication in multiline selector list? These tests. Rule itself reports selector position and not a precise position of duplicated selector within multiline selector list.

Warning will show the first occurrence of duplicated selector, rather previous one. This behavior is clearly visible in system test 005 behaviour.

Copy link
Contributor

@davidtheclark davidtheclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! I think we should adjust the message's wording a little, then we should merge.

@@ -13,7 +13,7 @@ const resolvedNestedSelector = require("postcss-resolve-nested-selector")
const ruleName = "no-duplicate-selectors"

const messages = ruleMessages(ruleName, {
rejected: selector => `Unexpected duplicate selector "${selector}"`,
rejected: (selector, firstDuplicateLine) => `Unexpected duplicate selector "${selector}" is also at line ${firstDuplicateLine}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change this wording to Unexpected duplicate of selector "${selector}" at line ${firstDuplicateLine}.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's very confusing. User might understand, that duplicated selector at line firstDuplicateLine, rather at line stylelint reports for this message.

16:1 Unexpected duplicate of selector "a" at line 3

I would think duplicate selector is at line 3. And it'd take some time to understand that it's at line 16.

What about Unexpected duplicate selector "${selector}", first occurrence at line ${firstDuplicateLine}? Maybe “occurrence” could be replaced with other word.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! How about "used" instead of "occurrence": Unexpected duplicate selector "${selector}", first used at line ${firstDuplicateLine}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like it! Changed it.

@davidtheclark
Copy link
Contributor

Great @hudochenkov. Feel free to merge.

@hudochenkov hudochenkov merged commit 5269b15 into master Mar 15, 2017
@hudochenkov
Copy link
Member Author

Added to changelog:

  • Added: duplicate selector first usage line to no-duplicate-selector message (#2415)

@hudochenkov hudochenkov deleted the no-duplicate-selectors-improvements branch March 15, 2017 18:08
alexander-akait pushed a commit that referenced this pull request Mar 21, 2017
#2415)

* Add previous selector line number to message of no-duplicate-selectors

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

Successfully merging this pull request may close these issues.

2 participants