New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prettier throws SyntaxError: Unexpected token
in valid MDX function
#13077
Comments
SyntaxError: Unexpected token
in valid MDX functionSyntaxError: Unexpected token
in valid MDX function
👋 @B2o5T! I see Prettier 2.7.1 --parser babel Input: export const getStaticProps = async () => {
const pluginsData = await getPackagesData({ packageList: PACKAGES });
const data = await Promise.all(
pluginsData.map(async plugin => {
const [description, content] = await buildMultipleMDX();
return {
...plugin,
description,
content,
};
})
);
return {
props: {
ssg: { data },
},
revalidate: 60 * 60,
};
}; Output: export const getStaticProps = async () => {
const pluginsData = await getPackagesData({ packageList: PACKAGES });
const data = await Promise.all(
pluginsData.map(async (plugin) => {
const [description, content] = await buildMultipleMDX();
return {
...plugin,
description,
content,
};
})
);
return {
props: {
ssg: { data },
},
revalidate: 60 * 60,
};
}; |
@kachkaev yes I use this code in
|
My brain’s pattern matching failed me because the example only had Prettier does not support MDX2 yet – see umbrella issue: #12209. In the meantime, for the code to parse, it is necessary to remove newlines from your JS blocks. I know it’s annoying because the workaround is not intuitive, but at least it works: Prettier 2.7.1 --parser mdx Input: export const getStaticProps = async () => {
const pluginsData = await getPackagesData({ packageList: PACKAGES });
const data = await Promise.all(
pluginsData.map(async plugin => {
const [description, content] = await buildMultipleMDX();
return {
...plugin,
description,
content,
};
})
);
return {
props: {
ssg: { data },
},
revalidate: 60 * 60,
};
}; Output: export const getStaticProps = async () => {
const pluginsData = await getPackagesData({ packageList: PACKAGES });
const data = await Promise.all(
pluginsData.map(async (plugin) => {
const [description, content] = await buildMultipleMDX();
return {
...plugin,
description,
content,
};
})
);
return {
props: {
ssg: { data },
},
revalidate: 60 * 60,
};
};
|
Closing as duplicate of #5795 |
Prettier 2.7.1
Playground link
Input:
Output:
Expected behavior:
The text was updated successfully, but these errors were encountered: