Skip to content

Feature: handle .prettierignore location like .gitignore and .npmignore #4081

@bebbi

Description

@bebbi

Suggested feature: handle .prettierignore files like .gitignore and .npmignore files, allowing them at any level of the project, not only root.

Use-case:
Using prettier in sub-projects and their "container" projects, where they are editable both from within a sub-projects repository, as well as the container repository.
Examples: git submodules, git subtree, git subrepo, and mechanisms to sync mono- and sub-repos such as splitsh

In this case, we may need a .prettierignore file that is specific to a sub-project and is located at the sub-tree root rather than the project root. Otherwise, we need duplicate .prettierignore declarations with different paths in the sub-project repo and in the container repo.

From git docs:

Patterns read from a .gitignore file in the same directory as the path, or in any parent directory,
with patterns in the higher level files (up to the toplevel of the work tree) being overridden
by those in lower level files down to the directory containing the file.
These patterns match relative to the location of the .gitignore file.
A project normally includes such .gitignore files in its repository,
containing patterns for files generated as part of the project build.

From npm docs:

Like git, npm looks for .npmignore and .gitignore files in all subdirectories of your package,
not only the root directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliIssues with Prettier's Command Line Interfacearea:ignore.prettierignore file, --ignore-path CLI option, /* prettier-ignore */ comments and so onstatus:needs discussionIssues needing discussion and a decision to be made before action can be taken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions