Skip to content

Commit

Permalink
fix empty comments at rule copy
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-ershkov committed Oct 8, 2024
1 parent 09432fd commit f6c9253
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {Container} from "postcss";
import { Container } from 'postcss';

export const hasEmptyChildNodes = ({nodes}: Container) => !nodes || nodes.length === 0
export const hasEmptyChildNodes = ({ nodes }: Container) => {
const significantNodes = nodes.filter((node) => node.type !== 'comment');
return !significantNodes || significantNodes.length === 0;
};
38 changes: 38 additions & 0 deletions packages/postcss-logical-fallback/tests/no-changes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { test } from 'uvu';
import { run } from './run';

test('should not copy comments', async () => {
await run(
`body {
/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
min-height: 100vh;
padding: 2rem;
}`,
`body {
/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
min-height: 100vh;
padding: 2rem;
}`,
);

await run(
`.class {
/*
multiline
comment
*/
min-height: 100vh;
padding: 2rem;
}`,
`.class {
/*
multiline
comment
*/
min-height: 100vh;
padding: 2rem;
}`,
);
});

test.run();

0 comments on commit f6c9253

Please sign in to comment.