Skip to content

Extending react-app eslint config in non-typescript app #10502

Open

Description

@thisismydesign

Describe the bug

I'm trying the DISABLE_ESLINT_PLUGIN flag added to react-scripts in v4.0.2. In .eslintrc.js:

  extends: [
    "react-app",
  ]

This gives me

$ eslint .

Oops! Something went wrong! :(

ESLint: 7.19.0

Error: Failed to load parser '@typescript-eslint/parser' declared in '.eslintrc.js » eslint-config-react-app#overrides[0]': Cannot find module 'typescript'

I'm on a non-typescript project. Do I still have to configure it as if it was a typescript project if I want to use the react-app ruleset? This is what the readme of https://www.npmjs.com/package/eslint-config-react-app indicates as well, but it would be great to be able to use it without all of these dependencies. Especially when using create-react-app.

Environment

Environment Info:

  current version of create-react-app: 4.0.2
  running from /root/.npm/_npx/13859/lib/node_modules/create-react-app

  System:
    OS: Linux 4.19 Ubuntu 18.04.1 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
  Binaries:
    Node: 14.10.0 - ~/.nvm/versions/node/v14.10.0/bin/node
    Yarn: 1.22.5 - ~/.nvm/versions/node/v14.10.0/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.10.0/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    react: ^16.13.1 => 16.13.1 
    react-dom: ^16.13.1 => 16.13.1 
    react-scripts: 4.0.2 => 4.0.2 
  npmGlobalPackages:
    create-react-app: Not Found

Activity

  1. added this to the 4.0.3 milestone on Feb 5, 2021
  2. mrmckeb commented on Feb 5, 2021

    @mrmckeb
    Contributor

    Hi @thisismydesign, this has been an issue for a long time now I think.

    It's because we use TS dependencies in the config, even if those are scoped to .ts and .tsx files.
    https://github.com/facebook/create-react-app/blob/master/packages/eslint-config-react-app/index.js#L34

    I'm not 100% sure how to solve this - we have the same problem with an ESLint config in my company, but ignored it as we only use TS on new projects anyway... So I get that it can be a pain-point.

    Do you have any thoughts on this? Maybe @ianschmitz has some ideas too.

  3. modified the milestones: 4.0.3, 4.0.4 on Feb 22, 2021
  4. modified the milestones: 4.1, 4.x on May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions