Merge pull request #1179 from sveltejs/fix-capitalize-warning

fix capitalize warning
pull/1186/head
Rich Harris 7 years ago committed by GitHub
commit 72a65c48da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -101,7 +101,7 @@ export default function validate(
throw error; throw error;
} }
if (name && !/^[A-Z]/.test(name)) { if (name && /^[a-z]/.test(name)) {
const message = `options.name should be capitalised`; const message = `options.name should be capitalised`;
onwarn({ onwarn({
message, message,

@ -88,4 +88,19 @@ describe("validate", () => {
} }
]); ]);
}); });
it("does not warn if options.name begins with non-alphabetic character", () => {
const warnings = [];
svelte.compile("<div></div>", {
name: "_",
onwarn(warning) {
warnings.push({
message: warning.message,
pos: warning.pos,
loc: warning.loc
});
}
});
assert.deepEqual(warnings, []);
});
}); });

Loading…
Cancel
Save