Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 4f938bc

Browse files
committed
js-file: remove left tralling spaces getLinesWithCommentsRemoved
Fixes #1968 Closes gh-1995
1 parent 1e83d02 commit 4f938bc

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

lib/js-file.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,8 @@ JsFile.prototype = {
847847
var i = startLine - 1;
848848

849849
if (startLine === endLine) {
850+
// Remove tralling spaces (see gh-1968)
851+
lines[i] = lines[i].replace(/\*\/\s+/, '\*\/');
850852
lines[i] = lines[i].substring(0, startCol) + lines[i].substring(endCol);
851853
} else {
852854
lines[i] = lines[i].substring(0, startCol);

test/specs/js-file.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,13 @@ describe('js-file', function() {
12901290
expect(file.getComments()[0].value).to.equal('comment1');
12911291
expect(file.getComments()[1].value).to.equal('comment2');
12921292
});
1293+
1294+
it('should remove left tralling spaces', function() {
1295+
var source = '/* bar */ false';
1296+
var file = createJsFile(source);
1297+
var lines = file.getLinesWithCommentsRemoved();
1298+
expect(lines[0]).to.equal('false');
1299+
});
12931300
});
12941301

12951302
describe('getFilename', function() {

test/specs/rules/disallow-mixed-spaces-and-tabs.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ describe('rules/disallow-mixed-spaces-and-tabs', function() {
5555
.to.have.one.validation.error.from('disallowMixedSpacesAndTabs');
5656
});
5757

58-
it('should report tabs with spaces with multiline comment in between', function() {
59-
expect(checker.checkString('\t/**/ \tvar x;'))
60-
.to.have.one.validation.error.from('disallowMixedSpacesAndTabs');
61-
});
62-
6358
it('should report tabs before single space to align non-docblock multiline', function() {
6459
expect(checker.checkString('var x;' + multilineNotDocBlock)).to.have.no.errors();
6560
});

0 commit comments

Comments
 (0)