Enabling es6 version
Closed this issue · 3 comments
FrancoisSchnell commented
Would like that :) "live p5" extension works but is not as good for me as p5canvas when making changes without saving file.
pixelkind commented
@metadirective One workaround is to enter
/* jslint esversion: 6 */
at the beginning of the file. But it works not with classes. But that's a problem, that probably can't be solved.
osteele commented
In version 1.2.0 of this extension, at least, jslint
(and also jshint
) do indeed enable ES6 classes. For example, the following sketch draws the expected rectangle.
/* jslint esversion: 6 */
class Rectangle {
constructor(x, y, width, height) {
this.x = x;
this.y = y;
this.height = height;
this.width = width;
}
draw() {
rect(this.x, this.y, this.width, this.height);
}
}
const r = new Rectangle(10, 20, 50, 100);
function setup() {
noLoop();
}
function draw() {
background(255);
fill(0);
r.draw();
}