[compiler:eslint] avoid loading the user config when running Babel + BabelPluginReactCompiler #29229
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I was trying to use
eslint-plugin-react-compiler
in one of my repo, but it wasn't reporting any error. After digging a bit more, I added aconsole.log
in thecatch
just aftertransformFromAstSync(babelAST, sourceCode, {
and I saw this error:And in my top level
![image](https://private-user-images.githubusercontent.com/22725671/333084170-aafb36b6-21d2-471a-ac10-2f29086529f1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg4MjgyMzksIm5iZiI6MTcxODgyNzkzOSwicGF0aCI6Ii8yMjcyNTY3MS8zMzMwODQxNzAtYWFmYjM2YjYtMjFkMi00NzFhLWFjMTAtMmYyOTA4NjUyOWYxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE5VDIwMTIxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThmNDZiM2FlOWE4ZDc1NjA5NDNiMjQzNzExMDQyNzdkZGNjYzQwZDYzMDNkMGUzMDA5MjhhOGIxMzhmNGI5YzEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.uj9fyauYMElEn7rOnS5y9m-KJz5TX0XMB2MHBK1pJG8)
babel.config.js
, I indeed have the plugin@babel/plugin-proposal-class-properties
not setup withloose: true
:To confirm my suspicions, I created https://github.com/Ayc0/bug-react-eslint-compiler-babel in which I have a minimal reproduction of this bug:
When the
![image](https://private-user-images.githubusercontent.com/22725671/333084515-10834326-9993-4b33-9864-832dbac4e0af.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg4MjgyMzksIm5iZiI6MTcxODgyNzkzOSwicGF0aCI6Ii8yMjcyNTY3MS8zMzMwODQ1MTUtMTA4MzQzMjYtOTk5My00YjMzLTk4NjQtODMyZGJhYzRlMGFmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE5VDIwMTIxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJhMGY5YTgyYWVkZTdjYzBlYjkyMWQxN2U1ZmY4ZTU5ZGIxNTI3YjhkYmYxMmVhMjUyZjkzMTQzNmMwYWRmYzEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.9QmurT3u6FlFX04Z19PeLy3DZ__P2i_c5j1XL_MRvOY)
babel.config.js
doesn't have anything, it works:But if it has
![image](https://private-user-images.githubusercontent.com/22725671/333084696-d6ed998f-0bfd-463c-b193-022f719c6887.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg4MjgyMzksIm5iZiI6MTcxODgyNzkzOSwicGF0aCI6Ii8yMjcyNTY3MS8zMzMwODQ2OTYtZDZlZDk5OGYtMGJmZC00NjNjLWIxOTMtMDIyZjcxOWM2ODg3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE5VDIwMTIxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFmODM2YjViOTVjNjBjNGY1OGM5Nzg0NGU0YWJjNWEyMzA1NDM1OTMzNWYwZGEzOTM3Y2MwYzFjOGJmOWQ1ZDUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.zStb7O2qQdyDTyDhb4VvxOkKM-8HL8dn6TpCNZGM7mg)
root: true
, it stops reporting errors:Or if it has the plugin not set with
![image](https://private-user-images.githubusercontent.com/22725671/333084747-ee183b43-6fb8-4779-8a24-c127e8184e38.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg4MjgyMzksIm5iZiI6MTcxODgyNzkzOSwicGF0aCI6Ii8yMjcyNTY3MS8zMzMwODQ3NDctZWUxODNiNDMtNmZiOC00Nzc5LThhMjQtYzEyN2U4MTg0ZTM4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE5VDIwMTIxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI3YWE4YjU3NzdhMWFjY2I0Y2FmZmJjMGU3YTEwMjdjYTRhMDg2ZmM2NjhmMDNlZjdmYmI1NzY5ZTExMDM4N2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.umIzcSeYAGjyEu3v1k264hvEuzUlND4Syl2o_N8hC00)
loose: true
:How did you test this change?
babel.config.js
In the same repro, I edited my version of
eslint-plugin-react-compiler
present in my node_modules:.babelrc
After testing
babel.config.js
, I looked for.babelrc
. In babel's config, you have both options https://babeljs.io/docs/options#babelrc. And indeed, if justconfigFile
is disabled, but not.babelrc
, it doesn't report any error when there is a.babelrc
file (but does as soon as we addbabelrc: false
:To note
In one of their example on the babel website, when doing 2 passes of babel, they also disable those 2 options in the 2nd pass, see https://babeljs.io/docs/options#ast:
CI tests
I'd love to add a test in the repo itself, but as this seems to be related to the top-level
babel.config.js
or.babelrc
, I didn’t know how to test that properly