The Problem
Many developers and so many projects unfortunately use inconsistent file naming patterns, especially for configuration files. We often see patterns like .env.development
instead ofdevelopment.env
.
.env, .dockerfile and others are actually file extensions, and it's a mystery why people start to suffix the file type and this page is trying to change this.
This creates confusion and inconsistency in codebases. Let's explore why the proper convention matters and how to fix it.
The Proper Convention
Incorrect Pattern
Adding purpose after the extension:
- .env.development
- Dockerfile.static
- Makefile.local
- .gitignore.template
Correct Pattern
Adding purpose before the extension:
- development.env
- static.dockerfile
- local.makefile
- template.gitignore
Common Examples
File Type | Common (Incorrect) | Proper (Correct) |
---|---|---|
Environment Variables | .env.local | local.env |
Docker Configuration | Dockerfile.prod | prod.dockerfile |
Build Scripts | Makefile.ci | ci.makefile |
Git Configuration | .gitignore.node | node.gitignore |
Shell Scripts | setup.sh.macos | macos.setup.sh |
Why It Matters
File extensions tell us what type of file we're looking at. The name before the extension should tell us its purpose or variant, not the other way around.
Proper naming allows files to be grouped by extension first, then sorted by their purpose, making them easier to find in directories with many files.
Commands like *.env
will match all environment files regardless of their purpose, making shell operations more intuitive.
Many tools recognize files by their extensions. Proper naming ensures better syntax highlighting, linting, and other tooling support.
Try It Yourself
Convert your incorrectly named files to the proper convention: