From 6a3768187b0283f7eede266d2b166487f396729e Mon Sep 17 00:00:00 2001 From: Maksim Koryukov Date: Mon, 6 Apr 2026 19:41:27 -0400 Subject: [PATCH 1/5] fix(deps): upgrade eslint and plugins to 10.2.0 feat: cfg 2 feat: asdf --- .eslintignore | 8 ------- .eslintrc.json | 21 ----------------- eslint.config.mjs | 58 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 9 +++++--- 4 files changed, 64 insertions(+), 32 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.json create mode 100644 eslint.config.mjs diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index ad9338310d..0000000000 --- a/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -dist -coverage -docs -*.min.js -.wa-version -.wwebjs_auth -.wwebjs_cache diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index f525b8b8b1..0000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "env": { - "browser": true, - "commonjs": true, - "es6": true, - "node": true - }, - "extends": [ - "eslint:recommended", - "plugin:mocha/recommended", - "plugin:prettier/recommended" - ], - "globals": { - "Atomics": "readonly", - "SharedArrayBuffer": "readonly" - }, - "parserOptions": { - "ecmaVersion": 2022 - }, - "plugins": ["mocha"] -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000000..2aace6fdb3 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,58 @@ +import globals from 'globals'; +import pluginEslintJs from '@eslint/js'; +import pluginMocha from 'eslint-plugin-mocha'; +import pluginStylistic from '@stylistic/eslint-plugin'; +import configEslintConfigPrettier from 'eslint-plugin-prettier/recommended'; + +export default [ + pluginEslintJs.configs.recommended, + pluginStylistic.configs.recommended, + { + name: 'whatsapp-web.js/default/rules', + plugins: { + mocha: pluginMocha, + '@stylistic': pluginStylistic, + }, + languageOptions: { + // // TODO: consider moving to: + // ecmaVersion: 2025, + ecmaVersion: 2022, + + globals: { + ...globals.browser, + ...globals.commonjs, + ...globals.es6, + ...globals.node, + + Atomics: 'readonly', + SharedArrayBuffer: 'readonly', + }, + }, + rules: { + 'no-unused-vars': [ + 'error', + { + // TODO: args can be uncommented, but there is code, that causes lint-errors + // args: 'all', + vars: 'all', + caughtErrorsIgnorePattern: '^ignoreError', + }, + ], + }, + }, + { + name: 'whatsapp-web.js/default/ignores', + ignores: [ + 'node_modules', + 'dist', + 'coverage', + 'docs', + '*.min.js', + '.wa-version', + '.wwebjs_auth', + '.wwebjs_cache', + ], + }, + pluginMocha.configs.recommended, + configEslintConfigPrettier, +]; diff --git a/package.json b/package.json index 1f63aeadac..787e3596ff 100644 --- a/package.json +++ b/package.json @@ -42,18 +42,21 @@ "puppeteer": "^24.31.0" }, "devDependencies": { - "is-ci": "^4.1.0", "@commitlint/cli": "^20.4.1", "@commitlint/config-conventional": "^20.4.1", + "@eslint/js": "^9.39.4", + "@stylistic/eslint-plugin": "^5.10.0", "@types/node-fetch": "^2.5.12", "chai": "^4.3.4", "chai-as-promised": "^7.1.1", "dotenv": "^16.0.0", - "eslint": "^8.4.1", + "eslint": "^9.39.4", "eslint-config-prettier": "^10.1.8", - "eslint-plugin-mocha": "^10.0.3", + "eslint-plugin-mocha": "^11.2.0", "eslint-plugin-prettier": "^5.5.5", + "globals": "^17.4.0", "husky": "^9.1.7", + "is-ci": "^4.1.0", "jsdoc": "^3.6.4", "jsdoc-baseline": "^0.1.5", "lint-staged": "^16.2.7", From 4951017de13bd514be7eaa36e85236eadc5893df Mon Sep 17 00:00:00 2001 From: Maksim Koryukov Date: Mon, 6 Apr 2026 19:42:18 -0400 Subject: [PATCH 2/5] chore: manual lint-fix feat: tmp 1 --- example.js | 1 + src/Client.js | 4 ++-- src/util/Injected/Utils.js | 12 ++++++------ src/webCache/LocalWebCache.js | 2 +- tests/structures/chat.js | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/example.js b/example.js index 195f3c0cab..62fee77a14 100644 --- a/example.js +++ b/example.js @@ -119,6 +119,7 @@ client.on('message', async (msg) => { await client.acceptInvite(inviteCode); msg.reply('Joined the group!'); } catch (e) { + console.error(e); msg.reply('That invite code seems to be invalid.'); } } else if (msg.body.startsWith('!addmembers')) { diff --git a/src/Client.js b/src/Client.js index 145e110466..d70d2cba1b 100644 --- a/src/Client.js +++ b/src/Client.js @@ -2327,7 +2327,7 @@ class Client extends EventEmitter { }, participantWids, ); - } catch (err) { + } catch (ignoreError) { return 'CreateGroupError: An unknown error occupied while creating a group'; } @@ -2566,7 +2566,7 @@ class Client extends EventEmitter { meContact, )); } - } catch (error) { + } catch (ignoreError) { return false; } diff --git a/src/util/Injected/Utils.js b/src/util/Injected/Utils.js index 53cc348794..cb52962b54 100644 --- a/src/util/Injected/Utils.js +++ b/src/util/Injected/Utils.js @@ -333,7 +333,7 @@ exports.LoadUtils = () => { .vcardGetNameFromParsed(parsed), }; } - } catch (_) { + } catch (ignoreError) { // not a vcard } } @@ -857,7 +857,7 @@ exports.LoadUtils = () => { .require('WAWebCollections') .WAWebNewsletterCollection.find(chatWid); } - } catch (err) { + } catch (ignoreError) { chat = null; } } else { @@ -1181,7 +1181,7 @@ exports.LoadUtils = () => { ); return waveform; - } catch (e) { + } catch (ignoreError) { return undefined; } }; @@ -1418,7 +1418,7 @@ exports.LoadUtils = () => { return base64Image; } } - } catch (error) { + } catch (ignoreError) { /* empty */ } } @@ -1455,7 +1455,7 @@ exports.LoadUtils = () => { rpcResult.value.addParticipant[0] .addParticipantsParticipantAddedOrNonRegisteredWaUserParticipantErrorLidResponseMixinGroup .value.addParticipantsParticipantMixins; - } catch (err) { + } catch (ignoreError) { data.code = 400; return data; } @@ -1618,7 +1618,7 @@ exports.LoadUtils = () => { )); } return result; - } catch (err) { + } catch (ignoreError) { return []; } }; diff --git a/src/webCache/LocalWebCache.js b/src/webCache/LocalWebCache.js index 561fa7966a..fc0be93b98 100644 --- a/src/webCache/LocalWebCache.js +++ b/src/webCache/LocalWebCache.js @@ -22,7 +22,7 @@ class LocalWebCache extends WebCache { try { return fs.readFileSync(filePath, 'utf-8'); - } catch (err) { + } catch (ignoreError) { if (this.strict) throw new VersionResolveError( `Couldn't load version ${version} from the cache`, diff --git a/tests/structures/chat.js b/tests/structures/chat.js index dc2a9b19d6..5deeca3474 100644 --- a/tests/structures/chat.js +++ b/tests/structures/chat.js @@ -183,7 +183,7 @@ describe('Chat', function () { }); }); - // eslint-disable-next-line mocha/no-skipped-tests + // eslint-disable-next-line mocha/no-pending-tests describe.skip('Destructive operations', function () { it('can clear all messages from chat', async function () { const res = await chat.clearMessages(); From 1b099cebf0017943a55f7bd758ff9a8a2ecf3673 Mon Sep 17 00:00:00 2001 From: Maksim Koryukov Date: Mon, 6 Apr 2026 19:47:18 -0400 Subject: [PATCH 3/5] chore: automatic lint-fix --- src/Client.js | 3 ++- src/authStrategies/BaseAuthStrategy.js | 2 ++ src/structures/Label.js | 1 + src/structures/Message.js | 2 ++ src/util/Injected/Utils.js | 2 +- src/webCache/WebCache.js | 1 + tests/client.js | 2 +- 7 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Client.js b/src/Client.js index d70d2cba1b..4d002cfd83 100644 --- a/src/Client.js +++ b/src/Client.js @@ -107,6 +107,7 @@ class Client extends EventEmitter { Util.setFfmpegPath(this.options.ffmpegPath); } + /** * Injection logic * Private function @@ -322,7 +323,7 @@ class Client extends EventEmitter { await webCache.persist(this.currentIndexHtml, version); } - //Load util functions (serializers, helper functions) + // Load util functions (serializers, helper functions) await this.pupPage.evaluate(LoadUtils); let start = Date.now(); diff --git a/src/authStrategies/BaseAuthStrategy.js b/src/authStrategies/BaseAuthStrategy.js index 1121f0b3d5..b94597d701 100644 --- a/src/authStrategies/BaseAuthStrategy.js +++ b/src/authStrategies/BaseAuthStrategy.js @@ -8,6 +8,7 @@ class BaseAuthStrategy { setup(client) { this.client = client; } + async beforeBrowserInitialized() {} async afterBrowserInitialized() {} async onAuthenticationNeeded() { @@ -17,6 +18,7 @@ class BaseAuthStrategy { failureEventPayload: undefined, }; } + async getAuthEventPayload() {} async afterAuthReady() {} async disconnect() {} diff --git a/src/structures/Label.js b/src/structures/Label.js index f9d64454e7..98d41252e6 100644 --- a/src/structures/Label.js +++ b/src/structures/Label.js @@ -37,6 +37,7 @@ class Label extends Base { */ this.hexColor = labelData.hexColor; } + /** * Get all chats that have been assigned this Label * @returns {Promise>} diff --git a/src/structures/Message.js b/src/structures/Message.js index 8ac970ede7..cedd0c2bd0 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -821,6 +821,7 @@ class Message extends Base { } return undefined; } + /** * Gets the payment details associated with a given message * @return {Promise} @@ -1006,6 +1007,7 @@ class Message extends Base { return edittedEventMsg && new Message(this.client, edittedEventMsg); } + /** * Returns the PollVote this poll message * @returns {Promise} diff --git a/src/util/Injected/Utils.js b/src/util/Injected/Utils.js index cb52962b54..3383711cdb 100644 --- a/src/util/Injected/Utils.js +++ b/src/util/Injected/Utils.js @@ -361,7 +361,7 @@ exports.LoadUtils = () => { content = options.buttons.body; caption = content; } else { - caption = options.caption ? options.caption : ' '; //Caption can't be empty + caption = options.caption ? options.caption : ' '; // Caption can't be empty } buttonOptions = { productHeaderImageRejected: false, diff --git a/src/webCache/WebCache.js b/src/webCache/WebCache.js index 28e42c6867..be085f0b05 100644 --- a/src/webCache/WebCache.js +++ b/src/webCache/WebCache.js @@ -5,6 +5,7 @@ class WebCache { async resolve() { return null; } + async persist() {} } diff --git a/tests/client.js b/tests/client.js index dd4412692a..c0de50adb0 100644 --- a/tests/client.js +++ b/tests/client.js @@ -351,7 +351,7 @@ END:VCARD`; it('can send multiple Contacts as a contact card message', async function () { const contact1 = await client.getContactById(remoteId); const contact2 = - await client.getContactById('5511942167462@c.us'); //iFood + await client.getContactById('5511942167462@c.us'); // iFood const msg = await client.sendMessage(remoteId, [ contact1, From 3596b240139c14aae4c2a9705cdf4cd6ff0d36e3 Mon Sep 17 00:00:00 2001 From: Maksim Koryukov Date: Mon, 6 Apr 2026 21:53:27 -0400 Subject: [PATCH 4/5] feat(repo): github actions - lint - use node v24 because it is linting (not runtime), so why not to use the latest stable Node version --- .github/workflows/lint.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 320ec5fe8b..e4a945743a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,12 +9,12 @@ jobs: name: ESLint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Install node v14 - uses: actions/setup-node@v2 + - uses: actions/checkout@v4 + - name: Install node v24 + uses: actions/setup-node@v4 with: - node-version: '14' + node-version: '24' - name: Install dependencies run: npm install - name: Run ESLint - run: ./node_modules/.bin/eslint . + run: npm run lint From ad7b03c9b29799a0b2d9641a7d495651b7c05ea9 Mon Sep 17 00:00:00 2001 From: Maksim Koryukov Date: Sun, 12 Apr 2026 06:49:55 -0400 Subject: [PATCH 5/5] fix: remove @stylistic/eslint-plugin (in favor of prettier) --- eslint.config.mjs | 3 --- package.json | 1 - 2 files changed, 4 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 2aace6fdb3..9e4d1a47f0 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,17 +1,14 @@ import globals from 'globals'; import pluginEslintJs from '@eslint/js'; import pluginMocha from 'eslint-plugin-mocha'; -import pluginStylistic from '@stylistic/eslint-plugin'; import configEslintConfigPrettier from 'eslint-plugin-prettier/recommended'; export default [ pluginEslintJs.configs.recommended, - pluginStylistic.configs.recommended, { name: 'whatsapp-web.js/default/rules', plugins: { mocha: pluginMocha, - '@stylistic': pluginStylistic, }, languageOptions: { // // TODO: consider moving to: diff --git a/package.json b/package.json index 787e3596ff..a59f46c4aa 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "@commitlint/cli": "^20.4.1", "@commitlint/config-conventional": "^20.4.1", "@eslint/js": "^9.39.4", - "@stylistic/eslint-plugin": "^5.10.0", "@types/node-fetch": "^2.5.12", "chai": "^4.3.4", "chai-as-promised": "^7.1.1",