Skip to content

Option in TSConfig to include hidden/dot filesΒ #49555

Open
@regseb

Description

@regseb

Suggestion

πŸ” Search Terms

hidden, dot, dotfile, include, tsconfig.

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Add an option in TSConfig to include hidden files (and hidden directories) in include and exclude options.

{
    "hidden": true,
    "include": ["**/*"],
}

Other alternative names for hidden:

  • dot like in:
    • node-glob: Include .dot files in normal matches and globstar matches. Note that an explicit dot in a portion of the pattern will always match dot files.
    • globby and fast-glob: Allow patterns to match entries that begin with a period (.).
    • tinyglobby: Whether to allow entries starting with a dot.
  • dotfiles like in express and serve-static (it used hidden before): Determines how dotfiles (files or directories that begin with a dot β€œ.”) are treated.
  • includeDot and excludeDot by silverwind: #49555 (comment)

πŸ“ƒ Motivating Example

Proposal for wildcard documentation:

include and exclude support wildcard characters to make glob patterns:

  • * matches zero or more characters (excluding directory separators and hidden file if hidden is set to false)
  • ? matches any one character (excluding directory separators)
  • **/ matches any directory nested to any level (excluding hidden directory if hidden is set to false)

πŸ’» Use Cases

I want to scan all files in my project, even hidden files and files in a hidden directory. I use this TSConfig (⚠️ which doesn't list files in two hidden directories, e.g. .foo/.bar/baz.ts):

{
    "include": [
        "**/*",
        "**/.*",
        "**/.*/**/*",
        "**/.*/**/.*"
    ]
}

πŸ”— Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions