Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about invalid globs in content #6449

Merged
merged 3 commits into from Dec 13, 2021
Merged

Warn about invalid globs in content #6449

merged 3 commits into from Dec 13, 2021

Conversation

RobinMalfait
Copy link
Contributor

@RobinMalfait RobinMalfait commented Dec 13, 2021

This PR will try and fix bogus globs

When using globs, there is this option called "brace expansion", this means that you can simplify some globs instead of repeating the same thing over and over again. For example:

./src/**/*.html
./src/**/*.js

Can be simplified as:

./src/**/*.{html,js}

This is also what we explain in our docs: https://tailwindcss.com/docs/installation

However, it seems like some people are changing that glob to better match their project which is totally fine. However, a lot of people end up with invalid globs.

./src/**/*.{html}

This is an invalid glob, notice that there is only 1 item inside the { & }.
This is the same behaviour as brace expansion in your terminal.

Here is an example from my terminal output inside the tailwindcss repo:

$ ls -la *.{json} # Invalid
zsh: no matches found: *.{json}
$ ls -lah *.json # Valid
-rw-r--r--  1 robin  staff   438K Dec 12 22:18 package-lock.json
-rw-r--r--  1 robin  staff   3.1K Dec 12 22:18 package.json
$ ls -lah *.{json,js} # Valid
-rw-r--r--  1 robin  staff   120B Dec 12 22:18 colors.js
-rw-r--r--  1 robin  staff   156B Dec 12 22:18 defaultConfig.js
-rw-r--r--  1 robin  staff   151B Dec 12 22:18 defaultTheme.js
-rw-r--r--  1 robin  staff   438K Dec 12 22:18 package-lock.json
-rw-r--r--  1 robin  staff   3.1K Dec 12 22:18 package.json
-rw-r--r--  1 robin  staff   151B Dec 12 22:18 plugin.js
-rw-r--r--  1 robin  staff   446B Sep  1 17:36 prettier.config.js
-rw-r--r--  1 robin  staff   156B Dec 12 22:18 resolveConfig.js

This PR will try and detect those bogus cases and rewrite show a warning with a fix for the glob.

./src/**/*.{html}

Should become:

./src/**/*.html

Example warning output:

warn - The glob pattern ./src/**/*.{html} in your config is invalid.
warn -     Update it to ./src/**/*.html to silence this warning.

image

Fixes: #6394

@RobinMalfait RobinMalfait force-pushed the rewrite-globs branch 2 times, most recently from 64c3c50 to c276b1f Compare December 13, 2021 13:33
@RobinMalfait RobinMalfait changed the title Rewrite invalid globs if we can Warn on invalid globs if we can Dec 13, 2021
@RobinMalfait RobinMalfait changed the title Warn on invalid globs if we can Warn about invalid globs in content Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New content property in tailwind.config does not work if only one extension (.tsx) is provided
1 participant