From ad69c760fb009c5d07a04735fc7f7ca457280248 Mon Sep 17 00:00:00 2001 From: Manish Jethani Date: Tue, 3 Aug 2021 02:25:03 +0530 Subject: [PATCH] Run ESLint during Node.js package generation (#3798) --- platform/nodejs/eslintrc.json | 18 ++++++++++++++++++ platform/nodejs/test.js | 1 + src/js/biditrie.js | 7 ++++--- src/js/globals.js | 2 ++ src/js/hntrie.js | 2 +- src/js/static-filtering-parser.js | 2 ++ src/js/static-net-filtering.js | 2 ++ tools/make-nodejs.sh | 2 ++ 8 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 platform/nodejs/eslintrc.json diff --git a/platform/nodejs/eslintrc.json b/platform/nodejs/eslintrc.json new file mode 100644 index 000000000..8ffed4f39 --- /dev/null +++ b/platform/nodejs/eslintrc.json @@ -0,0 +1,18 @@ +{ + "env": { + "es2021": true, + "node": true + }, + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": 12, + "sourceType": "module" + }, + "rules": { + "indent": [ "warn", 4 ], + "getter-return": "off", + "no-control-regex": "off", + "no-empty": [ "error", { "allowEmptyCatch": true } ], + "no-useless-escape": "off" + } +} diff --git a/platform/nodejs/test.js b/platform/nodejs/test.js index 24d245d61..7ac93f7a0 100644 --- a/platform/nodejs/test.js +++ b/platform/nodejs/test.js @@ -19,6 +19,7 @@ Home: https://github.com/gorhill/uBlock */ +/* eslint-disable-next-line no-redeclare */ /* globals process */ 'use strict'; diff --git a/src/js/biditrie.js b/src/js/biditrie.js index 269ac1b88..cddd0a6d0 100644 --- a/src/js/biditrie.js +++ b/src/js/biditrie.js @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -/* globals WebAssembly */ +/* globals WebAssembly vAPI */ 'use strict'; @@ -223,7 +223,7 @@ const BidiTrieContainer = class { } if ( al === aR ) { return 0; } } - return 0; + return 0; // eslint-disable-line no-unreachable } matchesLeft(icell, ar, r) { @@ -267,7 +267,7 @@ const BidiTrieContainer = class { if ( icell === 0 ) { return 0; } } } - return 0; + return 0; // eslint-disable-line no-unreachable } matchesExtra(l, r, ix) { @@ -513,6 +513,7 @@ const BidiTrieContainer = class { } // TODO: we should never reach here because there will // always be a boundary cell. + // eslint-disable-next-line no-debugger debugger; // jshint ignore:line // boundary cell + needle remainder inext = this.addCell(0, 0, 0); diff --git a/src/js/globals.js b/src/js/globals.js index 3401bd8c2..6c334d255 100644 --- a/src/js/globals.js +++ b/src/js/globals.js @@ -19,6 +19,8 @@ Home: https://github.com/gorhill/uBlock */ +/* globals self */ + 'use strict'; /******************************************************************************/ diff --git a/src/js/hntrie.js b/src/js/hntrie.js index 3fb172556..63e91dc4b 100644 --- a/src/js/hntrie.js +++ b/src/js/hntrie.js @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -/* globals WebAssembly */ +/* globals WebAssembly vAPI */ 'use strict'; diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index a07d0bd73..e0bd65fbd 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -19,6 +19,8 @@ Home: https://github.com/gorhill/uBlock */ +/* globals document */ + 'use strict'; /******************************************************************************/ diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 162a8f6ca..01cb65933 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -19,6 +19,8 @@ Home: https://github.com/gorhill/uBlock */ +/* globals vAPI */ + 'use strict'; /******************************************************************************/ diff --git a/tools/make-nodejs.sh b/tools/make-nodejs.sh index 71e49c4e8..1dedfefb2 100755 --- a/tools/make-nodejs.sh +++ b/tools/make-nodejs.sh @@ -54,6 +54,8 @@ cp platform/nodejs/*.js $DES/ cp platform/nodejs/*.json $DES/ cp LICENSE.txt $DES/ +eslint -c platform/nodejs/eslintrc.json $DES/js $DES/*.js + if [ "$1" = all ]; then echo "*** uBlock0.nodejs: Creating plain package..." pushd $(dirname $DES/) > /dev/null