This repository was archived by the owner on Jan 19, 2019. It is now read-only.
File tree 3 files changed +38
-3
lines changed
3 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,32 @@ function isComma(token) {
244
244
return token . kind === SyntaxKind . CommaToken ;
245
245
}
246
246
247
+ /**
248
+ * Returns true if the given TSToken is a comment
249
+ * @param {TSToken } token the TypeScript token
250
+ * @returns {boolean } is commment
251
+ */
252
+ function isComment ( token ) {
253
+ return ( token . kind === SyntaxKind . SingleLineCommentTrivia || token . kind === SyntaxKind . MultiLineCommentTrivia ) || ( token . kind >= SyntaxKind . JSDocTypeExpression && token . kind <= SyntaxKind . JSDocTypeLiteral ) ;
254
+ }
255
+
256
+ /**
257
+ * Returns true if the given TSToken is inside a comment
258
+ * Non-comment type tokens are generated for types in JSDoc Blocks
259
+ * @param {TSToken } token the TypeScript token
260
+ * @returns {boolean } is inside a commment
261
+ */
262
+ function isInsideComment ( token ) {
263
+ if ( token . kind === SyntaxKind . SourceFile ) {
264
+ return false ;
265
+ }
266
+ if ( isComment ( token ) ) {
267
+ return true ;
268
+ }
269
+ return isInsideComment ( token . parent ) ;
270
+ }
271
+
272
+
247
273
/**
248
274
* Returns the binary expression type of the given TSToken
249
275
* @param {TSToken } operator the operator token
@@ -693,7 +719,7 @@ function convertTokens(ast) {
693
719
* @returns {undefined }
694
720
*/
695
721
function walk ( node ) {
696
- if ( isToken ( node ) && node . kind !== SyntaxKind . EndOfFileToken ) {
722
+ if ( isToken ( node ) && ! isInsideComment ( node ) && node . kind !== SyntaxKind . EndOfFileToken ) {
697
723
const converted = convertToken ( node , ast ) ;
698
724
699
725
if ( converted ) {
Original file line number Diff line number Diff line change 9
9
/**
10
10
* a
11
11
*/
12
- foo ;
12
+ foo ;
13
+
14
+ /**
15
+ * This is a function.
16
+ * @param {String } bar
17
+ * @returns {String } returns bar
18
+ */
19
+ function foo ( bar ) {
20
+ return bar ;
21
+ }
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ describe("TypeScript", () => {
80
80
) ;
81
81
} ) ;
82
82
83
- it ( "should not produce any lint errors on valid JSDoc indentation (#344)" , ( ) => {
83
+ it ( "should not produce any lint errors on valid JSDoc indentation (#344 & #422 )" , ( ) => {
84
84
verifyAndAssertMessages (
85
85
loadExternalFixture ( "jsdoc-indent" ) ,
86
86
{
You can’t perform that action at this time.
0 commit comments