microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.03k stars 12.37k forks source link

Option in TSConfig to include hidden files #49555

Open regseb opened 2 years ago

regseb commented 2 years ago

Suggestion

🔍 Search Terms

hidden, dot, include, tsconfig.

✅ Viability Checklist

My suggestion meets these guidelines:

⭐ 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:

📃 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:

{
    "include": [
        "**/*",
        "**/.*",
        "**/.*/**/*",
        "**/.*/**/.*"
    ]
}
doktordirk commented 1 year ago

Use case: .storybook folder

dartess commented 1 year ago

Thans for workaround. After updating to version @5, I began to get errors in the IDE in storybook files.

ernestostifano commented 1 year ago

Having issues with .storybook folder too

psychobolt commented 1 year ago

Even in TS 5.0, .storybook or any dot folders needs to be explicitly included in config.

SalvatorePreviti commented 1 year ago

This is particularly problematic with typescript eslint:

Parsing error: ESLint was configured to run on <tsconfigRootDir>/packages/eslint-config/.prettierrc.js using parserOptions.project: folder/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the typescript-eslint docs for more info: https://typescript-eslint.io/linting/troubleshooting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file
silverwind commented 11 months ago

I would not name the option hidden (which is too ambigous), but includeDot and excludeDot.

artshade commented 10 months ago

I would not name the option hidden (which is too ambigous), but includeDot and excludeDot.

This is correct. "Hidden" depends on the environment. In case of Linux, yes, but still depends on the filesystem and some don't have EXT4, hence "dotfiles".

What about Windows? Please correct if mistaken, but in Windows, you have NTFS with both prefixes like $ and file metadata as hidden and system referenced in file header attributes.

Related

ryallen-nokia commented 7 months ago

Use case: .storybook folder

Adding .storybook/**/* to the config include array works.

MonstraG commented 7 months ago

Today got bit by the fact that hidden files are ignored because it was refusing to look at .eslintrc.js

bostrom commented 5 months ago

In the Storybook case (using typescript-eslint), the following worked for me:

.tsconfig

  "include": [
    ".storybook/**/*"
  ],

.eslintrc

  ignorePatterns: [
    '!.storybook',
  ],