prefer-match-file-name

Group
Style
Path
lint/style/prefer-match-file-name
Default
Off, opt in
Origin
Falcon
Rule
384 of 512

Match a file's sole class or enum name to its snake-case basename.

Other declarations may coexist with the type. Files with multiple classes or enums, generated inner-dot suffixes, and part-of files are left alone. Naming convention violations themselves belong to the existing naming rules.

Invalid

example.dartdart
class Account {
  final int id;
  Account(this.id);
}
The sole class or enum `Account` does not match this filename. Rename the file to `account.dart` or rename the declaration to match the file.
1class Account {

Valid

example.dartdart
class Good {
  void run() {}
}

Configure prefer-match-file-name

Set its severity in falcon.json. See the configuration guide.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "style": {
        "prefer-match-file-name": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/style/prefer-match-file-name: <reason>