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 optional name to extended rule object #119

Merged
merged 3 commits into from
May 30, 2020
Merged

Add optional name to extended rule object #119

merged 3 commits into from
May 30, 2020

Conversation

pajter
Copy link
Contributor

@pajter pajter commented May 20, 2020

First of all, thanks for this plugin! It's really helpful.

I've added the ability to name an extended rule object. This can improve the user experience by showing a more friendly error message.

Here's an example:

{
  type: 'rule',
  name: 'Pseudo Element',
  selector: /^&::/,
},
{
  type: 'rule',
  name: 'BEM Element',
  selector: /^&__/,
}

Instead of this message:

Expected rule with selector matching "/^&::/" to come before rule with selector matching "/^&__/"

You would get this message:

Expected rule "Pseudo Element" to come before rule "BEM Element".

I updated the docs, changelog and tests. Please let me know if I missed anything!

Copy link
Owner

@hudochenkov hudochenkov left a comment

Choose a reason for hiding this comment

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

That's a great idea!

Everything looks very good. Thank you for putting extra effort and adding tests!

Could you please update

if (item.type === 'rule') {
to include:

if (!_.isUndefined(item.name)) {
	result = _.isString(item.name) && item.name.length;
}

It will check name property if it's valid.

@pajter
Copy link
Contributor Author

pajter commented May 30, 2020

Good catch! I added the extra check and some more tests.

@hudochenkov hudochenkov merged commit 5d2a8ca into hudochenkov:master May 30, 2020
@hudochenkov
Copy link
Owner

Thank you! I'll try to release this weekend.

@hudochenkov
Copy link
Owner

stylelint-order@4.1.0 is released!

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

Successfully merging this pull request may close these issues.

2 participants