Skip to content

[RFC]: Add lint support for enforcing header filename conventions #13658

Open

Description

@stdlib-bot

A package's primary header file and its include guard needs to match the package name, except for being in snakecase, rather than kebabcase.

We have this convention so that end users have a consistent rule for how to convert a package name to a header include path. If packages are allowed to deviate from that convention, end users would need to explicitly look up the include path for each package they wanted to use, which just creates unnecessary friction.

We should both (a) document and (b) create a lint rule for enforcing filenames and potentially support separate linting for enforcing include guards (although this may be tied to us getting clang linting up and running).

When linting filenames, we'd need to distinguish between the main include and additional includes which are intended to be private. For the latter, these are allowed to have any name (e.g., see ndarray/base/unary). What should be the case is that if a package has an include folder, there should always be a header file having a path matching the package name, with the file basename being the base package name converted to snakecase. I cannot think of an exception to this rule. And if we ever needed to make an exception, we could consider, at some point in the future, adding an associated config option to a package's package.json which allows disabling the lint rule.


Created via /stdlib todo from stdlib-js/stdlib#11830 by @kgryte.

Activity

  1. changed the title [-]Add lint support for enforcing header filename conventions [/-] [+][RFC]: Add lint support for enforcing header filename conventions[/+] on Jul 25, 2026
  2. Neeraj-1604 commented on Aug 15, 2026

    @Neeraj-1604

    I would like to take up this issue. My understanding is that for any package with an include/ directory, we need to enforce that a primary header file exists whose path matches the package path converted from kebab-case to snake_case (eg. include/stdlib/math/base/assert/int32_is_even.h), along with a matching #ifndef include guard (e.g. STDLIB_MATH_BASE_ASSERT_INT32_IS_EVEN_H), while allowing private/internal headers to use flexible names. To implement this, I will:

    • Document the header naming and include guard convention in docs/contributing/packages.md and the C style guide.
    • Extend the header linting tools in @stdlib/_tools/lint/header-filenames to validate primary header file presence and include guard format across packages, with support for potential package.json rule overrides.

    Could I be assigned to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions