Skip to content

Consider that some node_modules folders aren't vendor #677

Closed
@daltones

Description

@daltones

I'd like to propose a change in no-extraneous-dependencies rule.

Currently, that rule understands that every module from a node_modules folder is a dependency that should be specified in package.json.

The last few days I was considering drop all kinds of hacks to resolve modules in my projects (such as babel-plugin-module-resolver or some webpack configuration). And the solution is obvious: I could use a node_modules folder inside my src folder for all my modules.

I guess that is the real standard way intended first, but then people started to associate the node_modules folder to strictly npm dependencies.

So I propose that no-extraneous-dependencies considers only node_modules folder that are sibling of a package.json.

Then we could have a structure like this:

project/
  package.json
  node_modules/        # there could be some extraneous dependency
  src/
    node_modules/      # every module inside this folder would be not extraneous, because there's no sibling package.json
      foo.js
      bar.js
      baz/
        index.js
    index.js

Inside src/ we can reference every module in a absolute way, because we're just following the built in resolving logic of Node. 😃


Later I saw (if I understood right) that Create React App is following that idea too (see facebook/create-react-app#1065)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions