Skip to content
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

Fix config validation message typo #13515

Merged
merged 2 commits into from Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/babel-core/src/config/full.ts
Expand Up @@ -124,7 +124,7 @@ export default gensync<(inputOpts: unknown) => ResolvedConfig | null>(
}
} catch (e) {
if (e.code === "BABEL_UNKNOWN_OPTION") {
checkNoUnwrappedItemOptionPairs(rawPresets, i, "preset", e);
checkNoUnwrappedItemOptionPairs(rawPresets, i, "presets", e);
}
throw e;
}
Expand Down Expand Up @@ -187,7 +187,7 @@ export default gensync<(inputOpts: unknown) => ResolvedConfig | null>(
} catch (e) {
if (e.code === "BABEL_UNKNOWN_PLUGIN_PROPERTY") {
// print special message for `plugins: ["@babel/foo", { foo: "option" }]`
checkNoUnwrappedItemOptionPairs(descs, i, "plugin", e);
checkNoUnwrappedItemOptionPairs(descs, i, "plugins", e);
}
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/src/config/validation/options.ts
Expand Up @@ -440,7 +440,7 @@ function assertOverridesList(
export function checkNoUnwrappedItemOptionPairs(
items: Array<UnloadedDescriptor>,
index: number,
type: "plugin" | "preset",
type: "plugins" | "presets",
e: Error,
): void {
if (index === 0) return;
Expand Down
12 changes: 6 additions & 6 deletions packages/babel-core/test/__snapshots__/option-manager.js.snap
Expand Up @@ -3,32 +3,32 @@
exports[`option-manager config plugin/preset flattening and overriding should throw when an option is following a preset 1`] = `
"[BABEL] unknown: Unknown option: .useSpread. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.
- Maybe you meant to use
\\"preset\\": [
\\"presets\\": [
[\\"./fixtures/option-manager/babel-preset-bar\\", {
\\"useSpread\\": true
}]
]
To be a valid preset, its name and options should be wrapped in a pair of brackets"
To be a valid presets, its name and options should be wrapped in a pair of brackets"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it's better not to have the s here. Maybe you could edit the checkNoUnwrappedItemOptionPairs adding the s for the "Maybe you meant to use" section, rather than changing it in the parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point!
I fixed it as you said.

b8d5987

`;

exports[`option-manager config plugin/preset flattening and overriding should throw when an option is provided as a plugin 1`] = `
"[BABEL] unknown: .useSpread is not a valid Plugin property
- Maybe you meant to use
\\"plugin\\": [
\\"plugins\\": [
[\\"./fixtures/option-manager/babel-plugin-foo\\", {
\\"useSpread\\": true
}]
]
To be a valid plugin, its name and options should be wrapped in a pair of brackets"
To be a valid plugins, its name and options should be wrapped in a pair of brackets"
`;

exports[`option-manager config plugin/preset flattening and overriding should throw when an option is provided as a preset 1`] = `
"[BABEL] unknown: Unknown option: .useBuiltIns. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.
- Maybe you meant to use
\\"preset\\": [
\\"presets\\": [
[\\"./fixtures/option-manager/babel-preset-bar\\", {
\\"useBuiltIns\\": \\"entry\\"
}]
]
To be a valid preset, its name and options should be wrapped in a pair of brackets"
To be a valid presets, its name and options should be wrapped in a pair of brackets"
`;