-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
[compiler][eslint] remove compilationMode override; report bailouts on first line #30423
Conversation
…n first line [ghstack-poisoned]
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…n first line ghstack-source-id: 4b6a3b181d4c3eb2f2e11b22455066c57aa2e018 Pull Request resolved: #30423
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
|
@@ -100,7 +100,6 @@ function makeSuggestions( | |||
|
|||
const COMPILER_OPTIONS: Partial<PluginOptions> = { | |||
noEmit: true, | |||
compilationMode: "infer", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that infer
is already the compilationMode
default, so this override only affects user-specified compilationMode
s (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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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]
…n first line ghstack-source-id: a1e27f431afc692b1b30738443bcfad3c9677568 Pull Request resolved: #30423
… 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: 1870c7aa09d455bea89171b77468baeef5b3a63b Pull Request resolved: #30423
…n first line ghstack-source-id: 1870c7aa09d455bea89171b77468baeef5b3a63b Pull Request resolved: #30423
…n first line ghstack-source-id: 1870c7aa09d455bea89171b77468baeef5b3a63b Pull Request resolved: facebook#30423
…n first line ghstack-source-id: 1870c7aa09d455bea89171b77468baeef5b3a63b Pull Request resolved: facebook#30423
…n first line ghstack-source-id: 1870c7aa09d455bea89171b77468baeef5b3a63b Pull Request resolved: facebook#30423
…n first line ghstack-source-id: 1870c7aa09d455bea89171b77468baeef5b3a63b Pull Request resolved: facebook#30423
…n first line ghstack-source-id: 1870c7aa09d455bea89171b77468baeef5b3a63b Pull Request resolved: facebook#30423
…n first line ghstack-source-id: 1870c7aa09d455bea89171b77468baeef5b3a63b 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:
useFoo
is not defined using component syntaxbefore.mov
After:
compilationMode
config is respectedScreen.Recording.2024-07-22.at.3.59.59.PM.mov