Refactor(files-util): Optimize the regular expression to match "import react"
This commit is contained in:
@@ -106,7 +106,7 @@ export const cssToJs = (file: IFile) => {
|
||||
}
|
||||
|
||||
export const addReactImport = (code: string) => {
|
||||
if (!/import\s+React/g.test(code)) {
|
||||
if (!/^\s*import\s+React\s+/g.test(code)) {
|
||||
return `import React from 'react';\n${code}`
|
||||
}
|
||||
return code
|
||||
|
||||
Reference in New Issue
Block a user