I'm working on a project with mixed JS and TypeScript support. We heavily use eslint rules in js and our ts goes through the typescript-eslint-parser. However, the interface definition of the typescript -> js ast doesn't get picked up by the prop-types rule like it does for Flow.
This gist has some sample tsx code as well as the ast that is produced for it. This particular case would fail proptypes but I renamed the prop so it would be easier to identify in the ast for the purpose of this issue.
Unfortunately, the ast around the prop definition seems relatively unstructured. However, the typescript compiler itself makes this rule redundant anyway.
Instead of adding complexity to this rule, I propose that an option is added to either explicitly ignore ts/tsx files or make a config array to ignore specific extensions.
What do you think?
@yannickcr @jseminck @lelandrichardson
eslint 4 already supports glob-based configuration; you can configure any rule to be disabled on ts/tsx files already.
"overrides": [
{
"files": ["**/*.tsx"],
"rules": {
"react/prop-types": "off"
}
}
]
put above override in eslint config file will solve the problem.
Following @F3n67u answer, here is the yaml version:
overrides:
- files: ['**/*.tsx']
rules:
'react/prop-types': 'off'
Most helpful comment
put above override in eslint config file will solve the problem.