Skip to content

Commit

Permalink
Fix false positives for Less maps in property-no-unknown (#5381)
Browse files Browse the repository at this point in the history
* fix false positives for Less maps

* Add test to isStandardSyntaxDeclaration.test.js

* Update lib/utils/isStandardSyntaxDeclaration.js

Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>

Co-authored-by: Jaye <jaye@whitewidget.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
  • Loading branch information
3 people committed Jul 26, 2021
1 parent 47716e5 commit 97d5151
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rules/property-no-unknown/__tests__/index.js
Expand Up @@ -124,6 +124,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 @@ -134,6 +134,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 @@ -41,6 +41,11 @@ module.exports = function (decl) {
return false;
}

// Less map declaration
if (parent && parent.type === 'atrule' && parent.raws.afterName === ':') {
return false;
}

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

0 comments on commit 97d5151

Please sign in to comment.