From 4b21db14f458e0241c8c13650cde9bb6c2aecef9 Mon Sep 17 00:00:00 2001 From: Jaye Date: Fri, 25 Jun 2021 20:29:58 +0800 Subject: [PATCH 1/3] fix false positives for Less maps --- lib/rules/property-no-unknown/__tests__/index.js | 4 ++++ lib/utils/isStandardSyntaxDeclaration.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/rules/property-no-unknown/__tests__/index.js b/lib/rules/property-no-unknown/__tests__/index.js index 9e901babe5..381ccc8a5b 100644 --- a/lib/rules/property-no-unknown/__tests__/index.js +++ b/lib/rules/property-no-unknown/__tests__/index.js @@ -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', + }, ], }); diff --git a/lib/utils/isStandardSyntaxDeclaration.js b/lib/utils/isStandardSyntaxDeclaration.js index 7362513502..315f46311c 100644 --- a/lib/utils/isStandardSyntaxDeclaration.js +++ b/lib/utils/isStandardSyntaxDeclaration.js @@ -40,6 +40,11 @@ module.exports = function (decl) { return false; } + // Less map declaration + if (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 From 05a4e9f61a3d69db3ea681e28c92896bc94839ff Mon Sep 17 00:00:00 2001 From: Jaye Date: Thu, 15 Jul 2021 13:20:01 +0800 Subject: [PATCH 2/3] Add test to isStandardSyntaxDeclaration.test.js --- lib/utils/__tests__/isStandardSyntaxDeclaration.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/utils/__tests__/isStandardSyntaxDeclaration.test.js b/lib/utils/__tests__/isStandardSyntaxDeclaration.test.js index bfc969d712..6d06fd7f17 100644 --- a/lib/utils/__tests__/isStandardSyntaxDeclaration.test.js +++ b/lib/utils/__tests__/isStandardSyntaxDeclaration.test.js @@ -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) { From 94ce4faae10d5b2a17f8de0a188f6a298756752a Mon Sep 17 00:00:00 2001 From: Jaye Renzo Date: Mon, 19 Jul 2021 09:52:54 +0800 Subject: [PATCH 3/3] Update lib/utils/isStandardSyntaxDeclaration.js Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> --- lib/utils/isStandardSyntaxDeclaration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/isStandardSyntaxDeclaration.js b/lib/utils/isStandardSyntaxDeclaration.js index 315f46311c..cbfd0a6afa 100644 --- a/lib/utils/isStandardSyntaxDeclaration.js +++ b/lib/utils/isStandardSyntaxDeclaration.js @@ -41,7 +41,7 @@ module.exports = function (decl) { } // Less map declaration - if (parent.type === 'atrule' && parent.raws.afterName === ':') { + if (parent && parent.type === 'atrule' && parent.raws.afterName === ':') { return false; }