DEV Community

Discussion on: What is your everything files or folders naming convention ?

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.