Skip to content

useFilenamingConvention

Diagnostic Category: lint/style/useFilenamingConvention

Since: v1.5.0 Sources:

Enforce naming conventions for JavaScript and TypeScript filenames.

Enforcing naming conventions helps to keep the codebase consistent.

A filename consists of two parts: a name and a set of consecutive extension. For instance, my-filename.test.js has my-filename as name, and two consecutive extensions: .test and .js.

The filename can start with a dot or a plus sign, be prefixed and suffixed by underscores _. For example, .filename.js, +filename.js, __filename__.js, or even .__filename__.js.

The convention of prefixing a filename with a plus sign is used by Sveltekit and Vike.

Also, the rule supports dynamic route syntaxes of Next.js, SolidStart, Nuxt, and Astro. For example [...slug].js and [[...slug]].js are valid filenames.

By default, the rule ensures that the filename is either in camelCase, kebab-case, snake_case, or equal to the name of one export in the file.

Sometimes you want to completely ignore some files. Biome ignore comments cannot be used because the rule applies on filenames not file contents. To ignore files, you can use overrides. If you want to ignore all files in the test directory, then you can disable the rule for those files only:

{
"overrides": [
{
"include": ["test/**/*"],
"linter": {
"rules": {
"style": {
"useFilenamingConvention": "off"
}
}
}
}
]
}

The rule provides several options that are detailed in the following subsections.

{
"//": "...",
"options": {
"strictCase": false,
"requireAscii": true,
"filenameCases": ["camelCase", "export"]
}
}

When this option is set to true, it forbids consecutive uppercase characters in camelCase and PascalCase. For instance, when the option is set to true, agentID will throw an error. This name should be renamed to agentId.

When the option is set to false, consecutive uppercase characters are allowed. agentID is so valid.

Default: true

When this option is set to true, it forbids names that include non-ASCII characters. For instance, when the option is set to true, café or 안녕하세요 will throw an error.

When the option is set to false, a name may include non-ASCII characters. café and 안녕하세요 are so valid.

Default: false

This option will be turned on by default in Biome 2.0.

By default, the rule enforces that the filename is either in camelCase, kebab-case, snake_case, or equal to the name of one export in the file.

You can enforce a stricter convention by setting filenameCases option. filenameCases accepts an array of cases among the following cases: camelCase, kebab-case, PascalCase, snake_case, and export.