DEV Community

loading...

What is your everything files or folders naming convention ?

drozerah profile image Drozerah ・1 min read

Hi,

I'd like to know what is your files and folders naming convention if you have one ?

hello_world.ext
hello-world.ext
hello.world.ext ...

Can you explain your preference in the way to fit best to that data programming world we are living in ?

Thanks

Discussion (2)

pic
Editor guide
Collapse
sargalias profile image
Spyros Argalias • Edited

I personally use camel case for most things, or pascal case if something is exporting a class (or React component).

Also I always prefer a component based file structure.

React component example:
Foo/
Foo.jsx
Foo.test.jsx
Foo.module.scss - Further, I use camel casing for classes for consistency.
index.js

Standard module not exporting a class:
foo/
foo.js
foo.test.js
index.js

Reasoning

It doesn't matter for private projects. As long as you're consistent within your team and codebase. It really doesn't matter at all.

But benefits for camel casing are:

  • It's the standard typing style in the JavaScript ecosystem.
  • It's the easiest to type.
  • We can use camel case stuff in JavaScript.

In a private project, the rest are okay too. Underscore case is very readable, but I find it the slowest to type. Kebab case is quite readable too, but I just don't like the look of it as much. Also we can't use kebab style in JavaScript, so that's a negative point in terms of consistency.

Collapse
yokotobe profile image
yokotobe
  1. I prefer not to put dot in filename as dot is used to seperate name and extension.
  2. Use underscore for word seperation
  3. No Camel case because it does not treat the same on Windows and Linux

ex.

good_naming.log