-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Allow patch level differences in preflight check #5247
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
Comments
Right now, this is intentional. We want to find an exact version match. We've actually never supported installing ESLint alongside Create React App, so this warning is fine IMO. For now, please match the version or disable the check with the suggested environment variable. |
@togakangaroo Could you clarify why you're installing ESLint inside your project? Is it for editor integrations or something else? |
I'm running into this as well. The reason I'm installing it is because Yarn doesn't recognize it as being installed in order to satisfy peer dependencies of other packages (ie. eslint-config-airbnb). |
In my case, I have it to lint files outside of |
My case is that i use a yeoman generator for copying my usual react lint rules, i can also use this with non-cra projects |
Would allowing patch-level differences for ESLint specifically satisfy most people in this thread? |
Note you can ignore the check (just as it says) by putting
to a file called |
Yes, my actual solution was adding an .env file with that flag to the generator. The problem with this is that i think the version mismatch between eslint versions is not that important (maybe i'm wrong), but to solve this problem i add the flag to my .env, maybe doing that i supress another really important warnings. Except for jest, is really important to do this preflight checks for dev dependencies? |
People have definitely complained about broken ESLint before after installing different versions. But yeah patch shouldn’t make a big difference. Although the fact that it even exists up the tree can cause issues by itself. |
So to fill in the picture, my own use case is that I have emacs checking my code with eslint. To do this correctly I want it to use the actual version from in my project so I want it to use npx eslint. This means that I have to have it in my project dependencies directly. I would imagine anyone else who wants to use it in their Dev workflow would have the same. What are the issues that mismatched versions might cause? Is there no way around those? |
Is there any other way without creating new .env file including 'SKIP_PREFLIGHT_CHECK=true' ? |
eslint is a project that follows semver, so minor version differences are compatible too. Suggesting you bark only on major version differences, like for example: semver.diff(yourVersion, userVersion) === 'major' |
I have a project which includes both server/client codes. Project structure like below:
Asume server code root path is ProjectRootPath, client code root path is ProjectRootPath/client When i run |
I am encountering this error too. I am using eslint and prettier for my vscode, so it will auto format my code when saved in VScode. These are the steps that I have implemented that led to the error in code. https://medium.com/quick-code/how-to-integrate-eslint-prettier-in-react-6efbd206d5c4 Thanks. |
I have exactly the same issue as @niccololampa I applied the fix with editing a .env file in my root, but that kinda feels like a temporary solution and I wouldn't want that to lead to further errors. |
So eslint is already part of react-scripts, so there should be available as part of npm scripts. I would just not install a different copy in your project. Goto your package.json and remove eslint entry from dependencies or devDependencies. This works fine for me using vscode + eslint plugin. |
Discovered the solution for my case. For those like me trying to install the Airbnb eslint styling. Follow these steps. The eslint-config airbnb requires the following eslint, eslint-plugin-import, eslint-plugin-react, and eslint-plugin-jsx-a11y all of which are already installed in the create-react-app. The problem arises from duplicate installation resulting from the command : npx install-peerdeps --dev eslint-config-airbnb So the solution is just call the following command:
This will just install the airbnb configuration and would not duplicate any packages installed already in create-react-app. Next is to create a .eslintrc file in your root file and insert the following code:
|
These kind of solutions will not work correctly for the linting done in dev mode, because those use the eslint config from webpack only which is set up to ignore eslint's config files. So your CLI and editor-based linting will use different rules from the linting done in dev mode. |
I forked this repo and (mostly) removed eslint from the You should still make sure you are linting for the react recommended issues. https://github.com/joserocha3/create-react-app-eslintless |
I'm having the same problem with the similar setup as @ywwhack . Is there any reason to check a parent node_modules directory for an eslint version? I thought that node won't look into parent if it finds a eslint package in a project node_modules folder. |
Also encountering this issue. It seems that this was historically not regarded as an issue though. |
I used @niccololampa's suggestion and put the eslint config in package.json, replacing what create-react-app had put in. Seems to work well. |
I wonder if adding some specificity to the skip variable could solve the issue (e.g. Rather than saying you're knowingly skipping all the preflight checks, you could specify which preflight checks to skip. |
I've experienced this issue when using a mono repo that contains a root, base, eslint config with variations for front end and node apps further down. A way of disabling only eslint would be most welcome. I had a quick Google for the other things prelight manages, does anyone have any details? |
on windows i've the same problem but i've done yarn add cross-env -D in the terminal and i've modified this line in the file name's package.json. |
I'm also running into this issue when using Yarn Workspaces. Even using When examining the directory structure the packages look like they get hoisted just fine, but perhaps CRA does not obey Yarn Workspaces |
Is there an issue number with a writeup of what the issues are with a different version of eslint so that someone else can potentially patch the defect? |
My use case is that I have installed other package which depends on eslint. |
Like moving flag check to verifyPackageTree.js and adding following lines: adding following lines: if (process.env.SKIP_PREFLIGHT_CHECK === 'true') {
console.log(`Warning: ${chalk.bold('SKIP_PREFLIGHT_CHECK')} is set to true`);
console.log(`Having wrong version of following packages may break your setup: ${depsToCheck.join(', ')}.\n`)
return
} |
@ywwhack I think you need to put |
@jgdodson imo it won't work. It only skip the eslint configuration, not eslint package. For example he have I'm sorry if I wrong here. I'm still newbie, and don't know to resolve if that above is the case. Thanks. |
@ywwhack :
My solution:
I don't know is it because I switch out the structure or is it because I use |
I manually uninstalled and installed the actual version. Hope that doesn't bring any issues later. |
@ywwhack Did you ever find a solution to this? I am also using the same folder structure and is stuck at this point. |
This isn't strictly related to ignoring patch level changes, but may contribute to the bigger convo. If not, I can remove it: In a yarn workspaces monorepo setup (with nohoist on for everything): If I peg the parent's ESLint to 5.16.0, CRA doesn't complain... but then I have to use that for all my packages. Besides missing the improvements made to ESlint since, if one of the other packages had a similar requirement for a different version I'd just be stuck. Pinning my parent to 5.16.0 for now, but I agree a --skip-linting type flag could be useful for folks that want to use CRA in a multi-package repo that already has global linting. |
this worked for me
|
Create-react-app does not support installing eslint. We could turn off PREFLIGHT_CHECK, but that could hide other issues. Until this issue (facebook/create-react-app#5247) is addressed, will stick with tslint for now
I hope this issue is still being looked into! With eslint replacing the deprecated tslint this year, it would be nice to not have to use the SKIP_PREFLIGHT_CHECK environment variable or worse, be stuck with an old eslint up the project tree from a CRA app! I’d be happy with something like SKIP_PREFLIGHT_CHECK=eslint ... seems like that would be a relatively simple compromise |
I had this issue after changin some file names, recently i delete node_modules on my project directory then npm start didnt, work. then try this:
hope can help |
|
This was sufficient for me to stop using CRA and manually setup the whole thing. (My comment might not be that useful, but this issue isn't either after two years of being ignored) |
Thank you. |
I had the same problem with CRA and it's eslint 5.**. Creating |
I have just encountered this issue in my monorepo regarding webpack. I have installed webpack v5 in my project root and react-scripts with its dependency to webpack v4 in a sub-folder When executing |
I think you are right |
|
Is this a bug report?
Yes, I am getting an eslint preflight check error hen I don't think I should be.
Did you try recovering your dependencies?
Yes, I've tried deleting the package-lock and rebuilt some stuff, but this issue seems pretty clearcut
Which terms did you search for in User Guide?
I searched for
eslint
there and in the issues but this is for the new release and I dont' think thats updated yetEnvironment
(paste the output of the command here)
Steps to Reproduce
To reproduce
I get the following. I don't think this is correct - a difference in patch version shouldn't cause the preflight check to fail, should it? (Also react-scripts should probably update their eslint version)
Expected Behavior
tests run fine - there is only a difference in patch level of eslint
Actual Behavior
I get the following
The text was updated successfully, but these errors were encountered: