Skip to content

Commit

Permalink
fix(no-unused-css): blank lines being left after fixing (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelss95 authored and mgechev committed Aug 28, 2018
1 parent 0bac287 commit c69e2ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit c69e2ae

Please sign in to comment.