Require Kebab Case Filename
Require kebab-case file names for TypeScript files so the file system stays consistent and case-insensitive platforms behave predictably.
Summary
The require-kebab-case-filename rule checks the file name stem (without known extensions like .ts, .tsx, .d.ts, .test.ts, etc.) against a kebab-case pattern.
If the stem does not match, the rule reports on the first line of the file.
Why Use This Rule?
- Prevents case-sensitivity issues across platforms — macOS and Windows treat
MyFile.tsandmyfile.tsas the same file, causing subtle bugs. - Keeps the file system consistent and predictable across the entire codebase.
- Aligns file names with URL conventions and package naming standards.
Examples
Configuration
Options
warning
ignoreFiles is an escape hatch for files where this rule genuinely does not apply. It is not intended for routine use.
| Option | Type | Default | Description |
|---|---|---|---|
extraExtensions | string[] | [] | Compound extensions to strip before validating the stem. |
ignoreFiles | string[] | [] | File patterns to skip. |
Autofix
Autofix is not available for this rule. Flagged code must be updated manually.
Troubleshooting
- Warning fires on a generated file — Add the file pattern to
ignoreFiles(e.g.,['**/generated/**']). - Warning fires on a file with compound extensions — The rule strips known extensions (
.d.ts,.test.ts,.tsx, etc.) before checking. If your extension is not recognized, the full name including the extra extension is checked against kebab-case. - Want to allow PascalCase for React components — Add the component file patterns to
ignoreFiles(e.g.,['**/components/**']).