Skip to content

Commit 2112053

Browse files
authored
fix(deps): upgrade eslint and plugins to 9.39.4 (#201701)
* fix(deps): upgrade eslint and plugins to 10.2.0 * chore: manual lint-fix * chore: automatic lint-fix * feat(repo): github actions - lint - use node v24 because it is linting (not runtime), so why not to use the latest stable Node version * fix: remove @stylistic/eslint-plugin (in favor of prettier) * fix: eslint uses `ecmaVersion` 2025 * fix: eslint's "mocha" config is isolated (for test files only) for example `describe` is not considered "global" outside the test files. the same for all other "eslint/mocha" rules - they are applied only to files in `/tests` folder. * chore: update package-lock.json after eslint upgrade
1 parent fb1ccd3 commit 2112053

16 files changed

Lines changed: 370 additions & 414 deletions

File tree

.eslintignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ jobs:
99
name: ESLint
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
13-
- name: Install node v14
14-
uses: actions/setup-node@v2
12+
- uses: actions/checkout@v4
13+
- name: Install node v24
14+
uses: actions/setup-node@v4
1515
with:
16-
node-version: '14'
16+
node-version: '24'
1717
- name: Install dependencies
1818
run: npm install
1919
- name: Run ESLint
20-
run: ./node_modules/.bin/eslint .
20+
run: npm run lint

eslint.config.mjs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import globals from 'globals';
2+
import pluginEslintJs from '@eslint/js';
3+
import pluginMocha from 'eslint-plugin-mocha';
4+
import configEslintConfigPrettier from 'eslint-plugin-prettier/recommended';
5+
6+
export default [
7+
pluginEslintJs.configs.recommended,
8+
{
9+
name: 'whatsapp-web.js/default/rules',
10+
plugins: {
11+
mocha: pluginMocha,
12+
},
13+
languageOptions: {
14+
ecmaVersion: 2025,
15+
16+
globals: {
17+
...globals.browser,
18+
...globals.commonjs,
19+
...globals.es6,
20+
...globals.node,
21+
22+
Atomics: 'readonly',
23+
SharedArrayBuffer: 'readonly',
24+
},
25+
},
26+
rules: {
27+
'no-unused-vars': [
28+
'error',
29+
{
30+
// TODO: args can be uncommented, but there is code, that causes lint-errors
31+
// args: 'all',
32+
vars: 'all',
33+
caughtErrorsIgnorePattern: '^ignoredError',
34+
},
35+
],
36+
},
37+
},
38+
{
39+
// be careful, "recommended" settings object has 4 fields:
40+
// - name (string)
41+
// - plugins (object)
42+
// - languageOptions (object)
43+
// - rules (object)
44+
//
45+
// by simple "adding" any of mentioned fields to this object
46+
// you REPLACE the "recommended" value.
47+
// If you want to PATCH it - consider nested "..." spread operator
48+
...pluginMocha.configs.recommended,
49+
name: 'whatsapp-web.js/default/mocha',
50+
51+
files: ['tests/**/*'],
52+
},
53+
{
54+
name: 'whatsapp-web.js/default/ignores',
55+
ignores: [
56+
'node_modules',
57+
'dist',
58+
'coverage',
59+
'docs',
60+
'*.min.js',
61+
'.wa-version',
62+
'.wwebjs_auth',
63+
'.wwebjs_cache',
64+
],
65+
},
66+
configEslintConfigPrettier,
67+
];

example.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ client.on('message', async (msg) => {
119119
await client.acceptInvite(inviteCode);
120120
msg.reply('Joined the group!');
121121
} catch (e) {
122+
console.error(e);
122123
msg.reply('That invite code seems to be invalid.');
123124
}
124125
} else if (msg.body.startsWith('!addmembers')) {

0 commit comments

Comments
 (0)