-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(typescript-estree): added allowInvalidAST option to not throw on invalid tokens #6247
feat(typescript-estree): added allowInvalidAST option to not throw on invalid tokens #6247
Conversation
Thanks for the PR, @JoshuaKGoldberg! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## v6 #6247 +/- ##
==========================================
- Coverage 87.81% 87.72% -0.09%
==========================================
Files 365 365
Lines 12455 12479 +24
Branches 3669 3679 +10
==========================================
+ Hits 10937 10947 +10
- Misses 1158 1170 +12
- Partials 360 362 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I'm not so sure this is the right approach to fixing the issue. It'd be hard to add branching logic for every possible syntactic issue not reported as such by TypeScript. Instead, I'll look at using our isolated program to catch them. Let this PR serve as a reference for what this logic could look like. 🙂 Edit: the isolated program is too slow. We're going with this! 🚀 |
PR Checklist
Overview
Adds an opt-in
allowInvalidAST
option to@typescript-eslint/typescript-estree
and@typescript-eslint/parser
. It enables checks for some known cases where TypeScript reports a syntactic issue as semantic:no-restricted-exports
: Cannot read property 'name' of null eslint/eslint#15384)indent
throws TypeError: Cannot read property 'loc' of undefined eslint/eslint#14538)Note that some previously reported cases seem to now be reported as syntactic issues by TypeScript:
export
(Results of weekly scheduled smoke test jsx-eslint/eslint-plugin-react#3178)import
(Parsing: strictly enforce the produced AST matches the spec and enforce most "error recovery" parsing errors #1852 (comment))throw
(Handle throw with no arguments in no-throw-literal eslint/eslint#13143)Does not tackle more difficult cases:
async
inside a non-async function ([Bug]await
on non-async function does not throw an error #2997)abstract
members markedasync
(TypeScript 4.1 Syntax Support #2583 (comment))in
on a primitive (TypeScript 4.2 Syntax Support #2935 (comment))MethodDefinition
(readonly
anddeclare
invalid property forMethodDefinition
. #2908 (comment))