Skip to content

Commit

Permalink
Unused variables are now an ESLint error (#1305)
Browse files Browse the repository at this point in the history
If it's not used then why is it there?
  • Loading branch information
GarboMuffin authored Feb 18, 2024
1 parent 5212671 commit e252617
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 110 deletions.
14 changes: 13 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@ module.exports = {
scaffolding: 'readonly'
},
rules: {
'no-unused-vars': 'off',
// Unused variables commonly indicate logic errors
'no-unused-vars': [
'error',
{
// Unused arguments are useful, eg. it can be nice for blocks to accept `args` even if they don't use it
args: 'none',
// Allow silently eating try { } catch { }
caughtErrors: 'none',
// Variables starting with _ are intentionally unused
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
}
],
// Allow while (true) { }
'no-constant-condition': [
'error',
Expand Down
2 changes: 1 addition & 1 deletion extensions/0832/rxFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

var rxFSfi = new Array();
var rxFSsy = new Array();
var Search, i, str, str2;
var Search, str, str2;

const file =
"data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIzMC4zMTIxMiIgaGVpZ2h0PSIyNC4yNDk2NyIgdmlld0JveD0iMCwwLDMwLjMxMjEyLDI0LjI0OTY3Ij48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMzA0Ljg0Mzk0LC0xNjcuODc1MTYpIj48ZyBkYXRhLXBhcGVyLWRhdGE9InsmcXVvdDtpc1BhaW50aW5nTGF5ZXImcXVvdDs6dHJ1ZX0iIGZpbGw9IiNmZmI5MDAiIGZpbGwtcnVsZT0ibm9uemVybyIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIHN0cm9rZS1saW5lY2FwPSJidXR0IiBzdHJva2UtbGluZWpvaW49Im1pdGVyIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS1kYXNoYXJyYXk9IiIgc3Ryb2tlLWRhc2hvZmZzZXQ9IjAiIHN0eWxlPSJtaXgtYmxlbmQtbW9kZTogbm9ybWFsIj48cGF0aCBkPSJNMzE5Ljk5OTk5LDE3MC45MDYzN2gxMi4xMjQ4M2MxLjY3NDEyLDAgMy4wMzEyNCwxLjM1NzEyIDMuMDMxMjQsMy4wMzEydjE1LjE1NjA3YzAsMS42NzQwOCAtMS4zNTcxMiwzLjAzMTIgLTMuMDMxMjQsMy4wMzEyaC0yNC4yNDk2NmMtMS42NzQxMiwwIC0zLjAzMTIyLC0xLjM1NzEyIC0zLjAzMTIyLC0zLjAzMTJ2LTE4LjE4NzI3YzAsLTEuNjgyMzIgMS4zNDg5LC0zLjAzMTIgMy4wMzEyMiwtMy4wMzEyaDkuMDkzNjN6Ii8+PC9nPjwvZz48L3N2Zz48IS0tcm90YXRpb25DZW50ZXI6MTUuMTU2MDYwMDAwMDAwMDI1OjEyLjEyNDgzNTAwMDAwMDAxOS0tPg==";
Expand Down
2 changes: 1 addition & 1 deletion extensions/0832/rxFS2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

var rxFSfi = new Array();
var rxFSsy = new Array();
var Search, i, str, str2;
var Search, str, str2;

const folder =
"data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIyOC40NjI1IiBoZWlnaHQ9IjI3LjciIHZpZXdCb3g9IjAsMCwyOC40NjI1LDI3LjciPjxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMjYuMDE5NTMsLTE2NC4xMTg3NSkiPjxnIGRhdGEtcGFwZXItZ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xMjQ5MjM3MDYwNTMtLT4=";
Expand Down
2 changes: 0 additions & 2 deletions extensions/Lily/TempVariables2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
(function (Scratch) {
"use strict";

const menuIconURI = "";

// Object.create(null) prevents "variable [toString]" from returning a function
let runtimeVariables = Object.create(null);

Expand Down
16 changes: 1 addition & 15 deletions extensions/NOname-awa/cn-number.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
(function (Scratch) {
"use strict";

let Number2,
null2,
units,
Number_in,
uppercase,
i,
N_Z,
o,
j,
After_decimal_point,
unit,
k,
C_Number,
m,
n;
let i, N_Z, o, j, After_decimal_point, unit, k, C_Number, m, n;

class CNNUMBER {
getInfo() {
Expand Down
16 changes: 0 additions & 16 deletions extensions/NOname-awa/math-and-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -1156,22 +1156,6 @@
return text.replace(new RegExp(oldStr, "g"), newStr);
};

const sortAndUniqueWords_en = (text) => {
let words = text.toLowerCase().match(/\b\w+\b/g);
words = Array.from(new Set(words));
words.sort();
return words.join(" ");
};

const sortAndUniqueWords_cn = (text) => {
let words = text.match(/[^\u4e00-\u9fa5]+|[\u4e00-\u9fa5]+/g);
words = Array.from(new Set(words));
words.sort(function (a, b) {
return a.localeCompare(b, "zh-Hans-CN", { sensitivity: "accent" });
});
return words.join(" ");
};

const countKeyword = (sentence, keyword) => {
const count = (sentence.match(new RegExp(keyword, "gi")) || []).length;
return count;
Expand Down
1 change: 1 addition & 0 deletions extensions/TheShovel/profanity.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(function (Scratch) {
"use strict";

// eslint-disable-next-line no-unused-vars
const encode = (str) =>
btoa(str)
.split("")
Expand Down
4 changes: 0 additions & 4 deletions extensions/ar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
let xrSession = null;
let xrState = false;
let xrRefSpace;
let xrViewSpace;
let xrProjectionMatrix;
let xrTransform;
let xrCombinedMatrix;
Expand Down Expand Up @@ -82,7 +81,6 @@
const onSuccess = function (session) {
xrSession = session;
xrRefSpace = null;
xrViewSpace = null;
xrHitTestSource = null;
hitPosition = null;
hitPositionAvailable = false;
Expand All @@ -103,7 +101,6 @@
session
.requestReferenceSpace("viewer")
.then((viewSpace) => {
xrViewSpace = viewSpace;
return session.requestHitTestSource({ space: viewSpace });
})
.then((hts) => {
Expand Down Expand Up @@ -500,7 +497,6 @@
}
stageWrapperParent = stageWrapper.parentElement;

const noop = () => {};
navigator.xr
.requestSession("immersive-ar", {
requiredFeatures: ["hit-test", "dom-overlay"],
Expand Down
1 change: 1 addition & 0 deletions extensions/docs-examples/unsandboxed/every-second.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
}
// highlight-start
setInterval(() => {
// eslint-disable-next-line no-unused-vars
const startedThreads = Scratch.vm.runtime.startHats('everysecondexample_everySecond');
}, 1000);
// highlight-end
Expand Down
2 changes: 2 additions & 0 deletions extensions/gamejolt.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
function hex_md5(a) {
return rstr2hex(rstr_md5(str2rstr_utf8(a)));
}
// eslint-disable-next-line no-unused-vars
function hex_hmac_md5(a, b) {
return rstr2hex(rstr_hmac_md5(str2rstr_utf8(a), str2rstr_utf8(b)));
}
// eslint-disable-next-line no-unused-vars
function md5_vm_test() {
return hex_md5("abc").toLowerCase() == "900150983cd24fb0d6963f7d28e17f72";
}
Expand Down
2 changes: 0 additions & 2 deletions extensions/obviousAlexC/SensingPlus.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@

const touchPointsArray = makeArrayOfTouches(); //* <-- Do this for devices that really can't support that many touches.

const alreadyTapped = {};

class SensingPlus {
getInfo() {
return {
Expand Down
Loading

0 comments on commit e252617

Please sign in to comment.