1
-
2
- // @ts -expect-error
3
1
import { lexer , parse , walk , property as propertyName } from 'css-tree'
4
2
import { type SyntaxError } from './types/syntax-error'
5
3
@@ -34,7 +32,7 @@ export default function validateCSS(text: string, parseOptions = {
34
32
}
35
33
36
34
37
- function isTargetError ( error : SyntaxError ) {
35
+ function isTargetError ( error : SyntaxError | null ) {
38
36
if ( ! error ) {
39
37
return null
40
38
}
@@ -53,7 +51,7 @@ export function validateAtrule(node: { name: any; prelude: any; block: { childre
53
51
const errors = [ ]
54
52
let error
55
53
56
- if ( error = isTargetError ( lexer . checkAtruleName ( atrule ) ) ) {
54
+ if ( error = isTargetError ( ( lexer as any ) . checkAtruleName ( atrule ) ) ) {
57
55
errors . push ( Object . assign ( error , {
58
56
atrule
59
57
} ) )
@@ -85,7 +83,7 @@ export function validateAtrulePrelude(atrule: string, prelude: any) {
85
83
const errors = [ ]
86
84
let error : SyntaxError | null
87
85
88
- if ( error = isTargetError ( lexer . checkAtrulePrelude ( atrule , prelude ) ) ) {
86
+ if ( error = isTargetError ( ( lexer as any ) . checkAtrulePrelude ( atrule , prelude ) ) ) {
89
87
errors . push ( Object . assign ( error , {
90
88
atrule
91
89
} ) )
@@ -104,7 +102,7 @@ export function validateAtruleDescriptor(atrule: any, descriptor: string, value:
104
102
const errors = [ ]
105
103
let error
106
104
107
- if ( error = isTargetError ( lexer . checkAtruleDescriptorName ( atrule , descriptor ) ) ) {
105
+ if ( error = isTargetError ( ( lexer as any ) . checkAtruleDescriptorName ( atrule , descriptor ) ) ) {
108
106
errors . push ( Object . assign ( error , {
109
107
atrule,
110
108
descriptor
@@ -131,7 +129,7 @@ export function validateDeclaration(property: string, value: any) {
131
129
return errors
132
130
}
133
131
134
- if ( error = isTargetError ( lexer . checkPropertyName ( property ) ) ) {
132
+ if ( error = isTargetError ( ( lexer as any ) . checkPropertyName ( property ) ) ) {
135
133
errors . push ( Object . assign ( error , {
136
134
property
137
135
} ) )
0 commit comments