Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

replace_import doesn't work if there are no other AST nodes #205

Open
morgante opened this issue Sep 27, 2023 · 1 comment
Open

replace_import doesn't work if there are no other AST nodes #205

morgante opened this issue Sep 27, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@morgante
Copy link
Contributor

morgante commented Sep 27, 2023

If a file is only a single AST node, using replace_import fails.

Sample file:

import { ThemeProvider } from '@mui/styles';

Pattern:

engine marzano(0.1)
language js

`ThemeProvider` as $target where {
    $target <: replace_import($old, new=`"@mui/material/styles"`), 
}

Expected output:

import { ThemeProvider } from "@mui/material/styles";

Actual output:

import { ThemeProvider } from "@mui/material/styles";

import { ThemeProvider } from '@mui/styles';

Adding even a blank after the import is sufficient to restore the expected/correct behavior.

@morgante morgante added the bug Something isn't working label Sep 27, 2023
@morgante
Copy link
Contributor Author

We likely need to use += or similar.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant