konobi / kwalitee

Package for measuring node package kwalitee
MIT License
12 stars 5 forks source link

Keep entry code in the main folder, and out of lib/ #8

Open Fishrock123 opened 9 years ago

Fishrock123 commented 9 years ago

Putting your entry code in more folders just makes it harder for everyone else to get to. I mean, unless you want to hide your code I guess. :)

If you have other files required by your index.js, or whichever other entry file, that's fine to go into lib/ or other top-level files, if it doesn't belong in another module.

From: https://twitter.com/konobi/status/639536896968892416

piranna commented 9 years ago

If you have other files required by your index.js, or whichever other entry file, that's fine to go into lib/ or other top-level files, if it doesn't belong in another module.

In that case (several js files), index.js should be in the lib/ folder too to have all the code in only one place.

The same could be specified for other folders/files (test, bin, src, doc...): when having only one file of a kind have in the root of the project, when having several put all of them inside their folder.

konobi commented 9 years ago

I believe everything should live under lib and there should be no *.js files in the root folder of the package.

piranna commented 9 years ago

I believe everything should live under lib and there should be no *.js files in the root folder of the package.

I think too, but I find acceptable to have an index.js file in the root folder of the package (that's already the package.json main entry default value) if it's the only one Javascript file in the project, except maybe a cli.js too for the command line executable since it's of a different kind (bin, not lib).

konobi commented 9 years ago

I still think it's better to have them in a folder... this also helps with things like doing lint testing, etc. The hope is to encourage good/best practices, but to do that, somewhere someone has to pick what's the best option for the community, going forward.

Fishrock123 commented 9 years ago

I believe everything should live under lib and there should be no *.js files in the root folder of the package.

Why?

this also helps with things like doing lint testing, etc.

How so?

konobi commented 9 years ago

Well, the first is a choice. The second is because it makes it easier to apply a lint to a directory rather than a directory and a random group of files. And you probably want to treat tests with a different lint profile.

piranna commented 9 years ago

I wouldn't read files but instead follow the require()s tree.

konobi commented 8 years ago

Well, based on some input, it seems like requiring that everything is in either "lib" or the code directory is configured in package.json is the best option.

piranna commented 8 years ago

:+1: