From c0bca1805de45d5f1aab9628cf45af64e4ef00fc Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Tue, 1 Sep 2020 15:28:11 +0800 Subject: [PATCH] Remove `css` parser from `isLessParser` check (#9092) --- src/language-css/parser-postcss.js | 7 +++---- src/language-css/printer-postcss.js | 5 ++--- src/language-css/utils.js | 6 ------ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/language-css/parser-postcss.js b/src/language-css/parser-postcss.js index 8430cdc08..c5a47ea75 100644 --- a/src/language-css/parser-postcss.js +++ b/src/language-css/parser-postcss.js @@ -6,7 +6,6 @@ const { hasPragma } = require("./pragma"); const { hasSCSSInterpolation, hasStringOrFunction, - isLessParser, isSCSS, isSCSSNestedPropertyNode, isSCSSVariable, @@ -414,7 +413,7 @@ function parseNestedCSS(node, options) { } if ( - isLessParser(options) && + options.parser === "less" && node.type === "css-decl" && value.startsWith("extend(") ) { @@ -431,7 +430,7 @@ function parseNestedCSS(node, options) { } if (node.type === "css-atrule") { - if (isLessParser(options)) { + if (options.parser === "less") { // mixin if (node.mixin) { const source = @@ -461,7 +460,7 @@ function parseNestedCSS(node, options) { return node; } - if (isLessParser(options)) { + if (options.parser === "less") { // Whitespace between variable and colon if (node.name.includes(":") && !node.params) { node.variable = true; diff --git a/src/language-css/printer-postcss.js b/src/language-css/printer-postcss.js index d17de5e6e..9eb0fde25 100644 --- a/src/language-css/printer-postcss.js +++ b/src/language-css/printer-postcss.js @@ -40,7 +40,6 @@ const { isWideKeywords, isSCSS, isLastNode, - isLessParser, isSCSSControlDirectiveNode, isDetachedRulesetDeclarationNode, isRelationalOperatorNode, @@ -158,7 +157,7 @@ function genericPrint(path, options, print) { trimmedBetween.startsWith("//") ? " " : "", trimmedBetween, node.extend ? "" : " ", - isLessParser(options) && node.extend && node.selector + options.parser === "less" && node.extend && node.selector ? concat(["extend(", path.call(print, "selector"), ")"]) : "", value, @@ -202,7 +201,7 @@ function genericPrint(path, options, print) { !parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";"; - if (isLessParser(options)) { + if (options.parser === "less") { if (node.mixin) { return concat([ path.call(print, "selector"), diff --git a/src/language-css/utils.js b/src/language-css/utils.js index c94814de3..b272028cc 100644 --- a/src/language-css/utils.js +++ b/src/language-css/utils.js @@ -415,11 +415,6 @@ function isColorAdjusterFuncNode(node) { return colorAdjusterFunctions.has(node.value.toLowerCase()); } -// TODO: only check `less` when we don't use `less` to parse `css` -function isLessParser(options) { - return options.parser === "css" || options.parser === "less"; -} - function lastLineHasInlineComment(text) { return /\/\//.test(text.split(/[\n\r]/).pop()); } @@ -477,7 +472,6 @@ module.exports = { isSCSS, isSCSSVariable, isLastNode, - isLessParser, isSCSSControlDirectiveNode, isDetachedRulesetDeclarationNode, isRelationalOperatorNode,