filename-case
Configuration
Rule Details
Enforces all linted files to have their names in a certain case style and a lowercase file extension. The default is kebabCase.
Files named index.js, index.mjs, index.cjs, index.ts, index.tsx, index.vue are ignored as they can't change case (only a problem with pascalCase).
Characters in the filename other than a-z, A-Z, 0-9, -, and _ are ignored.
Cases
kebabCase
foo-bar.jsfoo-bar.test.jsfoo-bar.test-utils.js
camelCase
fooBar.jsfooBar.test.jsfooBar.testUtils.js
snakeCase
foo_bar.jsfoo_bar.test.jsfoo_bar.test_utils.js
pascalCase
FooBar.jsFooBar.Test.jsFooBar.TestUtils.js
Options
case
Type: "camelCase" | "snakeCase" | "kebabCase" | "pascalCase"
Set a single allowed case style:
cases
Type: { camelCase?: boolean; snakeCase?: boolean; kebabCase?: boolean; pascalCase?: boolean }
Allow several case styles at once. Setting a key to true enables that style; the file passes if it matches any enabled style.
ignore
Type: string[]
Default: []
A list of regular-expression patterns (as strings) that match filenames the rule should skip.
multipleFileExtensions
Type: boolean
Default: true
When true, additional .-separated parts of the basename are treated as part of the extension and are not subject to case checking. When false, only the final extension is treated as such, and the rest of the basename must match the chosen case styles.
Differences from ESLint
- When the
casesoption enables more than one style, the diagnostic message lists the case names and rename suggestions in a fixed order: camel case, snake case, kebab case, pascal case. ESLint lists them in the order the keys appear in yourcasesobject. So{ pascalCase: true, camelCase: true }againstfoo-bar.jsreportsFilename is not in camel case or pascal case. Rename it to`fooBar.js`or`FooBar.js`.here, andFilename is not in pascal case or camel case. Rename it to`FooBar.js`or`fooBar.js`.in ESLint. - A regular-expression literal in
ignore(for example/^vendor/i) does not match anything. Write the pattern as a string — for example"^vendor"for/^vendor/, or"(?i)^vendor"for/^vendor/i.