Skip to content

eslint binary is not in the top level node_modules/.bin folder after creating an app #247

Closed
@keyz

Description

@keyz

I tested #149 again with create-react-app my-app --scripts-version 0.2.0-alpha.1 and noticed that ESLint in editor doesn't work as expected. Digging down into the issue and I realized our global-cli and npm run create-react-app in the main repo generate different node_module structures (I'm using npm 3):

A global create-react-app my-app call generates:

node_modules (top level)
├── .bin
│   ├── loose-envify
│   └── react-scripts
├── ...
└── react-scripts
    ├── ...
    └── node_modules
        └── .bin
            ├── ...
            └── eslint // 😢

And npm run create-react-app my-app in the main repo generates:

node_modules (top level)
├── .bin
│   ├── ... (everything's here like webpack, react-scripts, etc.)
│   └── eslint // 😃
├── ...
└── react-scripts
    ├── ...
    └── no node_modules here

As a result, the ESlint in editor part doesn't work for a global cli call. I've only tested my PR using the npm run create-react-app script and that's why I thought it was working for me. :(

To be clear, this issue only happens before ejecting; after ejecting eslint will be moved to the top level node_modules/.bin folder so it works fine. I think there's nothing wrong with "extends": "./node_modules/react-scripts/config/eslint.js"; the problem is the eslint binary gets put in a deep node_modules/.bin folder so editors (plugins) can't find it.

TBH I'm not sure what's a good way to fix this. Could we flatten the node_module structure while creating an app?

cc @gaearon @vjeux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions