Skip to content

Commit 471d02d

Browse files
committed
Don't doubly escape error messages. Fixes kratiahuja#34
1 parent 64cc59f commit 471d02d

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

index.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ TSLint.prototype.processString = function(content, relativePath) {
122122

123123
TSLint.prototype.testGenerator = function(relativePath, passed, errors) {
124124
if (errors) {
125-
errors = '\\n' + this.escapeErrorString(errors);
125+
errors = '\n' + errors;
126126
} else {
127127
errors = '';
128128
}
@@ -139,13 +139,6 @@ TSLint.prototype.testGenerator = function(relativePath, passed, errors) {
139139
}
140140
};
141141

142-
TSLint.prototype.escapeErrorString = function(string) {
143-
string = string.replace(/\n/gi, "\\n");
144-
string = string.replace(/'/gi, "\\'");
145-
146-
return string;
147-
};
148-
149142
TSLint.prototype.createLogMessage = function(message, color) {
150143
return chalk[color](message);
151144
}

tests/fixtures/errorFiles/errorFile2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class A {
33
{
44
for(var i = 0; i < 10; ++i){
55
debugger;
6-
eval("something");
6+
eval('something');
77
}
88
}
99
}

tests/index.js

+16
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,22 @@ describe('broccoli-tslinter', function() {
136136
});
137137
});
138138

139+
it('generated test error messages should not be doubly escaped', function() {
140+
var node = new TSLint('./tests/fixtures/errorFiles', {
141+
logError: function(message) {
142+
loggerOutput.push(message);
143+
}
144+
});
145+
builder = new broccoli.Builder(node);
146+
return builder.build().then(function() {
147+
var dir = builder.outputPath;
148+
var testGenerated = readFile(dir + '/errorFile2.lint-test.js');
149+
assert.notInclude(testGenerated, "\\\\' should be", 'Single quotes are not doubly escaped');
150+
assert.notInclude(testGenerated, "should be \\\"", 'Double quotes are not doubly escaped');
151+
assert.notInclude(testGenerated, "\\\\n", 'Newlines are not doubly escaped');
152+
});
153+
});
154+
139155
it('tests should not be generated when disableTestGenerator is true', function() {
140156
var node = new TSLint('./tests/fixtures/errorFiles', {
141157
logError: function(message) {

0 commit comments

Comments
 (0)