Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Fishrock123 opened this issue Sep 3, 2015 · 9 comments
Open

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

Fishrock123 opened this issue Sep 3, 2015 · 9 comments

Comments

@Fishrock123
Copy link

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
Copy link

piranna commented Sep 4, 2015

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
Copy link
Owner

konobi commented Sep 4, 2015

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

@piranna
Copy link

piranna commented Sep 4, 2015

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
Copy link
Owner

konobi commented Sep 4, 2015

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
Copy link
Author

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
Copy link
Owner

konobi commented Sep 4, 2015

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
Copy link

piranna commented Sep 4, 2015

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

@konobi
Copy link
Owner

konobi commented Oct 2, 2015

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
Copy link

piranna commented Oct 2, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants