invalid @apply quick fix: check that base class name can be @applied
parent
8c6ba84417
commit
f7d4a36934
|
@ -22,6 +22,7 @@ import dset from 'dset'
|
||||||
import selectorParser from 'postcss-selector-parser'
|
import selectorParser from 'postcss-selector-parser'
|
||||||
import { flatten } from '../../../util/array'
|
import { flatten } from '../../../util/array'
|
||||||
import { getClassNameMeta } from '../../util/getClassNameMeta'
|
import { getClassNameMeta } from '../../util/getClassNameMeta'
|
||||||
|
import { validateApply } from '../../util/validateApply'
|
||||||
|
|
||||||
export async function provideInvalidApplyCodeActions(
|
export async function provideInvalidApplyCodeActions(
|
||||||
state: State,
|
state: State,
|
||||||
|
@ -173,11 +174,12 @@ function classNameToAst(
|
||||||
selector: string,
|
selector: string,
|
||||||
important: boolean = false
|
important: boolean = false
|
||||||
) {
|
) {
|
||||||
const baseClassName = dlv(
|
const baseClassName = classNameParts[classNameParts.length - 1]
|
||||||
state.classNames.classNames,
|
const validatedBaseClassName = validateApply(state, [baseClassName])
|
||||||
classNameParts[classNameParts.length - 1]
|
if (
|
||||||
)
|
validatedBaseClassName === null ||
|
||||||
if (!baseClassName) {
|
validatedBaseClassName.isApplyable === false
|
||||||
|
) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const meta = getClassNameMeta(state, classNameParts)
|
const meta = getClassNameMeta(state, classNameParts)
|
||||||
|
@ -216,9 +218,7 @@ function classNameToAst(
|
||||||
|
|
||||||
let rule = {
|
let rule = {
|
||||||
[selector]: {
|
[selector]: {
|
||||||
[`@apply ${classNameParts[classNameParts.length - 1]}${
|
[`@apply ${baseClassName}${important ? ' !important' : ''}`]: '',
|
||||||
important ? ' !important' : ''
|
|
||||||
}`]: '',
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if (path.length) {
|
if (path.length) {
|
||||||
|
|
Loading…
Reference in New Issue