create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Warnings not always shown

Open eluchsinger opened this issue 3 years ago • 16 comments

Describe the bug

When running npm start, the output won't show all of the warnings in the project. After editing the files, the warnings start appearing.

(Write your answer here.)

Did you try recovering your dependencies?

NPM Version 6.14.11

Environment

Environment Info:

current version of create-react-app: 5.0.0 running from C:\Users\eluch\AppData\Roaming\npm-cache_npx\3452\node_modules\create-react-app

System: OS: Windows 10 10.0.19043 CPU: (6) x64 Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
Binaries: Node: 14.16.0 - D:\Program Files\nodejs\node.EXE
Yarn: Not Found npm: 6.14.11 - D:\Program Files\nodejs\npm.CMD Browsers: Chrome: Not Found Edge: Spartan (44.19041.1266.0), Chromium (96.0.1054.62) Internet Explorer: 11.0.19041.1202 npmPackages: react: ^17.0.2 => 17.0.2 react-dom: ^17.0.2 => 17.0.2 react-scripts: 5.0.0 => 5.0.0 npmGlobalPackages: create-react-app: Not Found

Steps to reproduce

(Write your steps here:)

  1. Run npm start
  2. See the console output, doesn't show all of the warnings.
  3. Edit and save a file where you know there should be a warning (e.g. React Hook useEffect has missing dependencies)

Expected behavior

I would expect the warnings (and errors) of the project to be shown.

Actual behavior

Not all of the warnings are shown in the console output.

Reproducible demo

I will try to add a reproducible demo if this is really not a known bug that everyone can reproduce.

eluchsinger avatar Dec 20 '21 14:12 eluchsinger

I have the same problem after upgrading to react-scripts 5. Issues are shown only for files that have just been saved. So, if there are compilation errors, then you kill the app, and start it again, you end up with "No issues found", get errors in browser console, and get errors in cli again when you save the file that contains the code that doesn't conform to eslint configuration.

It seems as the .eslintrc.js config is not parsed when the app starts. If I have an error in the config (such as wrong name of a config), the error is not shown after start, but only after making first change to a watched file and saving.

hydrandt avatar Dec 27 '21 09:12 hydrandt

I found this problem might due to the Eslint lintFile and the cache setting(https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions) When use lintFile and turn the cache on. After the first lint, eslint will use the cache result and only lint the file is changed. And the eslint won't clear the cache automatic.

In react-scripts webpack.config.js

new ESLintPlugin({
    // Plugin options
    extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
    formatter: require.resolve('react-dev-utils/eslintFormatter'),
    eslintPath: require.resolve('eslint'),
    failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
    context: paths.appSrc,
    cache: true,
    cacheLocation: path.resolve(
      paths.appNodeModules,
      '.cache/.eslintcache'
    ),
    // ESLint class options
    cwd: paths.appPath,
    resolvePluginsRelativeTo: __dirname,
    baseConfig: {
      extends: [require.resolve('eslint-config-react-app/base')],
      rules: {
        ...(!hasJsxRuntime && {
          'react/react-in-jsx-scope': 'error',
        }),
      },
    },
  }),

So my workaround solution is before I fix all the eslint waning and error, I will clear the node_modules/.cache manually. But it would take more time at every run.

qq831799 avatar Jan 05 '22 05:01 qq831799

Did anyone find the solution? Same problem here.

JamersonAguiarOSF avatar Jan 11 '22 17:01 JamersonAguiarOSF

I found this problem might due to the Eslint lintFile and the cache setting(https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions) When use lintFile and turn the cache on. After the first lint, eslint will use the cache result and only lint the file is changed. And the eslint won't clear the cache automatic.

In react-scripts webpack.config.js

new ESLintPlugin({
    // Plugin options
    extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
    formatter: require.resolve('react-dev-utils/eslintFormatter'),
    eslintPath: require.resolve('eslint'),
    failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
    context: paths.appSrc,
    cache: true,
    cacheLocation: path.resolve(
      paths.appNodeModules,
      '.cache/.eslintcache'
    ),
    // ESLint class options
    cwd: paths.appPath,
    resolvePluginsRelativeTo: __dirname,
    baseConfig: {
      extends: [require.resolve('eslint-config-react-app/base')],
      rules: {
        ...(!hasJsxRuntime && {
          'react/react-in-jsx-scope': 'error',
        }),
      },
    },
  }),

So my workaround solution is before I fix all the eslint waning and error, I will clear the node_modules/.cache manually. But it would take more time at every run.

we have an ejected cra5 app (due to multiple massive issues with cra5), and supply a custom .eslintrc on the root. linting works perfecty with yarn lint but not with yarn start

i just crosschecked with yarn lint and our yarn start only shows a handful of all warnings. after i've run yarn lint the yarn start command doesnt show ANY warnings anymore, even though eslint cache is disabled manually in the webpack config. also the node_modules/.cache/.eslintcache folder is empty

the eslint errors are also not shown when running yarn build, even if there are multiple warnings and errors.

kitsunekyo avatar Jan 18 '22 08:01 kitsunekyo

linking https://github.com/facebook/create-react-app/issues/10509

kitsunekyo avatar Jan 18 '22 08:01 kitsunekyo

here's a reproduction repo: https://github.com/kitsunekyo/cra5-eslint-not-emitting

when i run yarn start i sometimes get correct eslint emits, and sometimes absolutely no eslint output. it appears to be completely random.

if its already running, and i hit save on App.tsx once, the eslint error will correctly show up again.

kitsunekyo avatar Jan 18 '22 13:01 kitsunekyo

I have the same issue, at some point I don’t see warnings. When I save a file the warnings for this file show up.

Deleting the cache (rm -R ./node_modules/.cache) helps, but as soon as I stop the dev server and restart it I have the same issue again. Currently my workaround is to delete .cache before starting the dev server.

Just deleting ./node_modules/.cache/.eslintcache does not fix the issue.

I am currently on Windows with wsl2, I can later check if I have the same error on my macbook.

This also happens with a fresh CRA 5 default project.

receter avatar Jan 28 '22 09:01 receter

Are there some news on the issue? I've encountered the same behavior.

lucapollani avatar Feb 25 '22 08:02 lucapollani

Same question here. Is this a dead project / is CRA not recommended way to develop react apps anymore? Or is this not a common scenario to develop?

Last commit to this repo is 29 days ago. 295 open pull requests. Doesn't seem that somebody is actually maintaining this project anymore.

hydrandt avatar Feb 25 '22 16:02 hydrandt

Is there any update here?

It's getting very annoying because I'm often convinced everything is okay, I submit my work to my repository, and I get warnings when I see the continuous deployment build fail.

cristianlivella avatar Mar 23 '22 18:03 cristianlivella

Is this still happening in 5.0.1? Need to check.

hydrandt avatar Apr 23 '22 10:04 hydrandt

Is this still happening in 5.0.1? Need to check.

Same issue still on 5.0.1 on my side.

domhaas avatar May 18 '22 17:05 domhaas

How is everyone dealing with it? Just not upgrading to 5.x?

hydrandt avatar May 18 '22 19:05 hydrandt

yep. seems like there is barely any updates from the maintainers, so we stick with v4 and evaluate vite as a replacement.

kitsunekyo avatar May 18 '22 20:05 kitsunekyo

How is everyone dealing with it? Just not upgrading to 5.x?

"scripts": {
  "start": "rm -R ./node_modules/.cache && ...
  ...

domhaas avatar May 18 '22 20:05 domhaas

The fix above helps to represent warnings in the terminal, is there any other fix to help represent warnings in Browser console as well?

HurYur avatar Oct 07 '22 11:10 HurYur

Did you switch to Vite in the end @kitsunekyo?

hydrandt avatar Nov 04 '22 13:11 hydrandt

Hi all, this is caused by https://github.com/webpack-contrib/eslint-webpack-plugin/issues/130

facugaich avatar Dec 29 '22 22:12 facugaich

It seems that in cra 5 you need to include the eslint configuration in the package.json.

"eslintConfig": { "extends": [ "react-app", "react-app/jest" ] }

This solved this issue for me.

braddi avatar Jan 06 '23 12:01 braddi

AFAICT you can also just delete node_modules/.cache/.eslintcache

wheresthecode avatar Feb 22 '23 19:02 wheresthecode

Did you switch to Vite in the end @kitsunekyo?

we did indeed. we abandoned CRA for all projects and moved them to vite.

kitsunekyo avatar Mar 29 '23 06:03 kitsunekyo

Anyone manage to solve this. I have added to package.json - but still not showing up

ddennis avatar Jun 26 '23 12:06 ddennis