This repository has been archived by the owner on Jan 19, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 92
Core indent rule reports false positives in doc blocks #422
Comments
Digging into this a little more, it looks like this is because typescript-eslint-parser includes doc block components in the token list (I'm guessing this is because of Typescript's ability to parse doc blocks for type information when checking JS files). For example, the token list for the above is: [ { type: 'Punctuator',
value: '{',
range: [ 37, 38 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Identifier',
value: 'String',
range: [ 38, 44 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Punctuator',
value: '}',
range: [ 44, 45 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Identifier',
value: 'text',
range: [ 46, 50 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Punctuator',
value: '{',
range: [ 63, 64 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Identifier',
value: 'String',
range: [ 64, 70 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Punctuator',
value: '}',
range: [ 70, 71 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Keyword',
value: 'function',
range: [ 76, 84 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Identifier',
value: 'foo',
range: [ 85, 88 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Punctuator',
value: '(',
range: [ 88, 89 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Identifier',
value: 'text',
range: [ 89, 93 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Punctuator',
value: ':',
range: [ 93, 94 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Identifier',
value: 'string',
range: [ 95, 101 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Punctuator',
value: ')',
range: [ 101, 102 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Punctuator',
value: ':',
range: [ 102, 103 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Identifier',
value: 'string',
range: [ 104, 110 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Punctuator',
value: '{',
range: [ 111, 112 ],
loc: { start: [Object], end: [Object] } },
{ type: 'Punctuator',
value: '}',
range: [ 112, 113 ],
loc: { start: [Object], end: [Object] } } ] It seems like the fix in this case would be to align with Espree's behavior when it comes to handling comment tokens - since there isn't a spec for comments in ESTree - but I'll look into this a little more. |
kaicataldo
added a commit
to kaicataldo/typescript-eslint-parser
that referenced
this issue
Dec 24, 2017
PR up: #423 |
kaicataldo
added a commit
to kaicataldo/typescript-eslint-parser
that referenced
this issue
Dec 24, 2017
kaicataldo
added a commit
to kaicataldo/typescript-eslint-parser
that referenced
this issue
Dec 24, 2017
Please feel free to change the label if this is incorrect :) It's technically not the AST - it's actually the tokens array - that is causing the issue here. |
kaicataldo
added a commit
to kaicataldo/typescript-eslint-parser
that referenced
this issue
Jan 22, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of TypeScript are you using?
typescript@2.6.2
What version of
typescript-eslint-parser
are you using?typescript-eslint-parser@11.0.0
What code were you trying to parse?
The minimal repro case is:
Running the autofixer generates the following code (which then passes):
What did you expect to happen?
No errors! This only occurs with the typescript-eslint-parser. It does not happen with the default parser.
What happened?
I'll try to look into the cause if I get a chance, but not sure if and when that'll be. Took the bug label off because I'm not sure what the established practice is in this repo - happy to update though :)
The text was updated successfully, but these errors were encountered: