mirror of
https://github.com/beautifier/js-beautify.git
synced 2025-02-20 13:12:40 +00:00
Merge branch 'main' into bug/css-grid-template-property-fix
This commit is contained in:
commit
fe57c7bd3a
@ -318,7 +318,12 @@ Beautifier.prototype.beautify = function() {
|
||||
this.indent();
|
||||
this._output.set_indent(this._indentLevel);
|
||||
} else {
|
||||
this.indent();
|
||||
// inside mixin and first param is object
|
||||
if (previous_ch === '(') {
|
||||
this._output.space_before_token = false;
|
||||
} else if (previous_ch !== ',') {
|
||||
this.indent();
|
||||
}
|
||||
this.print_string(this._ch);
|
||||
}
|
||||
|
||||
@ -350,6 +355,12 @@ Beautifier.prototype.beautify = function() {
|
||||
this._output.add_new_line(true);
|
||||
}
|
||||
}
|
||||
if (this._input.peek() === ')') {
|
||||
this._output.trim(true);
|
||||
if (this._options.brace_style === "expand") {
|
||||
this._output.add_new_line(true);
|
||||
}
|
||||
}
|
||||
} else if (this._ch === ":") {
|
||||
|
||||
for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) {
|
||||
|
@ -345,7 +345,11 @@ class Beautifier:
|
||||
self.indent()
|
||||
self._output.set_indent(self._indentLevel)
|
||||
else:
|
||||
self.indent()
|
||||
# inside mixin and first param is object
|
||||
if previous_ch == "(":
|
||||
self._output.space_before_token = False
|
||||
elif previous_ch != ",":
|
||||
self.indent()
|
||||
self.print_string(self._ch)
|
||||
|
||||
self.eatWhitespace(True)
|
||||
@ -374,6 +378,10 @@ class Beautifier:
|
||||
):
|
||||
if self._input.peek() != "}":
|
||||
self._output.add_new_line(True)
|
||||
if self._input.peek() == ")":
|
||||
self._output.trim(True)
|
||||
if self._options.brace_style == "expand":
|
||||
self._output.add_new_line(True)
|
||||
elif self._ch == ":":
|
||||
|
||||
for i in range(0, len(self.NON_SEMICOLON_NEWLINE_PROPERTY)):
|
||||
|
@ -1360,9 +1360,8 @@ exports.test_data = {
|
||||
'}',
|
||||
'.set {',
|
||||
' each(@set, {',
|
||||
' @{key}-@{index}: @value;',
|
||||
' }',
|
||||
' );',
|
||||
' @{key}-@{index}: @value;',
|
||||
' });',
|
||||
'}'
|
||||
]
|
||||
},
|
||||
@ -1770,6 +1769,20 @@ exports.test_data = {
|
||||
'{{empty_line_indent}} width: auto;',
|
||||
'}'
|
||||
]
|
||||
}, {
|
||||
comment: 'mixins call with object notation, and brace_style="expand"',
|
||||
input: [
|
||||
'.example({',
|
||||
' color:red;',
|
||||
'});'
|
||||
],
|
||||
output: [
|
||||
'.example(',
|
||||
' {',
|
||||
' color:red;',
|
||||
' }',
|
||||
');'
|
||||
]
|
||||
}, {
|
||||
comment: 'integration test of newline_between_rules, imports, and brace_style="expand"',
|
||||
input: '.a{} @import "custom.css";.rule{}',
|
||||
@ -1796,6 +1809,37 @@ exports.test_data = {
|
||||
' &:extend(a:hover);',
|
||||
'}'
|
||||
]
|
||||
}, {
|
||||
unchanged: [
|
||||
'.test {',
|
||||
' .example({',
|
||||
' color:red;',
|
||||
' });',
|
||||
'}'
|
||||
]
|
||||
}, {
|
||||
unchanged: [
|
||||
'.example2({',
|
||||
' display:none;',
|
||||
'});'
|
||||
]
|
||||
}, {
|
||||
unchanged: [
|
||||
'.aa {',
|
||||
' .mq-medium(a, {',
|
||||
' background: red;',
|
||||
' });',
|
||||
'}'
|
||||
]
|
||||
}, {
|
||||
unchanged: [
|
||||
'@selectors: blue, green, red;',
|
||||
'each(@selectors, {',
|
||||
' .sel-@{value} {',
|
||||
' a: b;',
|
||||
' }',
|
||||
'});'
|
||||
]
|
||||
}, {
|
||||
comment: 'Ensure simple closing parens do not break behavior',
|
||||
unchanged: [
|
||||
|
Loading…
x
Reference in New Issue
Block a user