1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Enable the ESLint no-shadow rule

This rule is *not* currently enabled in mozilla-central, but it appears commented out[1] in the ESLint definition file; see https://searchfox.org/mozilla-central/rev/c80fa7258c935223fe319c5345b58eae85d4c6ae/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js#238-239

Unfortunately this rule is, for fairly obvious reasons, impossible to `--fix` automatically (even partially) and each case thus required careful manual analysis.
Hence this ESLint rule is, by some margin, probably the most difficult one that we've enabled thus far. However, using this rule does seem like a good idea in general since allowing variable shadowing could lead to subtle (and difficult to find) bugs or at the very least confusing code.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-shadow

---
[1] Most likely, a very large number of lint errors have prevented this rule from being enabled thus far.
This commit is contained in:
Jonas Jenwald 2020-03-25 09:42:50 +01:00
parent 475fa1f97f
commit 1d2f787d6a
12 changed files with 95 additions and 87 deletions

View file

@ -23,6 +23,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["Courier-Bold"] = 600;
t["Courier-BoldOblique"] = 600;
t["Courier-Oblique"] = 600;
// eslint-disable-next-line no-shadow
t["Helvetica"] = getLookupTableFactory(function(t) {
t["space"] = 278;
t["exclam"] = 278;
@ -340,6 +341,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["imacron"] = 278;
t["Euro"] = 556;
});
// eslint-disable-next-line no-shadow
t["Helvetica-Bold"] = getLookupTableFactory(function(t) {
t["space"] = 278;
t["exclam"] = 333;
@ -657,6 +659,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["imacron"] = 278;
t["Euro"] = 556;
});
// eslint-disable-next-line no-shadow
t["Helvetica-BoldOblique"] = getLookupTableFactory(function(t) {
t["space"] = 278;
t["exclam"] = 333;
@ -974,6 +977,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["imacron"] = 278;
t["Euro"] = 556;
});
// eslint-disable-next-line no-shadow
t["Helvetica-Oblique"] = getLookupTableFactory(function(t) {
t["space"] = 278;
t["exclam"] = 278;
@ -1291,6 +1295,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["imacron"] = 278;
t["Euro"] = 556;
});
// eslint-disable-next-line no-shadow
t["Symbol"] = getLookupTableFactory(function(t) {
t["space"] = 250;
t["exclam"] = 333;
@ -1483,6 +1488,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["bracerightbt"] = 494;
t["apple"] = 790;
});
// eslint-disable-next-line no-shadow
t["Times-Roman"] = getLookupTableFactory(function(t) {
t["space"] = 250;
t["exclam"] = 333;
@ -1800,6 +1806,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["imacron"] = 278;
t["Euro"] = 500;
});
// eslint-disable-next-line no-shadow
t["Times-Bold"] = getLookupTableFactory(function(t) {
t["space"] = 250;
t["exclam"] = 333;
@ -2117,6 +2124,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["imacron"] = 278;
t["Euro"] = 500;
});
// eslint-disable-next-line no-shadow
t["Times-BoldItalic"] = getLookupTableFactory(function(t) {
t["space"] = 250;
t["exclam"] = 389;
@ -2434,6 +2442,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["imacron"] = 278;
t["Euro"] = 500;
});
// eslint-disable-next-line no-shadow
t["Times-Italic"] = getLookupTableFactory(function(t) {
t["space"] = 250;
t["exclam"] = 333;
@ -2751,6 +2760,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["imacron"] = 278;
t["Euro"] = 500;
});
// eslint-disable-next-line no-shadow
t["ZapfDingbats"] = getLookupTableFactory(function(t) {
t["space"] = 278;
t["a1"] = 974;