diff --git a/.changeset/empty-goats-count.md b/.changeset/empty-goats-count.md new file mode 100644 index 0000000000..08cca0d360 --- /dev/null +++ b/.changeset/empty-goats-count.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: `property-no-unknown` false negatives for newer custom syntaxes diff --git a/lib/utils/__tests__/isStandardSyntaxDeclaration.test.js b/lib/utils/__tests__/isStandardSyntaxDeclaration.test.js index fcce7bba53..8c928ee3aa 100644 --- a/lib/utils/__tests__/isStandardSyntaxDeclaration.test.js +++ b/lib/utils/__tests__/isStandardSyntaxDeclaration.test.js @@ -166,6 +166,10 @@ describe('isStandardSyntaxDeclaration', () => { true, ); }); + + it('supports root-level declarations', () => { + expect(isStandardSyntaxDeclaration(decl('color: yellow;'))).toBe(true); + }); }); function decl(css, parser = postcss) { diff --git a/lib/utils/isStandardSyntaxDeclaration.js b/lib/utils/isStandardSyntaxDeclaration.js index 2f1f8b5787..e258a7d89f 100644 --- a/lib/utils/isStandardSyntaxDeclaration.js +++ b/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 @@ -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;