Skip to content

Commit c0bca18

Browse files
authored
Remove css parser from isLessParser check (prettier#9092)
1 parent c61638f commit c0bca18

3 files changed

Lines changed: 5 additions & 13 deletions

File tree

src/language-css/parser-postcss.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const { hasPragma } = require("./pragma");
66
const {
77
hasSCSSInterpolation,
88
hasStringOrFunction,
9-
isLessParser,
109
isSCSS,
1110
isSCSSNestedPropertyNode,
1211
isSCSSVariable,
@@ -414,7 +413,7 @@ function parseNestedCSS(node, options) {
414413
}
415414

416415
if (
417-
isLessParser(options) &&
416+
options.parser === "less" &&
418417
node.type === "css-decl" &&
419418
value.startsWith("extend(")
420419
) {
@@ -431,7 +430,7 @@ function parseNestedCSS(node, options) {
431430
}
432431

433432
if (node.type === "css-atrule") {
434-
if (isLessParser(options)) {
433+
if (options.parser === "less") {
435434
// mixin
436435
if (node.mixin) {
437436
const source =
@@ -461,7 +460,7 @@ function parseNestedCSS(node, options) {
461460
return node;
462461
}
463462

464-
if (isLessParser(options)) {
463+
if (options.parser === "less") {
465464
// Whitespace between variable and colon
466465
if (node.name.includes(":") && !node.params) {
467466
node.variable = true;

src/language-css/printer-postcss.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const {
4040
isWideKeywords,
4141
isSCSS,
4242
isLastNode,
43-
isLessParser,
4443
isSCSSControlDirectiveNode,
4544
isDetachedRulesetDeclarationNode,
4645
isRelationalOperatorNode,
@@ -158,7 +157,7 @@ function genericPrint(path, options, print) {
158157
trimmedBetween.startsWith("//") ? " " : "",
159158
trimmedBetween,
160159
node.extend ? "" : " ",
161-
isLessParser(options) && node.extend && node.selector
160+
options.parser === "less" && node.extend && node.selector
162161
? concat(["extend(", path.call(print, "selector"), ")"])
163162
: "",
164163
value,
@@ -202,7 +201,7 @@ function genericPrint(path, options, print) {
202201
!parentNode.raws.semicolon &&
203202
options.originalText[options.locEnd(node) - 1] !== ";";
204203

205-
if (isLessParser(options)) {
204+
if (options.parser === "less") {
206205
if (node.mixin) {
207206
return concat([
208207
path.call(print, "selector"),

src/language-css/utils.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,6 @@ function isColorAdjusterFuncNode(node) {
415415
return colorAdjusterFunctions.has(node.value.toLowerCase());
416416
}
417417

418-
// TODO: only check `less` when we don't use `less` to parse `css`
419-
function isLessParser(options) {
420-
return options.parser === "css" || options.parser === "less";
421-
}
422-
423418
function lastLineHasInlineComment(text) {
424419
return /\/\//.test(text.split(/[\n\r]/).pop());
425420
}
@@ -477,7 +472,6 @@ module.exports = {
477472
isSCSS,
478473
isSCSSVariable,
479474
isLastNode,
480-
isLessParser,
481475
isSCSSControlDirectiveNode,
482476
isDetachedRulesetDeclarationNode,
483477
isRelationalOperatorNode,

0 commit comments

Comments
 (0)