mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Remove trailing space from emitLeadingComment
This will prevent emiting an extraneous trailing space on comments to match https://eslint.org/docs/rules/no-trailing-spaces This also removes a space that may have been originally there after a comment but isn't necessary syntactically.
This commit is contained in:
@@ -274,9 +274,6 @@ namespace ts {
|
||||
if (hasTrailingNewLine) {
|
||||
writer.writeLine();
|
||||
}
|
||||
else {
|
||||
writer.write(" ");
|
||||
}
|
||||
}
|
||||
|
||||
function emitLeadingCommentsOfPosition(pos: number) {
|
||||
|
||||
@@ -24,7 +24,7 @@ var n: number;
|
||||
|
||||
|
||||
//// [decls.js]
|
||||
// Ambient external import declaration referencing ambient external module using top level module name
|
||||
// Ambient external import declaration referencing ambient external module using top level module name
|
||||
//// [consumer.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
|
||||
@@ -87,4 +87,4 @@ function foo(x, y, z) {
|
||||
// x = a;
|
||||
// y = a;
|
||||
// z = a;
|
||||
//}
|
||||
//}
|
||||
|
||||
@@ -46,4 +46,4 @@ var c5c = /** @class */ (function () {
|
||||
c5c.prototype.foo = function () { };
|
||||
return c5c;
|
||||
}());
|
||||
//import c5c = require('');
|
||||
//import c5c = require('');
|
||||
|
||||
@@ -100,4 +100,4 @@ var e6b;
|
||||
})(e6b || (e6b = {})); // should be error
|
||||
// enum then import, messes with error reporting
|
||||
//enum e7 { One }
|
||||
//import e7 = require(''); // should be error
|
||||
//import e7 = require(''); // should be error
|
||||
|
||||
@@ -41,4 +41,4 @@ var e2 = /** @class */ (function () {
|
||||
return e2;
|
||||
}());
|
||||
//enum then enum - covered
|
||||
//enum then import - covered
|
||||
//enum then import - covered
|
||||
|
||||
@@ -79,4 +79,4 @@ function y5b() { }
|
||||
function y5c() { }
|
||||
// function then import, messes with other errors
|
||||
//function y6() { }
|
||||
//import y6 = require('');
|
||||
//import y6 = require('');
|
||||
|
||||
@@ -48,4 +48,4 @@ var i3;
|
||||
i3[i3["One"] = 0] = "One";
|
||||
})(i3 || (i3 = {}));
|
||||
; // error
|
||||
//import i4 = require(''); // error
|
||||
//import i4 = require(''); // error
|
||||
|
||||
@@ -59,4 +59,4 @@ interface B<TBase extends Base> extends A {
|
||||
}
|
||||
var b: B<Derived> = null;
|
||||
var z: Derived = b.foo();
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -18,4 +18,4 @@ var foo;
|
||||
(function (foo) {
|
||||
function bar() { }
|
||||
})(foo || (foo = {}));
|
||||
// test #4
|
||||
// test #4
|
||||
|
||||
@@ -8,4 +8,4 @@ var bar;
|
||||
var x;
|
||||
/*
|
||||
var bar;
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,7 @@ var array = [
|
||||
var array = [
|
||||
/* element 1*/
|
||||
1
|
||||
/* end of element 1 */ ,
|
||||
/* end of element 1 */,
|
||||
2
|
||||
/* end of element 2 */
|
||||
];
|
||||
|
||||
@@ -12,8 +12,8 @@ var array = [
|
||||
var array = [
|
||||
/* element 1*/
|
||||
1
|
||||
/* end of element 1 */ ,
|
||||
/* end of element 1 */,
|
||||
2
|
||||
/* end of element 2 */ ,
|
||||
/* end of element 2 */,
|
||||
,
|
||||
];
|
||||
|
||||
@@ -7,5 +7,5 @@ function f() {
|
||||
//// [commentOnBlock1.js]
|
||||
// asdf
|
||||
function f() {
|
||||
/*asdf*/ { }
|
||||
/*asdf*/{ }
|
||||
}
|
||||
|
||||
@@ -29,4 +29,4 @@ function () { });
|
||||
foo(/*c7*/ function () { });
|
||||
foo(
|
||||
/*c7*/
|
||||
/*c8*/ function () { });
|
||||
/*c8*/function () { });
|
||||
|
||||
@@ -17,7 +17,7 @@ foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b);
|
||||
foo(/*c3*/ function () { }, /*d2*/ function () { }, /*e2*/ a + /*e3*/ b);
|
||||
foo(/*c3*/ function () { }, /*d3*/ function () { }, /*e3*/ (a + b));
|
||||
foo(
|
||||
/*c4*/ function () { },
|
||||
/*d4*/ function () { },
|
||||
/*c4*/function () { },
|
||||
/*d4*/function () { },
|
||||
/*e4*/
|
||||
/*e5*/ "hello");
|
||||
/*e5*/"hello");
|
||||
|
||||
@@ -178,7 +178,7 @@ jsDocMultiLine();
|
||||
*New line1
|
||||
*New Line2*/
|
||||
/** Shoul mege this line as well
|
||||
* and this too*/ /** Another this one too*/
|
||||
* and this too*//** Another this one too*/
|
||||
function jsDocMultiLineMerge() {
|
||||
}
|
||||
jsDocMultiLineMerge();
|
||||
@@ -188,23 +188,23 @@ function jsDocMixedComments1() {
|
||||
}
|
||||
jsDocMixedComments1();
|
||||
/// Triple slash comment
|
||||
/** jsdoc comment */ /*** another jsDocComment*/
|
||||
/** jsdoc comment *//*** another jsDocComment*/
|
||||
function jsDocMixedComments2() {
|
||||
}
|
||||
jsDocMixedComments2();
|
||||
/** jsdoc comment */ /*** another jsDocComment*/
|
||||
/** jsdoc comment *//*** another jsDocComment*/
|
||||
/// Triple slash comment
|
||||
function jsDocMixedComments3() {
|
||||
}
|
||||
jsDocMixedComments3();
|
||||
/** jsdoc comment */ /*** another jsDocComment*/
|
||||
/** jsdoc comment *//*** another jsDocComment*/
|
||||
/// Triple slash comment
|
||||
/// Triple slash comment 2
|
||||
function jsDocMixedComments4() {
|
||||
}
|
||||
jsDocMixedComments4();
|
||||
/// Triple slash comment 1
|
||||
/** jsdoc comment */ /*** another jsDocComment*/
|
||||
/** jsdoc comment *//*** another jsDocComment*/
|
||||
/// Triple slash comment
|
||||
/// Triple slash comment 2
|
||||
function jsDocMixedComments5() {
|
||||
|
||||
@@ -86,8 +86,8 @@ function blah3(a // trailing commen single line
|
||||
) {
|
||||
}
|
||||
lambdaFoo = function (a, b) { return a * b; }; // This is trailing comment
|
||||
/*leading comment*/ (function () { return 0; }); // Needs to be wrapped in parens to be a valid expression (not declaration)
|
||||
/*leading comment*/ (function () { return 0; }); //trailing comment
|
||||
/*leading comment*/(function () { return 0; }); // Needs to be wrapped in parens to be a valid expression (not declaration)
|
||||
/*leading comment*/(function () { return 0; }); //trailing comment
|
||||
function blah4(/*1*/ a /*2*/, /*3*/ b /*4*/) {
|
||||
}
|
||||
function foo1() {
|
||||
|
||||
@@ -18,7 +18,7 @@ var resolve = {
|
||||
id: /*! @ngInject */ function (details) { return details.id; },
|
||||
id1: /* c1 */ "hello",
|
||||
id2:
|
||||
/*! @ngInject */ function (details) { return details.id; },
|
||||
/*! @ngInject */function (details) { return details.id; },
|
||||
id3:
|
||||
/*! @ngInject */
|
||||
function (details) { return details.id; },
|
||||
|
||||
@@ -505,4 +505,4 @@ var r8b8 = b8 !== a8;
|
||||
var r8b9 = b9 !== a9;
|
||||
var r8b10 = b10 !== a10;
|
||||
var r8b11 = b11 !== a11;
|
||||
//var r8b12 = b12 !== a12;
|
||||
//var r8b12 = b12 !== a12;
|
||||
|
||||
+1
-1
@@ -431,4 +431,4 @@ var r8b6 = b6 !== a6;
|
||||
var r8b7 = b7 !== a7;
|
||||
var r8b8 = b8 !== a8;
|
||||
var r8b9 = b9 !== a9;
|
||||
//var r8b10 = b10 !== a10;
|
||||
//var r8b10 = b10 !== a10;
|
||||
|
||||
+1
-1
@@ -320,4 +320,4 @@ var r8b3 = b3 !== a3;
|
||||
var r8b4 = b4 !== a4;
|
||||
var r8b5 = b5 !== a5;
|
||||
var r8b6 = b6 !== a6;
|
||||
//var r8b7 = b7 !== a7;
|
||||
//var r8b7 = b7 !== a7;
|
||||
|
||||
+1
-1
@@ -320,4 +320,4 @@ var r8b3 = b3 !== a3;
|
||||
var r8b4 = b4 !== a4;
|
||||
var r8b5 = b5 !== a5;
|
||||
var r8b6 = b6 !== a6;
|
||||
//var r8b7 = b7 !== a7;
|
||||
//var r8b7 = b7 !== a7;
|
||||
|
||||
@@ -56,4 +56,4 @@ var c: C<number>;
|
||||
var cc: C<C<number>>;
|
||||
|
||||
c = c.m(cc);
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -17,4 +17,4 @@ var Foo = /** @class */ (function () {
|
||||
var baz = Foo.b;
|
||||
// Foo.b won't bind.
|
||||
baz.concat("y");
|
||||
// So we don't want an error on 'concat'.
|
||||
// So we don't want an error on 'concat'.
|
||||
|
||||
@@ -117,4 +117,4 @@ function foo(x, y, z) {
|
||||
// a = x;
|
||||
// a = y;
|
||||
// a = z;
|
||||
//}
|
||||
//}
|
||||
|
||||
@@ -108,4 +108,4 @@ function foo2(x, y) {
|
||||
//function foo2<T extends { (): void }, U extends T>(x: T, y: U) {
|
||||
// foo(x);
|
||||
// foo(y);
|
||||
//}
|
||||
//}
|
||||
|
||||
@@ -63,4 +63,4 @@ function other3(arg) {
|
||||
// var d = r2[1];
|
||||
// // BUG 821629
|
||||
// //var u: U = r2[1]; // ok
|
||||
//}
|
||||
//}
|
||||
|
||||
@@ -64,4 +64,4 @@ function other3(arg) {
|
||||
// var d: Date = r2['hm']; // ok
|
||||
// // BUG 821629
|
||||
// //var u: U = r2['hm']; // ok
|
||||
//}
|
||||
//}
|
||||
|
||||
@@ -268,4 +268,4 @@ function foo4(t, u) {
|
||||
// var i = [u, base]; // Base[]
|
||||
// var j = [u, derived]; // Derived[]
|
||||
// var k: Base[] = [t, u];
|
||||
//}
|
||||
//}
|
||||
|
||||
@@ -54,4 +54,4 @@ function f2() {
|
||||
// }
|
||||
// var x: U;
|
||||
// x.getDate();
|
||||
//}
|
||||
//}
|
||||
|
||||
@@ -75,4 +75,4 @@ var C2 = /** @class */ (function () {
|
||||
// var x: U;
|
||||
// x.getDate();
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
|
||||
@@ -89,4 +89,4 @@ var X;
|
||||
var a = X["foo"];
|
||||
var a0 = X["bar"];
|
||||
var _a;
|
||||
// TODO: make sure that enum still disallow template literals as member names
|
||||
// TODO: make sure that enum still disallow template literals as member names
|
||||
|
||||
@@ -19,4 +19,4 @@ var M;
|
||||
//var m: M = M;
|
||||
var x1 = M.a;
|
||||
//var x2 = m.a;
|
||||
//var q: m.P;
|
||||
//var q: m.P;
|
||||
|
||||
@@ -28,11 +28,11 @@ import j from "./jquery.js"
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports["default"] = 0;
|
||||
// No extension: '.ts' added
|
||||
// No extension: '.ts' added
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
// '.js' extension: stripped and replaced with '.ts'
|
||||
// '.js' extension: stripped and replaced with '.ts'
|
||||
//// [d.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
|
||||
@@ -84,4 +84,4 @@ function foo(x, y, z) {
|
||||
// x = null;
|
||||
// y = null;
|
||||
// z = null;
|
||||
//}
|
||||
//}
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
|
||||
|
||||
//// [parserSkippedTokens10.js]
|
||||
/*existing trivia*/ ;
|
||||
/*existing trivia*/;
|
||||
|
||||
@@ -78,4 +78,4 @@ declare module MsPortal.Controls.Base.ItemList {
|
||||
class ViewModel<TValue> extends ItemValue<TValue> {
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -26,4 +26,4 @@
|
||||
*/
|
||||
/*CHECK#1/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
// Comment
|
||||
|
||||
//// [sourceMap-Comment1.js]
|
||||
// Comment
|
||||
// Comment
|
||||
//# sourceMappingURL=sourceMap-Comment1.js.map
|
||||
@@ -8,7 +8,7 @@ sources: sourceMap-Comment1.ts
|
||||
emittedFile:tests/cases/compiler/sourceMap-Comment1.js
|
||||
sourceFile:sourceMap-Comment1.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>// Comment
|
||||
>>>// Comment
|
||||
1 >
|
||||
2 >^^^^^^^^^^
|
||||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
|
||||
@@ -14,7 +14,7 @@ System.register([], function (exports_1, context_1) {
|
||||
execute: function () {
|
||||
Home = {};
|
||||
exports_1("default", Home);
|
||||
// There is intentionally no semicolon on the prior line, this comment should not break emit
|
||||
// There is intentionally no semicolon on the prior line, this comment should not break emit
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ System.register([], function (exports_1, context_1) {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
exports_1("test", test = "TEST");
|
||||
//some comment
|
||||
//some comment
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -64,4 +64,4 @@ interface I2<V, T, U> {
|
||||
// y: U;
|
||||
// z: V;
|
||||
// foo<W extends V>(x: W): T;
|
||||
//}
|
||||
//}
|
||||
|
||||
@@ -83,4 +83,4 @@ function foo(x, y, z) {
|
||||
// x = undefined;
|
||||
// y = undefined;
|
||||
// z = undefined;
|
||||
//}
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user