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

Fix max-empty-lines before comments #5507

Merged
merged 5 commits into from Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/rules/max-empty-lines/__tests__/index.js
Expand Up @@ -120,6 +120,13 @@ testRule({
line: 5,
column: 1,
},
{
code: 'a {}\n\n\n/** horse */\n\nb {}',
fixed: 'a {}\n\n/** horse */\n\nb {}',
message: messages.expected(1),
line: 3,
column: 1,
},
{
code: 'a {}\r\n\r\n/** horse */\r\n\r\n\r\nb {}',
fixed: 'a {}\r\n\r\n/** horse */\r\n\r\nb {}',
Expand Down
15 changes: 3 additions & 12 deletions lib/rules/max-empty-lines/index.js
Expand Up @@ -50,23 +50,14 @@ function rule(max, options, context) {
if (context.fix) {
root.walk((node) => {
if (node.type === 'comment') {
// for inline comments
if (node.raws.inline) {
node.raws.before = getChars(node.raws.before);
}

if (!ignoreComments) {
node.raws.left = getChars(node.raws.left);
node.raws.right = getChars(node.raws.right);
}
} else {
if (node.raws.before) {
node.raws.before = getChars(node.raws.before);
}
}

if (node.raws.after) {
node.raws.after = getChars(node.raws.after);
}
if (node.raws.before) {
node.raws.before = getChars(node.raws.before);
}
});

Expand Down
2 changes: 0 additions & 2 deletions system-tests/003/__snapshots__/no-fs.test.js.snap
Expand Up @@ -15,7 +15,6 @@ Object {
/* Your images should be linked as if the CSS file sits in the same folder as the images. ie. no paths. */
/* basic elements */
html {
margin: 0;
Expand Down Expand Up @@ -66,7 +65,6 @@ abbr {
border-bottom: none;
}
/* specific divs */
.page-wrapper {
background: url(http://csszengarden.com/001/zen-bg.jpg) no-repeat top left;
Expand Down