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

Fix parseError for double-slash comments within selector lists in no-descending-specificity #5891

Merged
merged 1 commit into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/rules/no-descending-specificity/__tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const postcssScss = require('postcss-scss');
const postcssLess = require('postcss-less');
const stripIndent = require('common-tags').stripIndent;

const { messages, ruleName } = require('..');

Expand Down Expand Up @@ -172,6 +174,22 @@ testRule({
],
});

testRule({
ruleName,
customSyntax: postcssLess,
config: [true],

accept: [
{
code: stripIndent`
a,
// comment2
b {}
`,
},
],
});

testRule({
skip: true,
ruleName,
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/__tests__/isStandardSyntaxSelector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ describe('isStandardSyntaxSelector', () => {
expect(isStandardSyntaxSelector('.foo(@a)')).toBeFalsy();
expect(isStandardSyntaxSelector('.foo(@a: 5px)')).toBeFalsy();
});

it('SCSS or Less comments', () => {
expect(isStandardSyntaxSelector('a\n// comment\nb')).toBeFalsy();
expect(isStandardSyntaxSelector('a\n//comment\nb')).toBeFalsy();
});
it('ERB templates', () => {
// E. g. like in https://github.com/stylelint/stylelint/issues/4489
expect(isStandardSyntaxSelector('<% COLORS.each do |color| %>\na')).toBe(false);
Expand Down
5 changes: 5 additions & 0 deletions lib/utils/isStandardSyntaxSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ module.exports = function (selector) {
return false;
}

// SCSS and Less comments
if (selector.includes('//')) {
return false;
}

return true;
};