[compiler][eslint] remove compilationMode override; report bailouts on first line#30423
[compiler][eslint] remove compilationMode override; report bailouts on first line#30423mofeiZ merged 3 commits intogh/mofeiZ/14/basefrom
Conversation
…n first line [ghstack-poisoned]
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Comparing: b2ec044...686b477 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
|
|
||
| const COMPILER_OPTIONS: Partial<PluginOptions> = { | ||
| noEmit: true, | ||
| compilationMode: "infer", |
There was a problem hiding this comment.
Note that infer is already the compilationMode default, so this override only affects user-specified compilationModes (by overriding all other options to infer).
| const firstLineLoc = { | ||
| start: event.fnLoc.start, | ||
| end: { | ||
| line: event.fnLoc.start.line, | ||
| column: 10e3, | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Slightly hacky, but the alternative is to attach another loc object to events (e.g. function identifier, parameters, etc). This felt cleaner, as not all functions we compile have id or param nodes.
There was a problem hiding this comment.
Worth noting that in Flow we have a sig_loc on functions, which is the location of, effectively, everything in a function other than its body (function keyword, name, type parameters, parameters including parentheses, => for arrow functions, return type annotation). This has been a useful thing for us to have in a lot of error messages and the compiler might benefit from something similar.
There was a problem hiding this comment.
Ohhh i've wanted that a few times
| const firstLineLoc = { | ||
| start: event.fnLoc.start, | ||
| end: { | ||
| line: event.fnLoc.start.line, | ||
| column: 10e3, | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Worth noting that in Flow we have a sig_loc on functions, which is the location of, effectively, everything in a function other than its body (function keyword, name, type parameters, parameters including parentheses, => for arrow functions, return type annotation). This has been a useful thing for us to have in a lot of error messages and the compiler might benefit from something similar.
… bailouts on first line" --- Before: - observe that both functions are compiled, even though `useFoo` is not defined using [component syntax](https://flow.org/en/docs/react/component-syntax/) - eslint diagnostic highlights entire function body https://github.com/user-attachments/assets/e4a26fa9-cebb-4a44-8789-4810a015a67b After: - `compilationMode` config is respected - eslint diagnostic highlights only first line https://github.com/user-attachments/assets/eb3f9b1a-b204-4f10-a920-d6fd6b821adc [ghstack-poisoned]
… bailouts on first line" --- Before: - observe that both functions are compiled, even though `useFoo` is not defined using [component syntax](https://flow.org/en/docs/react/component-syntax/) - eslint diagnostic highlights entire function body https://github.com/user-attachments/assets/e4a26fa9-cebb-4a44-8789-4810a015a67b After: - `compilationMode` config is respected - eslint diagnostic highlights only first line https://github.com/user-attachments/assets/eb3f9b1a-b204-4f10-a920-d6fd6b821adc [ghstack-poisoned]
…n first line ghstack-source-id: 1870c7a Pull Request resolved: facebook#30423
…n first line ghstack-source-id: 1870c7a Pull Request resolved: facebook#30423
…n first line ghstack-source-id: 1870c7a Pull Request resolved: facebook#30423
…n first line ghstack-source-id: 1870c7a Pull Request resolved: facebook#30423
…n first line ghstack-source-id: 1870c7a Pull Request resolved: facebook#30423
…n first line ghstack-source-id: 1870c7a Pull Request resolved: facebook#30423
|
Sorry about not chiming in earlier, but I'm not sure I'm following that the fix is to truncate the error location to just the first line. Shouldn't we audit the locations we report instead and ensure that they're scoped to a more specific point in the source (not the component/hook itself)? In any case, this approach doesn't seem to play well with our internal eslint infra which expects that lint message locations fall within the bounds of the actual source code. I think it'd be better to revert this change and then find the errors that span the whole function and fix their reported locations |
Stack from ghstack (oldest at bottom):
Before:
useFoois not defined using component syntaxbefore.mov
After:
compilationModeconfig is respectedScreen.Recording.2024-07-22.at.3.59.59.PM.mov