Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Not suppressed eslint/indent errors at .superTypeParameters TSTypeReference #514

@Gvozd

Description

@Gvozd

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions