Skip to content

Commit

Permalink
Don't calculate didYouMean suggestions prematurely
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Oct 19, 2020
1 parent 7572b02 commit 6fa213d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/substituteClassApplyAtRules.js
Expand Up @@ -167,15 +167,16 @@ function makeExtractUtilityRules(css, lookupTree, config) {
if (utilityMap[utilityName] === undefined) {
// Look for prefixed utility in case the user has goofed
const prefixedUtility = prefixSelector(config.prefix, `.${utilityName}`).slice(1)
const suggestedClass = didYouMean(utilityName, Object.keys(utilityMap))
const suggestionMessage = suggestedClass ? `, but \`${suggestedClass}\` does` : ''

if (utilityMap[prefixedUtility] !== undefined) {
throw rule.error(
`The \`${utilityName}\` class does not exist, but \`${prefixedUtility}\` does. Did you forget the prefix?`
)
}

const suggestedClass = didYouMean(utilityName, Object.keys(utilityMap))
const suggestionMessage = suggestedClass ? `, but \`${suggestedClass}\` does` : ''

throw rule.error(
`The \`${utilityName}\` class does not exist${suggestionMessage}. If you're sure that \`${utilityName}\` exists, make sure that any \`@import\` statements are being properly processed before Tailwind CSS sees your CSS, as \`@apply\` can only be used for classes in the same CSS tree.`,
{ word: utilityName }
Expand Down

0 comments on commit 6fa213d

Please sign in to comment.