Skip to content

filename

Kotlinstyleno fixdefault: offkotlin/ktlint

Reports a .kt file whose name, up to its first dot, is not in PascalCase. The check that a file with a single class is named after it is not made.

Kotlin files that hold a class are named after it, and the convention for all files is PascalCase. A file named my-file.kt has a name that cannot be the name of a class in it, and tools that match file and class names do not find it.

To fix, rename the file (MyFile.kt).

Reported
package a
kotlin:
lint:
rules:
filename:
level: warn # off (default), warn, error
options:
pattern: "^[A-Z][A-Za-z0-9]*$"
Option Type Default Description
pattern string "^[A-Z][A-Za-z0-9]*$" Regular expression the file name up to its first dot must match; empty: not checked.

Enabled by the presets: kotlin/ktlint.

Suppress one line with sudsy-disable-next-line filename in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
ktlint filename partial A file with a single class is not checked against the class name