Not suppressed eslint/indent errors at `.superTypeParameters TSTypeReference`
Gvozd opened this issue · comments
What version of TypeScript are you using?
3.0.3
What version of typescript-eslint-parser
are you using?
18.0.0
What code were you trying to parse?
export default class MyComponent extends PureComponent<{
model: MyModel
}> {// Expected indentation of 4 spaces but found 0 indent
}
What did you expect to happen?
I want suppress error in this case (for TSTypeReference
)
What happened?
I try suppress error with ignoredNodes
option
I try different node types, but it not working
'indent': [2, 4, {
SwitchCase: 1,
ignoredNodes: ['TSTypeReference', 'TSTypeReference *']
}],
When I run traverse with *
-selector, I do not receive any nodes in ClassDeclaration > .superTypeParameters
My monkey-patch fix
I do monkey-patch of parser, and now error doesn't emitted(in any indent variations, without ignoredNodes) - it's OK for me, for now.
// copy to file `.eslintrc.js`
var parser = require('typescript-eslint-parser'),
parseForESLint = parser.parseForESLint,
visitorKeys = require('eslint-visitor-keys');
parser.parseForESLint = function() {
const result = parseForESLint.apply(this, arguments);
result.visitorKeys = visitorKeys.unionWith({
ClassDeclaration: ['superTypeParameters']// now Eslint may traverse this node
});
return result;
};
I think, that also good idea add another additional visitorKeys
for additional AstNode types
Visitor keys were added, please let us know if there are any issues with the latest version!
I updated to latest typescript@3.1.6, typescript-eslint-parser@20.1.1
My first code suppressed successfully
But this error not suppressed by ignoredNodes
at another code example
Also at old version with my monkey-patch
I think that's another bug, not related to the visitor keys
export default class MyComponent extends PureComponent<
{model: MyModel}
> {// Expected indentation of 4 spaces but found 0 indent
}
'indent': [2, 4, {
SwitchCase: 1,
ignoredNodes: [
'TSTypeReference', 'TSTypeReference *',
'TSTypeParameterInstantiation', 'TSTypeParameterInstantiation *'
]
}],