Repository: eslint/eslint
File: lib/types/index.d.ts (TypeScript)

Code before:
            options: {
                filter?: ((token: AST.Token | ESTree.Comment) => boolean) | undefined;
                includeComments: boolean;
                count?: number | undefined;
            },
        ): Array<AST.Token | ESTree.Comment>;
    }
}

// #endregion

export namespace Rule {

    type RuleModule = RuleDefinition<{
        LangOptions: Linter.LanguageOptions,
        Code: SourceCode,
        RuleOptions: any[],
        Visitor: NodeListener,
        Node: ESTree.Node,
        MessageIds: string,
        ExtRuleDocs: {}
    }>;

    type NodeTypes = ESTree.Node["type"];
    interface NodeListener extends RuleVisitor {
        ArrayExpression?(node: ESTree.ArrayExpression & NodeParentExtension): void;
        "ArrayExpression:exit"?(node: ESTree.ArrayExpression & NodeParentExtension): void;
        ArrayPattern?(node: ESTree.ArrayPattern & NodeParentExtension): void;
        "ArrayPattern:exit"?(node: ESTree.ArrayPattern & NodeParentExtension): void;
        ArrowFunctionExpression?(node: ESTree.ArrowFunctionExpression & NodeParentExtension): void;
        "ArrowFunctionExpression:exit"?(node: ESTree.ArrowFunctionExpression & NodeParentExtension): void;
        AssignmentExpression?(node: ESTree.AssignmentExpression & NodeParentExtension): void;
        "AssignmentExpression:exit"?(node: ESTree.AssignmentExpression & NodeParentExtension): void;
        AssignmentPattern?(node: ESTree.AssignmentPattern & NodeParentExtension): void;
        "AssignmentPattern:exit"?(node: ESTree.AssignmentPattern & NodeParentExtension): void;
        AwaitExpression?(node: ESTree.AwaitExpression & NodeParentExtension): void;
        "AwaitExpression:exit"?(node: ESTree.AwaitExpression & NodeParentExtension): void;
        BinaryExpression?(node: ESTree.BinaryExpression & NodeParentExtension): void;
        "BinaryExpression:exit"?(node: ESTree.BinaryExpression & NodeParentExtension): void;
        BlockStatement?(node: ESTree.BlockStatement & NodeParentExtension): void;
        "BlockStatement:exit"?(node: ESTree.BlockStatement & NodeParentExtension): void;
        BreakStatement?(node: ESTree.BreakStatement & NodeParentExtension): void;
        "BreakStatement:exit"?(node: ESTree.BreakStatement & NodeParentExtension): void;
        CallExpression?(node: ESTree.CallExpression & NodeParentExtension): void;
        "CallExpression:exit"?(node: ESTree.CallExpression & NodeParentExtension): void;
        CatchClause?(node: ESTree.CatchClause & NodeParentExtension): void;
        "CatchClause:exit"?(node: ESTree.CatchClause & NodeParentExtension): void;
        ChainExpression?(node: ESTree.ChainExpression & NodeParentExtension): void;
        "ChainExpression:exit"?(node: ESTree.ChainExpression & NodeParentExtension): void;
        ClassBody?(node: ESTree.ClassBody & NodeParentExtension): void;
        "ClassBody:exit"?(node: ESTree.ClassBody & NodeParentExtension): void;

Review comment (suggestion):
Changed these from optional properties that could be a function or `undefined` to just optional methods in order to properly extend `RuleVisitor`. I think this is functionally equivalent.

Code after:
            right: ESTree.Node | AST.Token | ESTree.Comment,
            options: {
                filter?: ((token: AST.Token | ESTree.Comment) => boolean) | undefined;
                includeComments: boolean;
                count?: number | undefined;
            },
        ): Array<AST.Token | ESTree.Comment>;
    }
}

// #endregion

export namespace Rule {

    type RuleModule = RuleDefinition<{
        LangOptions: Linter.LanguageOptions,
        Code: SourceCode,
        RuleOptions: any[],
        Visitor: NodeListener,
        Node: ESTree.Node,
        MessageIds: string,
        ExtRuleDocs: {}
    }>;

    type NodeTypes = ESTree.Node["type"];
    interface NodeListener extends RuleVisitor {
        ArrayExpression?: ((node: ESTree.ArrayExpression & NodeParentExtension) => void) | undefined;
        "ArrayExpression:exit"?: ((node: ESTree.ArrayExpression & NodeParentExtension) => void) | undefined;
        ArrayPattern?: ((node: ESTree.ArrayPattern & NodeParentExtension) => void) | undefined;
        "ArrayPattern:exit"?: ((node: ESTree.ArrayPattern & NodeParentExtension) => void) | undefined;
        ArrowFunctionExpression?: ((node: ESTree.ArrowFunctionExpression & NodeParentExtension) => void) | undefined;
        "ArrowFunctionExpression:exit"?: ((node: ESTree.ArrowFunctionExpression & NodeParentExtension) => void) | undefined;
        AssignmentExpression?: ((node: ESTree.AssignmentExpression & NodeParentExtension) => void) | undefined;
        "AssignmentExpression:exit"?: ((node: ESTree.AssignmentExpression & NodeParentExtension) => void) | undefined;
        AssignmentPattern?: ((node: ESTree.AssignmentPattern & NodeParentExtension) => void) | undefined;
        "AssignmentPattern:exit"?: ((node: ESTree.AssignmentPattern & NodeParentExtension) => void) | undefined;
        AwaitExpression?: ((node: ESTree.AwaitExpression & NodeParentExtension) => void) | undefined;
        "AwaitExpression:exit"?: ((node: ESTree.AwaitExpression & NodeParentExtension) => void) | undefined;
        BinaryExpression?: ((node: ESTree.BinaryExpression & NodeParentExtension) => void) | undefined;
        "BinaryExpression:exit"?: ((node: ESTree.BinaryExpression & NodeParentExtension) => void) | undefined;
        BlockStatement?: ((node: ESTree.BlockStatement & NodeParentExtension) => void) | undefined;
        "BlockStatement:exit"?: ((node: ESTree.BlockStatement & NodeParentExtension) => void) | undefined;
        BreakStatement?: ((node: ESTree.BreakStatement & NodeParentExtension) => void) | undefined;
        "BreakStatement:exit"?: ((node: ESTree.BreakStatement & NodeParentExtension) => void) | undefined;
        CallExpression?: ((node: ESTree.CallExpression & NodeParentExtension) => void) | undefined;
        "CallExpression:exit"?: ((node: ESTree.CallExpression & NodeParentExtension) => void) | undefined;
        CatchClause?: ((node: ESTree.CatchClause & NodeParentExtension) => void) | undefined;
        "CatchClause:exit"?: ((node: ESTree.CatchClause & NodeParentExtension) => void) | undefined;
        ChainExpression?: ((node: ESTree.ChainExpression & NodeParentExtension) => void) | undefined;
        "ChainExpression:exit"?: ((node: ESTree.ChainExpression & NodeParentExtension) => void) | undefined;
        ClassBody?: ((node: ESTree.ClassBody & NodeParentExtension) => void) | undefined;