Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit deb0d7e

Browse files
committed
Tweak error messages
1 parent 151be44 commit deb0d7e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/lib/expandApplyAtRules.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,14 @@ function processApply(root, context) {
158158
const screenType = apply.parent.params
159159

160160
throw apply.error(
161-
`@apply nested inside @screen is not supported. We suggest you write this as @apply ${applyCandidates.map(c => `${screenType}:${c}`).join(' ')} instead.`
161+
`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${applyCandidates
162+
.map((c) => `${screenType}:${c}`)
163+
.join(' ')} instead.`
162164
)
163165
}
164166

165167
throw apply.error(
166-
`@apply only works for elements and classes. Nesting inside an @${apply.parent.name} is not supported. Please move the @${apply.parent.name} around the element/class selector`
168+
`@apply is not supported within nested at-rules like @${apply.parent.name}. You can fix this by un-nesting @${apply.parent.name}.`
167169
)
168170
}
169171

tests/10-apply.test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function run(input, config = {}) {
77
const { currentTestName } = expect.getState()
88

99
return postcss([tailwind(config)]).process(input, {
10-
from: `${path.resolve(__filename)}?test=${currentTestName}`
10+
from: `${path.resolve(__filename)}?test=${currentTestName}`,
1111
})
1212
}
1313

@@ -162,7 +162,7 @@ test('@apply error with unknown utility', async () => {
162162
}
163163
`
164164

165-
await expect(run(css, config)).rejects.toThrowError("class does not exist")
165+
await expect(run(css, config)).rejects.toThrowError('class does not exist')
166166
})
167167

168168
test('@apply error with nested @screen', async () => {
@@ -186,7 +186,9 @@ test('@apply error with nested @screen', async () => {
186186
}
187187
`
188188

189-
await expect(run(css, config)).rejects.toThrowError("@apply nested inside @screen is not supported")
189+
await expect(run(css, config)).rejects.toThrowError(
190+
'@apply is not supported within nested at-rules like @screen'
191+
)
190192
})
191193

192194
test('@apply error with nested @anyatrulehere', async () => {
@@ -210,5 +212,7 @@ test('@apply error with nested @anyatrulehere', async () => {
210212
}
211213
`
212214

213-
await expect(run(css, config)).rejects.toThrowError("Nesting inside an @genie is not supported")
215+
await expect(run(css, config)).rejects.toThrowError(
216+
'@apply is not supported within nested at-rules like @genie'
217+
)
214218
})

0 commit comments

Comments
 (0)