File naming & case-sensitivity

Spending time thinking about which casing should be used in Javascript projects is a good example of bike-shedding.

That said, I generally advocate for kebab-case naming for everything. It’s more readable, and it removes the decision of “what casing should I use”.

More importantly, I’ve encountered issues more than once in projects that used camel or pascal casing for filenames where, after a refactor, CI is red because git didn’t detect a change due to case insensitivity.

Network tab with no JS

The Linux filesystem ext4 is case-sensitive, by default. It interprets myModule.ts and MyModule.ts as two separate files.

MacOS’ default APFS is case-insensitive, by default. It interprets the filenames myModule.ts and MyModule.ts as the same file.

Depending on your machine’s configuration, bugs may arise when a you change the casing of a file by renaming it, e.g. myModule.ts to MyModule.ts

On a case-insensitive filesystem, git won’t recognize this change. The internal core.ignorecase setting dictates this behavior, and isn’t intended to be user-configurable. This can result in git excluding files when staging or committing.

It’s probable that the filesystem differs between your local environment and your CI/CD environment. For example, a module import may resolve locally but break in CI due to mismatched casing.