Skip to content

Rule for blank line at start of file #21785

@skissane-medallia

Description

@skissane-medallia

Summary

I was looking for a rule which checks for a blank line at the start of a file – the first character of the file is a newline.

I can't find one... (I assume I just haven't failed to notice it.) it seems like it would be an easy thing to provide?

In a certain sense, the mirror image of too-many-newlines-at-end-of-file – except it would be triggered by any non-zero number of initial newlines, not by just one. (I guess you could also have it match whitespace followed by a newline.)

I realise the formatter will get rid of this, but I work on a code base where we are slowly introducing new ruff check rules, and we aren't yet at the point we want to enforce running ruff format on every file. But I just deleted every initial newline out of the code base, and I'd like a ruff check to ensure we don't get any coming back, but there doesn't seem to be one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionAwaiting a decision from a maintainerruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions