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(no-unused-css): blank lines being left after fixing #701

Merged
merged 1 commit into from
Aug 28, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/noUnusedCssRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class UnusedCssVisitor extends BasicCssAstVisitor {
} = ast;
// length + 1 because we want to drop the '}'
const length = endOffset - startOffset + 1;
this.addFailureAt(startOffset, length, 'Unused styles', this.createReplacement(startOffset, length, ''));
this.addFailureAt(startOffset, length, 'Unused styles', Lint.Replacement.deleteText(startOffset - 1, length + 1));
}
} catch (e) {
logger.error(e);
Expand Down
8 changes: 4 additions & 4 deletions test/noUnusedCssRule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,8 @@ describe('no-unused-css', () => {
)!;
const replacement = failures[0].getFix() as Replacement;
expect(replacement.text).to.eq('');
expect(replacement.start).to.eq(199);
expect(replacement.end).to.eq(246);
expect(replacement.start).to.eq(14);
expect(replacement.end).to.eq(62);
});

it('should work with SASS', () => {
Expand Down Expand Up @@ -919,8 +919,8 @@ describe('no-unused-css', () => {
Config.transformStyle = (code: string) => ({ code, map: null });
const replacement = failures[0].getFix() as Replacement;
expect(replacement.text).to.eq('');
expect(replacement.start).to.eq(168);
expect(replacement.end).to.eq(271); // should be 276
expect(replacement.start).to.eq(-1);
expect(replacement.end).to.eq(29);
});
});

Expand Down