Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LESS mixin unexpected code formatting #146693

Closed
richmilns opened this issue Apr 4, 2022 · 3 comments
Closed

LESS mixin unexpected code formatting #146693

richmilns opened this issue Apr 4, 2022 · 3 comments
Assignees

Comments

@richmilns
Copy link

Using VSCode 1.66.0 and the new built-in LESS code formatting feature less.format.enable implemented by the JS Beautify library.

When using a LESS mixin that accepts CSS code rules as a parameter (this is used for media query mixins), the formatting when saved is a little unexpected. The formatting is consistent, but it is unusal.

Example code (expected formatting)

.example(@rules) {
    @rules();
}

.test {
    .example({
        color:red;
    });
}

Result after saving

.example(@rules) {
    @rules();
}

.test {
    .example( {
            color:red;
        }

    );
}

Similar issue reported a while back js-beautify issue 722

I've noticed that if you add the following to your settings.json file, the results are slightly better:

"less.format.newlineBetweenRules": false

This gives you formatting like:

.example(@rules) {
    @rules();
}

.test {
    .example( {
            color:red;
        }
    );
}

Apologies if this isn't the right place to report this, but as it was a new feature of VSCode I figured I'd start here.

@aeschli
Copy link
Contributor

aeschli commented Apr 4, 2022

Thanks for the report. We depend on JS Beautify here, so please file issues there.
Maybe we need to disable the formatter again for LESS if LESS is outside the scope of JS Beautify.

1 similar comment
@aeschli
Copy link
Contributor

aeschli commented Apr 4, 2022

Thanks for the report. We depend on JS Beautify here, so please file issues there.
Maybe we need to disable the formatter again for LESS if LESS is outside the scope of JS Beautify.

@richmilns
Copy link
Author

Thanks, can you please advise what the version of js-beautify is that comes with VSCode 1.66.0 ? I cannot seem to find this information anywhere.

The issue was moved to beautifier/js-beautify#2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants