|
|
|
@ -33,13 +33,15 @@ describe('validate', () => {
|
|
|
|
...options
|
|
|
|
...options
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
assert.deepEqual(warnings.map(w => ({
|
|
|
|
assert.deepEqual(
|
|
|
|
|
|
|
|
warnings.map((w) => ({
|
|
|
|
code: w.code,
|
|
|
|
code: w.code,
|
|
|
|
message: w.message,
|
|
|
|
message: w.message,
|
|
|
|
pos: w.pos,
|
|
|
|
start: { line: w.start.line, column: w.start.column },
|
|
|
|
start: w.start,
|
|
|
|
end: { line: w.end.line, column: w.end.column },
|
|
|
|
end: w.end
|
|
|
|
})),
|
|
|
|
})), expected_warnings);
|
|
|
|
expected_warnings
|
|
|
|
|
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
error = e;
|
|
|
|
error = e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -56,13 +58,17 @@ describe('validate', () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
assert.equal(error.code, expected.code);
|
|
|
|
assert.deepEqual(
|
|
|
|
assert.equal(error.message, expected.message);
|
|
|
|
{
|
|
|
|
assert.deepEqual(error.start, expected.start);
|
|
|
|
code: error.code,
|
|
|
|
assert.deepEqual(error.end, expected.end);
|
|
|
|
message: error.message,
|
|
|
|
assert.equal(error.pos, expected.pos);
|
|
|
|
start: { line: error.start.line, column: error.start.column },
|
|
|
|
|
|
|
|
end: { line: error.end.line, column: error.end.column },
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
expected
|
|
|
|
|
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
console.error(error); // eslint-disable-line no-console
|
|
|
|
console.error(error);
|
|
|
|
throw e;
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -78,6 +84,51 @@ describe('validate', () => {
|
|
|
|
}, /options\.name must be a valid identifier/);
|
|
|
|
}, /options\.name must be a valid identifier/);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it("check warning position", () => {
|
|
|
|
|
|
|
|
const { warnings } = svelte.compile('\n <img \n src="foo.jpg">\n', {
|
|
|
|
|
|
|
|
generate: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
|
|
|
|
warnings.map((w) => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
code: w.code,
|
|
|
|
|
|
|
|
frame: w.frame,
|
|
|
|
|
|
|
|
message: w.message,
|
|
|
|
|
|
|
|
start: {
|
|
|
|
|
|
|
|
character: w.start.character,
|
|
|
|
|
|
|
|
column: w.start.column,
|
|
|
|
|
|
|
|
line: w.start.line,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
end: {
|
|
|
|
|
|
|
|
character: w.end.character,
|
|
|
|
|
|
|
|
column: w.end.column,
|
|
|
|
|
|
|
|
line: w.end.line,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
pos: w.pos,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
code: "a11y-missing-attribute",
|
|
|
|
|
|
|
|
frame: '1: \n2: <img \n ^\n3: src="foo.jpg">\n4: ',
|
|
|
|
|
|
|
|
message: "A11y: <img> element should have an alt attribute",
|
|
|
|
|
|
|
|
start: {
|
|
|
|
|
|
|
|
character: 3,
|
|
|
|
|
|
|
|
column: 2,
|
|
|
|
|
|
|
|
line: 2,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
end: {
|
|
|
|
|
|
|
|
character: 24,
|
|
|
|
|
|
|
|
column: 15,
|
|
|
|
|
|
|
|
line: 3,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
pos: 3,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('warns if options.name is not capitalised', () => {
|
|
|
|
it('warns if options.name is not capitalised', () => {
|
|
|
|
const { warnings } = svelte.compile('<div></div>', {
|
|
|
|
const { warnings } = svelte.compile('<div></div>', {
|
|
|
|
name: 'lowercase',
|
|
|
|
name: 'lowercase',
|
|
|
|
|