-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add errorOnTypeScriptSyntaticAndSemanticIssues option #57
feat: add errorOnTypeScriptSyntaticAndSemanticIssues option #57
Conversation
Oh yipes, we get some very TypeScript-specific stuff in there:
|
you have to filter messages by types you can look on this what i proposed in plugin: error.category: DiagnosticCategory.Error = 1 |
additionally // example of code with nested errors :)
interface Foo {
hello: string;
}
const foo: string = ({ hello: 2 } as Foo)!.foo |
How does it change if you only error on syntactic issues? |
@j-f1 Hopefully @uniqueiniquity can tell us for sure, but I think getSyntacticDiagnostics is always returning nothing because those are covered by the long-standing logic of looking at the parseDiagnostics array on the AST |
Thanks @armano2, I have now seen the ts.flattenDiagnosticMessageText helper I had a quick look and they all seem to come through with category 1:
Unfortunately, it looks like |
I can see TypeScript bundles a file:
Which looks like this:
|
@JamesHenry i was doing some tests with code from my company and i got some suggestions and few warnings, i think it's better to filter them 😄 |
I don't think there's an easy way to filter out the "very TS specific errors" (e.g., couldn't find @types for imported package). One could filter out by error code, since those (I believe) reliably won't change, but there's a lot of errors. Your intuition about why you're not getting anything from |
I think I will go for an approach of filtering out all of the errors initially, and then we can opt into errors we know we want to provide feedback on (when the flag is enabled), we can then also extend this easily over time, and then actual errors we will care about should hopefully be much more manageable |
0ccfc84
to
1e0a824
Compare
Updated as per that idea, particularly important now is commits three, as it shows what happens before and after a particular error is supported. I went with the case previously outlined here: eslint/typescript-eslint-parser#547 As a starting point cc @mysticatea |
1e0a824
to
98acfe1
Compare
🎉 This PR is included in version 8.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
we should add this to readme / how to use it |
i just notice that there is typo in this PR it should be |
Whoops 😂 at least it is undocumented, so we can sneak a fix in before it is |
@armano2 @j-f1 @uniqueiniquity
I have applied the "errorOnTypeScriptSyntaticAndSemanticIssues" option we discussed.
The way I have tested it is to create a new spec which goes through all the existing fixtures, and only really cares if they throw. A simple sentence is snapshotted if they don't.
I have deliberately split this PR into two commits:
Therefore the diff between 1 and 2 is really important, because it is the difference between current behaviour, and behaviour with the option in enabled.
Even on initial glance, I have some concerns around the Prettier use-case, because I think the scale of "strictness" of reporting now looks like this:
Least strict: This parser with option disabled
Mid: Babel
Most strict: This parser with option enabled
For example, for this source, we will now report an error
"Cannot find name 'foo'."
:Please take a look at the diff and let me know what you think! :)