Skip to main content

consistent-filename

Enforce filename casing consistency.

Targeted pattern scope​

This rule validates the current file’s stem (filename without extension) against one configured casing format.

What this rule reports​

This rule reports a file when its stem is not already in the configured casing.

Supported casing formats:

  • camelCase
  • kebab-case (default)
  • PascalCase

Why this rule exists​

Consistent file naming reduces navigation friction and prevents style drift across packages.

❌ Incorrect​

// filename: user_service.ts
export const value = 1;
// ❌ with default format "kebab-case"

βœ… Correct​

// filename: user-service.ts
export const value = 1;

Deprecated​

  • Lifecycle: Deprecated and frozen.
  • Deprecated since: v1.0.0
  • Available until: v2.0.0
  • Use instead: unicorn/filename-case

Behavior and migration notes​

This rule is deprecated in favor of unicorn/filename-case.

It reports only and does not provide an autofix.

Options​

type Options = [
{
format?: "camelCase" | "kebab-case" | "PascalCase";
},
];

Default:

{
format: "kebab-case";
}

Status​

Use the Deprecated section above for lifecycle details.

Additional examples​

// filename: dataLoader.ts
// βœ… valid with { format: "camelCase" }

// filename: DataLoader.ts
// βœ… valid with { format: "PascalCase" }

ESLint flat config example​

import etcMisc from "eslint-plugin-etc-misc";

export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/consistent-filename": "error",
},
},
];

When not to use it​

Disable this rule if your repository intentionally mixes naming styles by directory or if you are already standardizing on unicorn/filename-case.

Package documentation​

Rule catalog ID: R006

Further reading​

Adoption resources​

  • Start at warning level in CI, then move to error after cleanup.
  • Use focused codemods/autofix batches per package or directory.