Skip to content

unicorn/filename-case Style

What it does

Enforces specific case styles for filenames. By default, kebab case is enforced.

Why is this bad?

Inconsistent file naming conventions make it harder to locate files, navigate projects, and enforce consistency across a codebase. Standardizing naming conventions improves readability, reduces cognitive overhead, and aligns with best practices in large-scale development.

Cases

Examples of correct filenames for each case:

kebabCase

  • some-file-name.js
  • some-file-name.test.js
  • some-file-name.test-utils.js

camelCase

  • someFileName.js
  • someFileName.test.js
  • someFileName.testUtils.js

snakeCase

  • some_file_name.js
  • some_file_name.test.js
  • some_file_name.test_utils.js

pascalCase

  • SomeFileName.js
  • SomeFileName.Test.js
  • SomeFileName.TestUtils.js

Options

Use kebabCase as the default option.

case

{ type: 'kebabCase' | 'camelCase' | 'snakeCase' | 'pascalCase' }

You can set the case option like this:

json
"unicorn/filename-case": [
  "error",
  {
    "case": "kebabCase"
  }
]

cases

{ type: { [key in 'kebabCase' | 'camelCase' | 'snakeCase' | 'pascalCase']?: boolean } }

You can set the case option like this:

json
"unicorn/filename-case": [
  "error",
  {
    "cases": {
      "camelCase": true,
      "pascalCase": true
    }
  }
]

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny unicorn/filename-case
json
{
  "rules": {
    "unicorn/filename-case": "error"
  }
}

References

Released under the MIT License.