Require filenames to match a regex naming convention (github/filenames-match-regex)
March 19, 2025 ยท View on GitHub
Rule Details
Rule to ensure that filenames match a convention, with a default of kebab case or camelCase with one hump for flat config.
๐ Examples of incorrect filename for this default rule:
fileNameRule.js
๐ Examples of correct code for this rule:
fileName.jsfile-name.js
Options
regex - Regex to match the filename structure. Defaults to kebab case or camelCase with one hump.
Default:
{
"filenames-match-regex": [
"error"
]
}
If you want to add custom regex such as matching all camelCase, add the regex as a string. For example, for camelCase it would look like:
{
"filenames-match-regex": [
"error",
"^([a-z0-9]+)([A-Z][a-z0-9]+)*$"
]
}
Version
4.3.2