ember-cli-typescript
ember-cli-typescript copied to clipboard
ember install ember-cli-typescript does not set eslint parser to @typescript-eslint/parser
User story
As an Ember.js application developer, I would like ember-cli-typescript to update the default .eslintrc.js
configuration (particularly, the parser
option) so that npm run lint
does not fail with spurious errors when using standard TypeScript features such as type assertions (babel-eslint
incorrectly identifies them as JSX).
ember-cli-typescript
already provides a usable tsconfig.json
, blueprints, etc., so I'm not sure why it doesn't update eslint settings as well. Maybe it's not trivial to do or would break things / surprise users? In that case, perhaps this could be given more attention in the installation, configuration, or FAQ parts of the documentation. (Apologies if this is documented somewhere, but I did not see it on https://docs.ember-cli-typescript.com/ nor could I easily find issues with "Parsing error: Unterminated JSX contents." to help me understand what the problem was.)
I created the ect-parser-test
example project to demonstrate the problem and proposed solution. Below is an example of the "Parsing error: Unterminated JSX contents." problem that I encountered.
// (in an integration test for a component)
// ...
// Problem is coming from type assertion (<HTMLFormElement>) here
// (commenting out the following line prevents the parsing error below)
assert.strictEqual((<HTMLFormElement>this.element).textContent?.trim(), '');
// ESLint:
// Parsing error: Unterminated JSX contents.
await render(hbs`
<MyComponent>
template block text
</MyComponent>
`);
// ...
Ha! Now I found this: https://github.com/typed-ember/ember-cli-typescript/issues/637
See also: #963
@jacobq thanks so much for filing this. I'm going to close it in favor of #637, as I think that's where we want to track it (as well as #963), but this will be helpful as part of that work!