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

Fix many small lints #996

Merged
merged 28 commits into from
May 26, 2020
Merged

Fix many small lints #996

merged 28 commits into from
May 26, 2020

Conversation

bomanimc
Copy link
Member

This PR fixes a bunch of smaller/less-involved lint errors, as well as adds a few more lint errors to ignore in the eslintrc.js file. There are also lots of autoformatted Prettier changes for the files that I manually touched.

After merging the remaining PRs on lint, I think we'll be low enough on lint errors to start handling them on a more case-by-case basis in the files we touch.

@bomanimc bomanimc changed the title Bomani.fix many small lints Fix many small lints May 24, 2020
@bomanimc bomanimc requested a review from joeyklee May 24, 2020 18:13
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

eslint

examples/javascript/ImageClassification/ImageClassification_Video_Load/sketch.js|36 col 38| 'classifier' is already declared in the upper scope. no-shadow
examples/javascript/ImageClassification/ImageClassification_Video/sketch.js|23 col 5| 'result' is not defined. no-undef
examples/javascript/ImageClassification/ImageClassification_Video/sketch.js|24 col 5| 'probability' is not defined. no-undef
examples/javascript/Pix2Pix/Pix2Pix_promise/sketch.js|16 col 1| Split 'let' declarations into multiple statements. one-var
examples/javascript/Pix2Pix/Pix2Pix_promise/sketch.js|16 col 51| 'pix2pix' is defined but never used. Allowed unused vars must match /^setup$|^draw$|^preload$/. no-unused-vars
examples/javascript/Pix2Pix/Pix2Pix_promise/sketch.js|98 col 43| Unexpected unnamed function. func-names
examples/javascript/PoseNet/PoseNet_part_selection/sketch.js|58 col 11| Use object destructuring. prefer-destructuring
examples/javascript/PoseNet/PoseNet_part_selection/sketch.js|66 col 11| Use object destructuring. prefer-destructuring
examples/javascript/PoseNet/PoseNet_part_selection/sketch.js|74 col 11| Use object destructuring. prefer-destructuring
examples/javascript/UNET/UNET_webcam/sketch.js|69 col 9| 'canvas' is already declared in the upper scope. no-shadow
examples/javascript/UNET/UNET_webcam/sketch.js|70 col 9| 'ctx' is already declared in the upper scope. no-shadow
examples/p5js/FaceApi/FaceApi_Image_Landmarks/sketch.js|47 col 18| 'detections' is already declared in the upper scope. no-shadow
examples/p5js/FaceApi/FaceApi_Image_Landmarks/sketch.js|56 col 24| 'detections' is already declared in the upper scope. no-shadow
examples/p5js/FaceApi/FaceApi_Video_Landmarks_LocalModels/sketch.js|53 col 18| 'detections' is already declared in the upper scope. no-shadow
examples/p5js/FaceApi/FaceApi_Video_Landmarks_LocalModels/sketch.js|68 col 24| 'detections' is already declared in the upper scope. no-shadow
examples/p5js/FaceApi/FaceApi_Video_Landmarks_LocalModels/sketch.js|74 col 11| Use object destructuring. prefer-destructuring
examples/p5js/ImageClassification/ImageClassification_MultipleImages/sketch.js|34 col 38| 'imgPath' is not defined. no-undef
examples/p5js/NeuralNetwork/NeuralNetwork_basics/sketch.js|27 col 25| Unexpected unnamed function. func-names
examples/p5js/NeuralNetwork/NeuralNetwork_basics/sketch.js|34 col 27| Unexpected unnamed function. func-names
examples/p5js/NeuralNetwork/NeuralNetwork_basics/sketch.js|41 col 24| Unexpected unnamed function. func-names
examples/p5js/NeuralNetwork/NeuralNetwork_basics/sketch.js|48 col 29| Unexpected unnamed function. func-names
examples/p5js/NeuralNetwork/NeuralNetwork_basics/sketch.js|49 col 33| Unexpected unnamed function. func-names
examples/p5js/NeuralNetwork/NeuralNetwork_basics/sketch.js|56 col 19| Unexpected unnamed function. func-names
examples/p5js/NeuralNetwork/NeuralNetwork_basics/sketch.js|57 col 32| Unexpected unnamed function. func-names
examples/p5js/NeuralNetwork/NeuralNetwork_Interactive_Regression/sketch.js|87 col 9| 'y' is not defined. no-undef
examples/p5js/NeuralNetwork/NeuroEvolution_FlappyBird/ga.js|40 col 10| 'savedBirds' is not defined. no-undef
examples/p5js/PoseNet/PoseNet_part_selection/sketch.js|49 col 11| Use object destructuring. prefer-destructuring
examples/p5js/PoseNet/PoseNet_part_selection/sketch.js|54 col 11| Use object destructuring. prefer-destructuring
examples/p5js/PoseNet/PoseNet_part_selection/sketch.js|59 col 11| Use object destructuring. prefer-destructuring
scripts/batch-update-p5webeditor.js|222 col 63| 'idx' is defined but never used. no-unused-vars
src/KMeans/index_test.js|6 col 20| 'ml5' is not defined. no-undef

}

