polish: recommend preset for js extensions (#11421)

This commit is contained in:
Huáng Jùnliàng 2020-04-16 15:13:57 -04:00 committed by GitHub
parent d9eb94327a
commit 1c0970131e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,8 +83,8 @@ const pluginNameMap = {
url: "https://git.io/vb4yb",
},
transform: {
name: "@babel/plugin-transform-flow-strip-types",
url: "https://git.io/vb49g",
name: "@babel/preset-flow",
url: "https://git.io/JfeDn",
},
},
functionBind: {
@ -119,8 +119,8 @@ const pluginNameMap = {
url: "https://git.io/vb4yA",
},
transform: {
name: "@babel/plugin-transform-react-jsx",
url: "https://git.io/vb4yd",
name: "@babel/preset-react",
url: "https://git.io/JfeDR",
},
},
logicalAssignment: {
@ -185,8 +185,8 @@ const pluginNameMap = {
url: "https://git.io/vb4SC",
},
transform: {
name: "@babel/plugin-transform-typescript",
url: "https://git.io/vb4Sm",
name: "@babel/preset-typescript",
url: "https://git.io/JfeDz",
},
},
@ -260,13 +260,15 @@ export default function generateMissingPluginMessage(
if (pluginInfo) {
const { syntax: syntaxPlugin, transform: transformPlugin } = pluginInfo;
if (syntaxPlugin) {
const syntaxPluginInfo = getNameURLCombination(syntaxPlugin);
if (transformPlugin) {
const transformPluginInfo = getNameURLCombination(transformPlugin);
helpMessage +=
`\n\nAdd ${transformPluginInfo} to the 'plugins' section of your Babel config ` +
`to enable transformation.`;
const sectionType = transformPlugin.name.startsWith("@babel/plugin")
? "plugins"
: "presets";
helpMessage += `\n\nAdd ${transformPluginInfo} to the '${sectionType}' section of your Babel config to enable transformation.
If you want to leave it as-is, add ${syntaxPluginInfo} to the 'plugins' section to enable parsing.`;
} else {
const syntaxPluginInfo = getNameURLCombination(syntaxPlugin);
helpMessage +=
`\n\nAdd ${syntaxPluginInfo} to the 'plugins' section of your Babel config ` +
`to enable parsing.`;