quick-lint / quick-lint-js

quick-lint-js finds bugs in JavaScript programs
https://quick-lint-js.com
GNU General Public License v3.0
1.52k stars 192 forks source link

7$: Parse '..' (incomplete '...') intelligently #536

Open strager opened 2 years ago

strager commented 2 years ago

In many situations, we should parse .. as if it was ... (spread operator).

muzoaydo commented 2 years ago

I claim this for-hire task. I expect payment after I complete this task. I will email the quick-lint-js team if I am assigned this task.

strager commented 2 years ago

Here are some cases we can improve. Each example should instead say something like "missing third '.' in '...' for array spread".

let xs = [];

// error: unexpected token [E0054]
function f(..x) { }

// error: missing operand for operator [E0026]
// error: missing property name between '.' and '.' [E0053]
(..x) => {};

// error: missing operand for operator [E0026]
// error: missing property name between '.' and '.' [E0053]
f(..xs);

// error: missing operand for operator [E0026]
// error: missing property name between '.' and '.' [E0053]
[..xs];

// error: unexpected token [E0054]
({ ..xs });

I see three implementation methods:

strager commented 2 years ago

@muzoaydo Are you still working on this task? Do you need any help?