Description
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)