Skip to content

After update to 4.0 lint errors are blocking the rendering #9887

Description

@Poyoman39

Describe the bug

With CRA 3.x lint errors where reported as warning in the console. Now it is blocking the rendering :
image

Expected behaviour

I would like to have by default the old behaviour (warning in console), or at least a way to switch back to this old behaviour


Edit:

@unframework give bellow a nice analysis about this issue: #9887 (comment)_

Solutions & workarounds

  • Implement a way to disable eslint in CRA builds/dev (env variables ...)
  • Use two eslint config files. One for text editor, and one for React.
  • Clean your code or change severity of eslint rules in your eslintrc file. (change them to warning for instance)

Activity

  1. dev-bjoern commented on Oct 24, 2020

    @dev-bjoern

    I always get these compile fails on eslint errors also in CRA 3.x (which is fine).

  2. mstykow commented on Oct 24, 2020

    @mstykow

    It depends. For example a simple console.log now also prevents compiling. This was not the case with 3.4.x. There is always the flag TSC_COMPILE_ON_ERROR=true you can set in your .env to compile anyways.

  3. fred172 commented on Oct 26, 2020

    @fred172

    This also breaks on prop warnings, which is very intrusive during development. It would be nice if this could be fixed...

  4. RosenTomov commented on Oct 26, 2020

    @RosenTomov

    Updated:

    Add

    emitWarning: true,
    failOnWarning: false,
    

    In config/webpack.config.js -> ESLintPlugin

          new ESLintPlugin({
            // Plugin options
            extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
            formatter: require.resolve('react-dev-utils/eslintFormatter'),
            eslintPath: require.resolve('eslint'),
            context: paths.appSrc,
            emitWarning: true, // new
            failOnWarning: false, // new
            // 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',
                }),
              },
            },
          }),
    
  5. Saibamen commented on Oct 26, 2020

    @Saibamen

    failOnError: false, Don't do that... Skip warnings only

  6. rus-yurchenko commented on Oct 26, 2020

    @rus-yurchenko

    Even more, the compilation time became much longer because it now extends the ESlint config and runs lint on every change, which eliminates the speed of fast refresh. I used ESlint only as a part of lint-staged before and want to continue to use it as an optional thing that won't slow down compilation time.

  7. RosenTomov commented on Oct 26, 2020

    @RosenTomov

    Try with caching, again add
    cache: true,

    in ESLintPlugin options.

  8. Saibamen commented on Oct 26, 2020

    @Saibamen

    Caching fixed in this PR: #9911

  9. asdfasdfasdfasdfff commented on Oct 27, 2020

    @asdfasdfasdfasdfff

    There is a temporary workaround, but it works for me for now. I renamed .eslintrc to something else which is not findable by cra, like config.eslint.js. Then I changed all eslint scripts in package.json to eslint -c config.eslint.js ...rest of params. The only problem I have now is that my configuration is not working in my editor too, I mean fix eslint errors on save is not working and I should change the configuration file for my editor too. It may not worth it to change all of these also.
    In my case I am using coc-eslint and coc-nvim which can be configured to use the new config file as explained here: url.

  10. abraidwood commented on Oct 27, 2020

    @abraidwood

    It feels like webpack.config.js should honour the SKIP_PREFLIGHT_CHECK environment variable something like this abraidwood@39452df

  11. fredefl commented on Oct 27, 2020

    @fredefl

    In my case, the errors I got after upgrading were in files that are not included in the build - and thus weren't linted in v3.4.0 but somehow are in v4.0.0. Maybe this is what you're seeing too?

  12. 76 remaining items

  13. vincentdesmares commented on Feb 25, 2021

    @vincentdesmares

    Hi @mrmckeb,

    I'm not sure if the problem is related but upgrading to React 4.0.3 from 3.x gave us new errors blocking the build, same as the author of this thread.

    While I'm not against blocking the build I don't understand why I cannot modify those errors in our eslintrc.json file.

    It looks like upgrading to 4.X now ignore our local configuration. For exemple, adding "@typescript-eslint/ban-ts-ignore": "off", successfully removes the error from VScode but the build is still failing the same way.

  14. mrmckeb commented on Feb 26, 2021

    @mrmckeb
    Contributor

    Hi @vincentdesmares, that sounds like a setup issue - as it definitely shouldn't behave that way - but it may be a bug of course! Can you share a reproduction? I can investigate further :)

  15. vincentdesmares commented on Feb 26, 2021

    @vincentdesmares

    I will try to reproduce the issue in a standalone repository.

    I'm very tempted to just trash my previous config and start clean but right now if I want to configure my app, the only reference that I found is https://create-react-app.dev/docs/setting-up-your-editor and the emplacement of the configuration is not explicitly specified.

    What's the available configurations?

  16. mrmckeb commented on Feb 26, 2021

    @mrmckeb
    Contributor

    It should be anything that ESLint supports: https://eslint.org/docs/2.0.0/user-guide/configuring#configuration-file-formats

    Just make sure it's not defined in your package.json too - as that's where we place it by default.

  17. stclairdaniel commented on May 12, 2021

    @stclairdaniel

    I'm still getting this issue in 4.0.3 -

    Failed to compile.
    
    src/scripts/components/App.tsx
      Line 7:8:     'Loading' is defined but never used                            @typescript-eslint/no-unused-vars
    
  18. anushbmx commented on May 13, 2021

    @anushbmx

    @stclairdaniel add ESLINT_NO_DEV_ERRORS=true in your .env, it will skip these errors in development

  19. Nerdsie commented on Jun 4, 2021

    @Nerdsie

    This still seems like an issue when building. ESLINT_NO_DEV_ERRORS=true fixes when simply running for development, but when building the build still fails on lint errors

  20. rswerve commented on Jun 4, 2021

    @rswerve

    This still seems like an issue when building. ESLINT_NO_DEV_ERRORS=true fixes when simply running for development, but when building the build still fails on lint errors

    That’s the expected behavior. It’s the DEV in NO_DEV_ERRORS. If you don’t want a particular error to break your build, you can turn off the specific linting rule in your eslint config.

  21. Nerdsie commented on Jun 4, 2021

    @Nerdsie

    This still seems like an issue when building. ESLINT_NO_DEV_ERRORS=true fixes when simply running for development, but when building the build still fails on lint errors

    That’s the expected behavior. It’s the DEV in NO_DEV_ERRORS. If you don’t want a particular error to break your build, you can turn off the specific linting rule in your eslint config.

    Is there no build equivalent of ESLINT_NO_DEV_ERRORS? I don't want ANY lint errors to break my build, it's a style check, bad style should not be a reason for my deployment to suddenly be not building. I shouldn't have to go through and change all my lint rules to warning instead of errors, especially because then our CI workflow won't notify us of the lint "failure"

  22. rswerve commented on Jun 4, 2021

    @rswerve

    This still seems like an issue when building. ESLINT_NO_DEV_ERRORS=true fixes when simply running for development, but when building the build still fails on lint errors

    That’s the expected behavior. It’s the DEV in NO_DEV_ERRORS. If you don’t want a particular error to break your build, you can turn off the specific linting rule in your eslint config.

    Is there no build equivalent of ESLINT_NO_DEV_ERRORS? I don't want ANY lint errors to break my build, it's a style check, bad style should not be a reason for my deployment to suddenly be not building. I shouldn't have to go through and change all my lint rules to warning instead of errors, especially because then our CI workflow won't notify us of the lint "failure"

    @Nerdsie There is. Check out this PR. The environment variable DISABLE_ESLINT_PLUGIN set to true will do what you want.

  23. Nerdsie commented on Jun 4, 2021

    @Nerdsie

    @rswerve Thanks, just what I need. It still feels weird to me to have to disable (both in prod and dev, via seperate options) build breaking on lint errors. Are people using eslint in such a way that lint errors catch more than just deviation from preferred styling?

  24. rswerve commented on Jun 4, 2021

    @rswerve

    @rswerve Thanks, just what I need. It still feels weird to me to have to disable (both in prod and dev, via seperate options) build breaking on lint errors. Are people using eslint in such a way that lint errors catch more than just deviation from preferred styling?

    @Nerdsie Yes. For example, to enforce the Rules of Hooks. If someone wants to break one of those rules, we want them to be aware they're doing it and disable it deliberately, so we can see it in code review. And even with styling, on a team you're either enforcing consistent styles or you're not; we find it's less to think about if we are, so we break the build (this almost never happens, because everyone runs Prettier locally).

  25. soullivaneuh commented on Jun 30, 2022

    @soullivaneuh

    Confirming @rswerve solution, here is my build npm script:

    "build": "npx tsc --noEmit && DISABLE_ESLINT_PLUGIN=true CI=false react-scripts build",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions