Skip to content

Commit b8cda16

Browse files
authored
Improve warnings (#5666)
1 parent 55cf564 commit b8cda16

File tree

7 files changed

+20
-36
lines changed

7 files changed

+20
-36
lines changed

src/corePlugins.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ export let variantPlugins = {
302302
if (mode === false) {
303303
mode = 'media'
304304
log.warn('darkmode-false', [
305-
'`darkMode` is set to `false` in your config.',
306-
'This will behave just like the `media` value.',
305+
'The `darkMode` option in your Tailwind CSS configuration is set to `false`, which now behaves the same as `media`.',
306+
'Change `darkMode` to `media` or remove it entirely.',
307307
])
308308
}
309309

src/featureFlags.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function issueFlagNotices(config) {
4040

4141
log.warn('experimental-flags-enabled', [
4242
`You have enabled experimental features: ${changes}`,
43-
'Experimental features are not covered by semver, may introduce breaking changes, and can change at any time.',
43+
'Experimental features in Tailwind CSS are not covered by semver, may introduce breaking changes, and can change at any time.',
4444
])
4545
}
4646
}

src/lib/generateRules.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -293,24 +293,17 @@ function* resolveMatches(candidate, context) {
293293
)
294294
.join('\n\n')
295295

296-
messages.push(
297-
` - Replace "${candidate}" with "${candidate.replace(
298-
'[',
299-
`[${type}:`
300-
)}" for:\n${rules}\n`
301-
)
296+
messages.push(` Use \`${candidate.replace('[', `[${type}:`)}\` for \`${rules.trim()}\``)
302297
break
303298
}
304299
}
305300

306301
log.warn([
307-
// TODO: Update URL
308-
`The class "${candidate}" is ambiguous and matches multiple utilities. Use a type hint (https://tailwindcss.com/docs/just-in-time-mode#ambiguous-values) to fix this.`,
309-
'',
302+
`The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
310303
...messages,
311-
`If this is just part of your content and not a class, replace it with "${candidate
304+
`If this is content and not a class, replace it with \`${candidate
312305
.replace('[', '[')
313-
.replace(']', ']')}" to silence this warning.`,
306+
.replace(']', ']')}\` to silence this warning.`,
314307
])
315308
continue
316309
}

src/lib/normalizeTailwindDirectives.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ export default function normalizeTailwindDirectives(root) {
4242
if (['layer', 'responsive', 'variants'].includes(atRule.name)) {
4343
if (['responsive', 'variants'].includes(atRule.name)) {
4444
log.warn(`${atRule.name}-at-rule-deprecated`, [
45-
`'@${atRule.name}' is deprecated, use '@layer utilities' or '@layer components' instead.`,
45+
`The \`@${atRule.name}\` directive has been deprecated in Tailwind CSS v3.0.`,
46+
`Use \`@layer utilities\` or \`@layer components\` instead.`,
4647
])
4748
}
4849
layerDirectives.add(atRule)

src/lib/setupContextUtils.js

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -306,18 +306,8 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
306306
return []
307307
}
308308

309-
if (!type.includes(coercedType)) {
310-
if (isOnlyPlugin) {
311-
log.warn([
312-
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
313-
`You can safely update it to \`${identifier}-${modifier.replace(
314-
coercedType + ':',
315-
''
316-
)}\`.`,
317-
])
318-
} else {
319-
return []
320-
}
309+
if (!type.includes(coercedType) && !isOnlyPlugin) {
310+
return []
321311
}
322312

323313
if (!isValidArbitraryValue(value)) {
@@ -615,9 +605,9 @@ function registerPlugins(plugins, context) {
615605

616606
if (value instanceof RegExp) {
617607
log.warn('root-regex', [
618-
// TODO: Improve this warning message
619-
'RegExp in the safelist option is not supported.',
620-
'Please use the object syntax instead: https://tailwindcss.com/docs/...',
608+
'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
609+
'Update your `safelist` configuration to eliminate this warning.',
610+
// TODO: Add https://tw.wtf/regex-safelist
621611
])
622612
continue
623613
}
@@ -665,9 +655,8 @@ function registerPlugins(plugins, context) {
665655
if (count !== 0) continue
666656

667657
log.warn([
668-
// TODO: Improve this warning message
669-
`You have a regex pattern in your "safelist" config (${regex}) that doesn't match any utilities.`,
670-
'For more info, visit https://tailwindcss.com/docs/...',
658+
`The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
659+
'Fix this pattern or remove it from your `safelist` configuration.',
671660
])
672661
}
673662
}

src/public/colors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import log from '../util/log'
33
function warn({ version, from, to }) {
44
log.warn(`${from}-color-renamed`, [
55
`As of Tailwind CSS ${version}, \`${from}\` has been renamed to \`${to}\`.`,
6-
'Please update your color palette to eliminate this warning.',
6+
'Update your configuration file to silence this warning.',
77
])
88
}
99

src/util/normalizeConfig.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ export function normalizeConfig(config) {
122122

123123
if (!valid) {
124124
log.warn('purge-deprecation', [
125-
'The `purge` option in your tailwind.config.js file has been deprecated.',
126-
'Please rename this to `content` instead.',
125+
'The `purge`/`content` options have changed in Tailwind CSS v3.0.',
126+
'Update your configuration file to eliminate this warning.',
127+
// TODO: Add https://tw.wtf/purge-deprecation
127128
])
128129
}
129130

0 commit comments

Comments
 (0)