Skip to content

Commit 72a65c4

Browse files
authored
Merge pull request #1179 from sveltejs/fix-capitalize-warning
fix capitalize warning
2 parents cde5fa1 + fdd9ada commit 72a65c4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/validate/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default function validate(
101101
throw error;
102102
}
103103

104-
if (name && !/^[A-Z]/.test(name)) {
104+
if (name && /^[a-z]/.test(name)) {
105105
const message = `options.name should be capitalised`;
106106
onwarn({
107107
message,

test/validator/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,19 @@ describe("validate", () => {
8888
}
8989
]);
9090
});
91+
92+
it("does not warn if options.name begins with non-alphabetic character", () => {
93+
const warnings = [];
94+
svelte.compile("<div></div>", {
95+
name: "_",
96+
onwarn(warning) {
97+
warnings.push({
98+
message: warning.message,
99+
pos: warning.pos,
100+
loc: warning.loc
101+
});
102+
}
103+
});
104+
assert.deepEqual(warnings, []);
105+
});
91106
});

0 commit comments

Comments
 (0)