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 false positives for Less maps in property-no-unknown #5381

Merged
merged 3 commits into from Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions lib/rules/property-no-unknown/__tests__/index.js
Expand Up @@ -123,6 +123,10 @@ testRule({
code: '.foo { transform+_: rotate(15deg); }',
description: 'Append property value with space using +_',
},
{
code: '@foo: { prop: red; }',
description: 'ignore LESS map props',
},
],
});

Expand Down
4 changes: 4 additions & 0 deletions lib/utils/__tests__/isStandardSyntaxDeclaration.test.js
Expand Up @@ -152,6 +152,10 @@ describe('isStandardSyntaxDeclaration', () => {
it('less &:extend', () => {
expect(isStandardSyntaxDeclaration(lessDecl('a { &:extend(b) }'))).toBe(false);
});

it('less map', () => {
expect(isStandardSyntaxDeclaration(lessDecl('@map: { key: value; }'))).toBe(false);
});
});

function decl(css, parser = postcss) {
Expand Down
5 changes: 5 additions & 0 deletions lib/utils/isStandardSyntaxDeclaration.js
Expand Up @@ -40,6 +40,11 @@ module.exports = function (decl) {
return false;
}

// Less map declaration
if (parent.type === 'atrule' && parent.raws.afterName === ':') {
This conversation was marked as resolved.
Show resolved Hide resolved
return false;
}

// Sass nested properties (e.g. border: { style: solid; color: red; })
if (
// @ts-ignore TODO TYPES selector does not exists
Expand Down