From 5b5061afa8509ded83e0fad8197abf917db1a55e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 13 Mar 2021 15:51:44 +0100 Subject: [PATCH] Enable the ESLint `no-var` rule globally A significant portion of the code-base has now been converted to use `let`/`const`, rather than `var`, hence it should be possible to simply enable the ESLint `no-var` rule globally. This way we can ensure that new code won't accidentally use `var`, and it also removes the need to manually enable the rule in various folders. Obviously it makes sense to continue the efforts to replace `var`, but that should probably happen on a file and/or folder basis. Please note that this patch excludes the following code: - The `extensions/` folder, since that seemed easiest for now (and I don't know exactly what the support situation is for the Chromium-extension). - The entire `external/` folder is ignored, since most of it's currently excluded from linting. For the code that isn't imported from elsewhere (and should be ignored), we should probably (at some point) bring the code up to the same linting/formatting standard as the rest of the code-base. - Various files in the `test/` folder are ignored, as necessary, since the way that a lot of this code is loaded will require some care (or perhaps larger re-factoring) when removing `var` usage. --- .eslintignore | 2 +- .eslintrc | 2 +- examples/.eslintrc | 5 ----- extensions/chromium/.eslintrc | 1 + extensions/firefox/.eslintrc | 1 + external/.eslintrc | 5 +++++ gulpfile.js | 1 - src/.eslintrc | 10 ---------- src/core/.eslintrc | 2 +- src/shared/.eslintrc | 2 +- systemjs.config.js | 1 + test/add_test.js | 2 ++ test/chromium/test-telemetry.js | 1 + test/downloadutils.js | 1 + test/driver.js | 1 + test/font/.eslintrc | 10 ---------- test/stats/statcmp.js | 2 ++ test/test.js | 1 + test/testutils.js | 1 + test/unit/.eslintrc | 3 --- test/webserver.js | 1 + web/.eslintrc | 3 --- 22 files changed, 22 insertions(+), 36 deletions(-) delete mode 100644 src/.eslintrc delete mode 100644 test/font/.eslintrc diff --git a/.eslintignore b/.eslintignore index 85bc5d593..d149d0f58 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,7 +7,7 @@ external/webL10n/ external/cmapscompress/ external/builder/fixtures/ external/builder/fixtures_esprima/ -external/quickjs/quickjs-eval.js +external/quickjs/ src/shared/cffStandardStrings.js src/shared/fonts_utils.js test/tmp/ diff --git a/.eslintrc b/.eslintrc index 15643b2a5..128967483 100644 --- a/.eslintrc +++ b/.eslintrc @@ -197,7 +197,7 @@ "no-useless-computed-key": "error", "no-useless-constructor": "error", "no-useless-rename": "error", - "no-var": "off", + "no-var": "error", "object-shorthand": ["error", "always", { "avoidQuotes": true, }], diff --git a/examples/.eslintrc b/examples/.eslintrc index 14eeee2f8..433abdbfa 100644 --- a/examples/.eslintrc +++ b/examples/.eslintrc @@ -8,9 +8,4 @@ "pdfjsLib": false, "pdfjsViewer": false, }, - - "rules": { - // ECMAScript 6 - "no-var": "error", - }, } diff --git a/extensions/chromium/.eslintrc b/extensions/chromium/.eslintrc index ae23570f8..9b12e47c4 100644 --- a/extensions/chromium/.eslintrc +++ b/extensions/chromium/.eslintrc @@ -17,6 +17,7 @@ "rules": { "mozilla/import-globals": "error", + "no-var": "off", "object-shorthand": "off", }, } diff --git a/extensions/firefox/.eslintrc b/extensions/firefox/.eslintrc index ac538caa5..7c4e6e682 100644 --- a/extensions/firefox/.eslintrc +++ b/extensions/firefox/.eslintrc @@ -16,6 +16,7 @@ "rules": { // Items different from the mozilla/recommended configuration. + "no-var": "off", // Other rules mozilla/recommended hasn't enabled yet. "no-shadow": "error", diff --git a/external/.eslintrc b/external/.eslintrc index e3523dce5..64c94ad96 100644 --- a/external/.eslintrc +++ b/external/.eslintrc @@ -6,4 +6,9 @@ "env": { "node": true, }, + + "rules": { + // ECMAScript 6 + "no-var": "off", + }, } diff --git a/gulpfile.js b/gulpfile.js index 905420c33..eb515bb63 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,7 +13,6 @@ * limitations under the License. */ /* eslint-env node */ -/* eslint no-var: error */ /* globals target */ "use strict"; diff --git a/src/.eslintrc b/src/.eslintrc deleted file mode 100644 index 4a0b538f6..000000000 --- a/src/.eslintrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": [ - "../.eslintrc" - ], - - "rules": { - // ECMAScript 6 - "no-var": "error", - }, -} diff --git a/src/core/.eslintrc b/src/core/.eslintrc index cec998b9c..c1831d388 100644 --- a/src/core/.eslintrc +++ b/src/core/.eslintrc @@ -4,7 +4,7 @@ }, "extends": [ - "../.eslintrc" + "../../.eslintrc" ], "env": { diff --git a/src/shared/.eslintrc b/src/shared/.eslintrc index cec998b9c..c1831d388 100644 --- a/src/shared/.eslintrc +++ b/src/shared/.eslintrc @@ -4,7 +4,7 @@ }, "extends": [ - "../.eslintrc" + "../../.eslintrc" ], "env": { diff --git a/systemjs.config.js b/systemjs.config.js index c5d8185aa..a4a02bc0f 100644 --- a/systemjs.config.js +++ b/systemjs.config.js @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable no-var */ "use strict"; diff --git a/test/add_test.js b/test/add_test.js index 1f3cd55e9..ca4b4b18b 100644 --- a/test/add_test.js +++ b/test/add_test.js @@ -1,3 +1,5 @@ +/* eslint-disable no-var */ + const fs = require("fs"); const crypto = require("crypto"); const execSync = require("child_process").execSync; diff --git a/test/chromium/test-telemetry.js b/test/chromium/test-telemetry.js index c0121c5cb..f03675a50 100755 --- a/test/chromium/test-telemetry.js +++ b/test/chromium/test-telemetry.js @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable no-var */ "use strict"; diff --git a/test/downloadutils.js b/test/downloadutils.js index 15c0c3c3b..159d15a21 100644 --- a/test/downloadutils.js +++ b/test/downloadutils.js @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable no-var */ "use strict"; diff --git a/test/driver.js b/test/driver.js index d40062547..717b6caaa 100644 --- a/test/driver.js +++ b/test/driver.js @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable no-var */ /* globals pdfjsLib, pdfjsViewer */ "use strict"; diff --git a/test/font/.eslintrc b/test/font/.eslintrc deleted file mode 100644 index 4a0b538f6..000000000 --- a/test/font/.eslintrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": [ - "../.eslintrc" - ], - - "rules": { - // ECMAScript 6 - "no-var": "error", - }, -} diff --git a/test/stats/statcmp.js b/test/stats/statcmp.js index b0b35c93a..4dd2a44a4 100644 --- a/test/stats/statcmp.js +++ b/test/stats/statcmp.js @@ -1,3 +1,5 @@ +/* eslint-disable no-var */ + "use strict"; var fs = require("fs"); diff --git a/test/test.js b/test/test.js index 13ab5461c..957ceb69d 100644 --- a/test/test.js +++ b/test/test.js @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable no-var */ "use strict"; diff --git a/test/testutils.js b/test/testutils.js index 8113d949f..f4e7eb03d 100644 --- a/test/testutils.js +++ b/test/testutils.js @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable no-var */ "use strict"; diff --git a/test/unit/.eslintrc b/test/unit/.eslintrc index c78c8b2d8..69af6d92d 100644 --- a/test/unit/.eslintrc +++ b/test/unit/.eslintrc @@ -6,8 +6,5 @@ "rules": { // Plugins "import/no-unresolved": ["error", { "ignore": ["pdfjs/"] }], - - // ECMAScript 6 - "no-var": "error", }, } diff --git a/test/webserver.js b/test/webserver.js index 68b413858..c2d5b96de 100644 --- a/test/webserver.js +++ b/test/webserver.js @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable no-var */ "use strict"; diff --git a/web/.eslintrc b/web/.eslintrc index 4bf1e6286..08e6f9e38 100644 --- a/web/.eslintrc +++ b/web/.eslintrc @@ -6,8 +6,5 @@ "rules": { // Plugins "import/no-unresolved": ["error", { "ignore": ["pdfjs-lib"]}], - - // ECMAScript 6 - "no-var": "error", }, }