Skip to content

Commit

Permalink
Fix semicolon duplicated at the end of file
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 18, 2022
1 parent b50dfd1 commit 80fd76d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
19 changes: 19 additions & 0 deletions changelog_unreleased/less/14007.md
@@ -0,0 +1,19 @@
#### Fix semicolon duplicated at the end of LESS file (#14007 by @mvorisek)

<!-- prettier-ignore -->
```less
// Input
@variable: {
field: something;
};

// Prettier stable
@variable: {
field: something;
}; ;

// Prettier main
@variable: {
field: something;
};
```
5 changes: 4 additions & 1 deletion src/language-css/printer-postcss.js
Expand Up @@ -101,7 +101,10 @@ function genericPrint(path, options, print) {
return [node.raw, hardline];
case "css-root": {
const nodes = printNodeSequence(path, options, print);
const after = node.raws.after.trim();
let after = node.raws.after.trim();
if (after.startsWith(";")) {
after = after.slice(1).trim();
}

return [
nodes,
Expand Down
18 changes: 18 additions & 0 deletions tests/format/less/less/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -83,6 +83,24 @@ a: b;
================================================================================
`;

exports[`issue-11483--never-append-anything.less format 1`] = `
====================================options=====================================
parsers: ["less"]
printWidth: 80
| printWidth
=====================================input======================================
@variable: {
field: something;
};
=====================================output=====================================
@variable: {
field: something;
};
================================================================================
`;

exports[`less.less format 1`] = `
====================================options=====================================
parsers: ["less"]
Expand Down
@@ -0,0 +1,3 @@
@variable: {
field: something;
};

0 comments on commit 80fd76d

Please sign in to comment.