You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Usage with TypeScript
To enable working with TypeScript projects, install @babel/preset-typescript as a dependency, then add "typescript" to parserOptions.babelOptions.parserOpts.plugins in your .eslintrc.
but it shows an example that uses babelOptions which makes me think that the @babel/eslint-parser parser is required instead of the @typescript-eslint/parser. In order to also run the plugin:@typescript-eslint/recommended rules... I believe I need the @typescript-eslint/parser parser. But if I use @typescript-eslint/parser then how can I update the babelOptions with the "typescript" plugin?
The text was updated successfully, but these errors were encountered:
You can only specify one parser. These rules were written with @babel/eslint-parser, so that's the parser we officially support. I think they should be reasonably similar when parsing JavaScript code, but I haven't fully investigated their interoperability. It's on our radar, though (salesforce/eslint-plugin-lwc#153).
An additional thing to be aware of when using this plugin with TypeScript is that certain language features (like type assertions) will break the rules' ability to detect violations, because the AST is different from what we expect to find in JavaScript code. Adding better TypeScript support is also something we're looking into (salesforce/eslint-plugin-lwc#154), but we have not yet decided which parser to support, going forward.
So unless your rules are compatible with their parser or their rules are compatible with your chosen parser... we will be unable to run both sets of rules at the same time. And by we, I mean the next generation of Salesforce Code Analyzer.
At best we would have to make 2 passes of ESLint with 2 different sets of configuration in order to make things work if the parser are incompatible.
I see the readme says:
Usage with TypeScript
To enable working with TypeScript projects, install @babel/preset-typescript as a dependency, then add "typescript" to parserOptions.babelOptions.parserOpts.plugins in your .eslintrc.
but it shows an example that uses babelOptions which makes me think that the @babel/eslint-parser parser is required instead of the @typescript-eslint/parser. In order to also run the plugin:@typescript-eslint/recommended rules... I believe I need the @typescript-eslint/parser parser. But if I use @typescript-eslint/parser then how can I update the babelOptions with the "typescript" plugin?
The text was updated successfully, but these errors were encountered: