update substitution placeholder message in @babel/template (#7255)
This commit is contained in:
parent
3316a554bf
commit
2185256589
@ -15,7 +15,14 @@ export default function populatePlaceholders(
|
||||
if (
|
||||
!Object.prototype.hasOwnProperty.call(replacements, placeholder.name)
|
||||
) {
|
||||
throw new Error(`No substitution given for "${placeholder.name}"`);
|
||||
const placeholderName = placeholder.name;
|
||||
|
||||
throw new Error(
|
||||
`Error: No substitution given for "${placeholderName}". If this is not meant to be a
|
||||
placeholder you may want to consider passing one of the following options to babel-template:
|
||||
- { placeholderPattern: false, placeholderWhitelist: new Set(['${placeholderName}'])}
|
||||
- { placeholderPattern: /^${placeholderName}$/ }`,
|
||||
);
|
||||
}
|
||||
});
|
||||
Object.keys(replacements).forEach(key => {
|
||||
|
||||
@ -133,7 +133,13 @@ describe("babel-template", function() {
|
||||
ID;
|
||||
ANOTHER_ID;
|
||||
`)({ ID: t.identifier("someIdent") });
|
||||
}).to.throw(Error, 'No substitution given for "ANOTHER_ID"');
|
||||
}).to.throw(
|
||||
Error,
|
||||
`Error: No substitution given for "ANOTHER_ID". If this is not meant to be a
|
||||
placeholder you may want to consider passing one of the following options to babel-template:
|
||||
- { placeholderPattern: false, placeholderWhitelist: new Set(['ANOTHER_ID'])}
|
||||
- { placeholderPattern: /^ANOTHER_ID$/ }`,
|
||||
);
|
||||
});
|
||||
|
||||
it("should return the AST directly when using .ast", () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user