Skip to content

Commit

Permalink
Use a few object param destructurings
Browse files Browse the repository at this point in the history
$ lebab --replace src/ --transform destruct-param
src/canvas-change.js:
23:  warning  5 different props found, will not transform more than 4  (destruct-param)

Don't destructure events or elements, or (otherwise) lose important context from the variable name.
  • Loading branch information
1j01 committed Oct 29, 2019
1 parent 72d4a1f commit 469f13c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,10 @@ set_magnification(1);
storage.get({
width: default_canvas_width,
height: default_canvas_height,
}, (err, values) => {
}, (err, {width, height}) => {
if(err){return;}
my_canvas_width = values.width;
my_canvas_height = values.height;
my_canvas_width = width;
my_canvas_height = height;
canvas.width = Math.max(1, my_canvas_width);
canvas.height = Math.max(1, my_canvas_height);
ctx.disable_image_smoothing();
Expand Down
2 changes: 1 addition & 1 deletion src/electron-injected.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ window.systemSaveCanvasAs = (canvas, suggestedFileName, savedCallback) => {
// TODO: Linux/Unix?? you're not supposed to need file extensions
return show_error_message("Missing file extension - try adding .png to the file name");
}
const formatNameMatched = ((filters.find(filter => filter.extensions.includes(extension))) || {}).name;
const formatNameMatched = ((filters.find(({extensions}) => extensions.includes(extension))) || {}).name;
if(!formatNameMatched){
return show_error_message(`Can't save as *.${extension} - try adding .png to the file name`);
}
Expand Down
22 changes: 11 additions & 11 deletions src/tool-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ const $ChooseShapeStyle = () => {
{stroke: true, fill: true},
{stroke: false, fill: true}
],
(a, is_chosen) => {
({stroke, fill}, is_chosen) => {
const sscanvas = make_canvas(39, 21);
const ssctx = sscanvas.ctx;

// border px inwards amount
let b = 5;
ssctx.fillStyle = is_chosen ? "#fff" : "#000";

if(a.stroke){
if(stroke){
// just using a solid rectangle for the stroke
// so as not to have to deal with the pixel grid with strokes
ssctx.fillRect(b, b, sscanvas.width-b*2, sscanvas.height-b*2);
Expand All @@ -117,19 +117,19 @@ const $ChooseShapeStyle = () => {
b += 1;
ssctx.fillStyle = "#777";

if(a.fill){
if(fill){
ssctx.fillRect(b, b, sscanvas.width-b*2, sscanvas.height-b*2);
}else{
ssctx.clearRect(b, b, sscanvas.width-b*2, sscanvas.height-b*2);
}

return sscanvas;
},
a => {
$chooser.stroke = a.stroke;
$chooser.fill = a.fill;
({stroke, fill}) => {
$chooser.stroke = stroke;
$chooser.fill = fill;
},
a => $chooser.stroke === a.stroke && $chooser.fill === a.fill
({stroke, fill}) => $chooser.stroke === stroke && $chooser.fill === fill
).addClass("choose-shape-style");

$chooser.fill = false;
Expand Down Expand Up @@ -168,10 +168,10 @@ const $choose_brush = $Choose(
render_brush(cbcanvas.ctx, shape, size);

return cbcanvas;
}, o => {
brush_shape = o.shape;
brush_size = o.size;
}, o => brush_shape === o.shape && brush_size === o.size
}, ({shape, size}) => {
brush_shape = shape;
brush_size = size;
}, ({shape, size}) => brush_shape === shape && brush_size === size
).addClass("choose-brush");

const $choose_eraser_size = $Choose(
Expand Down

0 comments on commit 469f13c

Please sign in to comment.