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

feat: improve error message for malformed each #3185

Merged
merged 3 commits into from
May 1, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: prettier
  • Loading branch information
ForbesLindesay committed May 1, 2020
commit c1a92b99be2ddfc4ada2377546d89555b3d009eb
11 changes: 10 additions & 1 deletion packages/pug-lexer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,16 @@ Lexer.prototype = {
}
const name = /^each\b/.exec(this.input) ? 'each' : 'for';
if (this.scan(/^(?:each|for)\b/)) {
this.error('MALFORMED_EACH', 'This `' + name + '` has a syntax error. `' + name + '` statements should be of the form: `' + name + ' VARIABLE_NAME of JS_EXPRESSION`');
this.error(
'MALFORMED_EACH',
'This `' +
name +
'` has a syntax error. `' +
name +
'` statements should be of the form: `' +
name +
' VARIABLE_NAME of JS_EXPRESSION`'
);
}
if (
(captures = /^- *(?:each|for) +([a-zA-Z_$][\w$]*)(?: *, *([a-zA-Z_$][\w$]*))? +in +([^\n]+)/.exec(
Expand Down