Skip to content

no-empty-file always false positives in @typescript-eslint/parser@6 #2175

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Right now, no-empty-file assumes that if an AST node includes a directive property, then that's enough to indicate it's a directive:

const isDirective = node => node.type === 'ExpressionStatement' && 'directive' in node;

That assumption no longer holds true in @typescript-eslint/parser's v6.0.0 due to typescript-eslint/typescript-eslint#6274. We changed the AST shape roughly like:

- directive?: string;
+ directive: string | undefined;

https://github.com/typescript-eslint/typescript-eslint/blob/df131e258c93e5714c88c0373cfeb2e1e75afc75/packages/ast-spec/src/statement/ExpressionStatement/spec.ts#L8

The PR explains why we did that (tl;dr: normalizing AST node shapes). So eslint-plugin-unicorn will need to update with a change like:

- const isDirective = node => node.type === 'ExpressionStatement' && 'directive' in node;
+ const isDirective = node => node.type === 'ExpressionStatement' && node.directive;

Right now, no-empty-line is flagging totally valid files such as https://github.com/jakebailey/pyright-action/pull/19/files#diff-1e058ca1442e46581b13571fb8d261f9e1f5657e26c96634d4c1072f0f0347f1. Thanks @jakebailey for reporting!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions