Skip to content

Commit

Permalink
Fix property-no-unknown false negatives for newer custom syntaxes (#…
Browse files Browse the repository at this point in the history
…6553)

Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
  • Loading branch information
43081j and ybiquitous committed Jan 5, 2023
1 parent 00de033 commit 3874566
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-goats-count.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `property-no-unknown` false negatives for newer custom syntaxes
4 changes: 4 additions & 0 deletions lib/utils/__tests__/isStandardSyntaxDeclaration.test.js
Expand Up @@ -166,6 +166,10 @@ describe('isStandardSyntaxDeclaration', () => {
true,
);
});

it('supports root-level declarations', () => {
expect(isStandardSyntaxDeclaration(decl('color: yellow;'))).toBe(true);
});
});

function decl(css, parser = postcss) {
Expand Down
21 changes: 1 addition & 20 deletions lib/utils/isStandardSyntaxDeclaration.js
@@ -1,14 +1,7 @@
'use strict';

const isScssVariable = require('./isScssVariable');
const { isRoot, isRule } = require('./typeGuards');

/**
* @param {string} [lang]
*/
function isStandardSyntaxLang(lang) {
return lang && (lang === 'css' || lang === 'custom-template' || lang === 'template-literal');
}
const { isRule } = require('./typeGuards');

/**
* Check whether a declaration is standard
Expand All @@ -19,18 +12,6 @@ module.exports = function isStandardSyntaxDeclaration(decl) {
const prop = decl.prop;
const parent = decl.parent;

// Declarations belong in a declaration block or standard CSS source
if (
parent &&
isRoot(parent) &&
parent.source &&
!isStandardSyntaxLang(
/** @type {import('postcss').Source & {lang?: string}} */ (parent.source).lang,
)
) {
return false;
}

// SCSS var; covers map and list declarations
if (isScssVariable(prop)) {
return false;
Expand Down

0 comments on commit 3874566

Please sign in to comment.