// call app.map.init() once the DOM is loaded
window.addEventListener('DOMContentLoaded', function() {
window.addEventListener("DOMContentLoaded", function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
Unexpected unnamed function. func-names

img = new ImageData(result.raw, 64, 64)
const canvasElement = document.createElement("canvas");
canvasElement.width = 64;
img = new ImageData(result.raw, 64, 64);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'img' is not defined. no-undef

canvasElement.height = 64;
canvasElement_ctx = canvasElement.getContext('2d');
canvasElement_ctx.putImageData(img, 0, 0);
canvasElementCtx = canvasElement.getContext("2d");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'canvasElementCtx' is not defined. no-undef

canvasElement_ctx = canvasElement.getContext('2d');
canvasElement_ctx.putImageData(img, 0, 0);
canvasElementCtx = canvasElement.getContext("2d");
canvasElementCtx.putImageData(img, 0, 0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'canvasElementCtx' is not defined. no-undef

canvasElement_ctx = canvasElement.getContext('2d');
canvasElement_ctx.putImageData(img, 0, 0);
canvasElementCtx = canvasElement.getContext("2d");
canvasElementCtx.putImageData(img, 0, 0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'img' is not defined. no-undef

canvas = document.querySelector('#myCanvas');
ctx = canvas.getContext('2d');
canvas = document.querySelector("#myCanvas");
ctx = canvas.getContext("2d");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'ctx' is not defined. no-undef

function appendImages(arr) {
const output = [];
for (i = 0; i < arr.length; i += 1) {
imgPath = arr[i];
output.push('images/dataset/' + imgPath);
output.push(`images/dataset/${imgPath}`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'imgPath' is not defined. no-undef

@@ -56,49 +50,44 @@ async function loadImage(imgPath, idx) {
const imgEl = new Image();
imgEl.src = imgPath;

imgEl.onload = async function () {
imgEl.onload = async function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
Unexpected unnamed async function. func-names

};
download(JSON.stringify(predictionsJSON), 'json.txt', 'text/plain');
} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'predictionsJSON' is not defined. no-undef

video.play();
});

const loop = classifier => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'classifier' is already declared in the upper scope. no-shadow

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

eslint

scripts/batch-update-p5webeditor.js|222 col 63| 'idx' is defined but never used. no-unused-vars

};
download(JSON.stringify(predictionsJSON), 'json.txt', 'text/plain');
} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'predictionsJSON' is not defined. no-undef

loop(classifier) // Call again to create a loop
}
})
} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'classifier' is already declared in the upper scope. no-shadow


const loop = classifier => {
classifier.classify().then(results => {
result.innerText = results[0].label;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'result' is not defined. no-undef

const loop = classifier => {
classifier.classify().then(results => {
result.innerText = results[0].label;
probability.innerText = results[0].confidence.toFixed(4);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'probability' is not defined. no-undef

@@ -13,7 +13,7 @@ For more models see: https://github.com/ml5js/ml5-data-and-training/tree/master/
// The pre-trained Edges2Pikachu model is trained on 256x256 images
// So the input images can only be 256x256 or 512x512, or multiple of 256
const SIZE = 256;
let inputImg, canvas, outputContainer, statusMsg, pix2pix, clearBtn, transferBtn, modelReady = false, isTransfering = false;
let inputImg, canvas, outputContainer, statusMsg, pix2pix, clearBtn, transferBtn;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
Split 'let' declarations into multiple statements. one-var

@@ -83,7 +84,7 @@ function doneTraining() {
console.log(results);
for (let i = 0; i < results.length; i += 1) {
x = xMany[i][0];
y = results[i][0]["value"];
y = results[i][0].value;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'y' is not defined. no-undef

@@ -37,7 +37,7 @@ function pickOne() {
let index = 0;
let r = random(1);
while (r > 0) {
r = r - savedBirds[index].fitness;
r -= savedBirds[index].fitness;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
'savedBirds' is not defined. no-undef

@@ -46,17 +46,17 @@ function draw() {

// Create a pink ellipse for the nose
fill(213, 0, 143);
const nose = pose['nose'];
const nose = pose.nose;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
Use object destructuring. prefer-destructuring

ellipse(nose.x, nose.y, 20, 20);

// Create a yellow ellipse for the right eye
fill(255, 215, 0);
const rightEye = pose['rightEye'];
const rightEye = pose.rightEye;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
Use object destructuring. prefer-destructuring

ellipse(rightEye.x, rightEye.y, 20, 20);

// Create a yellow ellipse for the right eye
fill(255, 215, 0);
const leftEye = pose['leftEye'];
const leftEye = pose.leftEye;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[eslint] reported by reviewdog 🐶
Use object destructuring. prefer-destructuring

@joeyklee joeyklee merged commit 7bd61e0 into development May 26, 2020
@joeyklee joeyklee deleted the bomani.fix-many-small-lints branch May 26, 2020 14:11
@joeyklee
Copy link
Contributor

Merged! Thank you!

NOTE: the object detector tests seem to be failing basically every PR. I'll try to figure this out this week. Sorry about this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants