@@ -9,6 +9,7 @@ import parseObjectStyles from '../util/parseObjectStyles'
9
9
import prefixSelector from '../util/prefixSelector'
10
10
import wrapWithVariants from '../util/wrapWithVariants'
11
11
import increaseSpecificity from '../util/increaseSpecificity'
12
+ import selectorParser from 'postcss-selector-parser'
12
13
13
14
function parseStyles ( styles ) {
14
15
if ( ! Array . isArray ( styles ) ) {
@@ -18,6 +19,14 @@ function parseStyles(styles) {
18
19
return _ . flatMap ( styles , style => ( style instanceof Node ? style : parseObjectStyles ( style ) ) )
19
20
}
20
21
22
+ function containsClass ( value ) {
23
+ return selectorParser ( selectors => {
24
+ let classFound = false
25
+ selectors . walkClasses ( ( ) => ( classFound = true ) )
26
+ return classFound
27
+ } ) . transformSync ( value )
28
+ }
29
+
21
30
export default function ( plugins , config ) {
22
31
const pluginBaseStyles = [ ]
23
32
const pluginComponents = [ ]
@@ -86,6 +95,12 @@ export default function(plugins, config) {
86
95
if ( config . important === true ) {
87
96
rule . walkDecls ( decl => ( decl . important = true ) )
88
97
} else if ( typeof config . important === 'string' ) {
98
+ if ( containsClass ( config . important ) ) {
99
+ throw rule . error (
100
+ `Classes are not allowed when using the \`important\` option with a string argument. Please use an ID instead.`
101
+ )
102
+ }
103
+
89
104
rule . selectors = rule . selectors . map ( selector => {
90
105
return increaseSpecificity ( config . important , selector )
91
106
} )
0 commit comments