From 807efd502d70e0d180ef75eecabcaea72a787311 Mon Sep 17 00:00:00 2001 From: 2^1 <217781969+2hoch1@users.noreply.github.com> Date: Tue, 10 Mar 2026 00:45:12 +0100 Subject: [PATCH] chore: cleanup, ci workflows and formatting (#127064) * ci: setup workflows, dependabot, labeler and commit linting * docs: update README, community files and issue templates * chore: configure prettier, editorconfig and format codebase * chore: restore changes lost during rebase * docs: adjust url for new logo * fix: align badges * chore: resolve conflicts and re-add temp lint --- .editorconfig | 8 +- .env.example | 1 - .eslintignore | 8 + .eslintrc.json | 29 +- .gitattributes | 4 + .../CODE_OF_CONDUCT.md | 30 +- .github/COMMIT_CONVENTION.md | 204 ++ .github/CONTRIBUTING.md | 43 + .github/DISCLAIMER.md | 9 + .github/FUNDING.yml | 2 +- .github/ISSUE_TEMPLATE/01-bug_report.yml | 164 ++ .github/ISSUE_TEMPLATE/02-feature_request.yml | 55 + .github/ISSUE_TEMPLATE/bug_report.yml | 140 - .github/ISSUE_TEMPLATE/config.yml | 6 +- .github/ISSUE_TEMPLATE/feature_request.yml | 71 - .github/SUPPORT.md | 10 + .github/dependabot.yml | 14 +- .github/issue-labeler.yml | 24 + .github/labels.yml | 148 + .github/pr-labeler.yml | 65 + .github/pull_request_template.md | 94 +- .github/stale.yml | 20 - .github/workflows/format-issue-bug.yml | 112 + .github/workflows/issue-triage.yml | 24 + .github/workflows/labels-sync.yml | 29 + .github/workflows/lint.yml | 30 +- .github/workflows/pr-triage.yml | 49 + .github/workflows/release.yml | 84 +- .github/workflows/stale.yml | 42 + .github/workflows/tests.yml | 28 + .github/workflows/update.yml | 81 +- .husky/commit-msg | 4 + .husky/pre-commit | 1 + .jsdoc.json | 6 +- .lintstagedrc.json | 6 + .prettierignore | 8 + .prettierrc.json | 10 + README.md | 161 +- commitlint.config.js | 29 + example.js | 217 +- index.d.ts | 1705 ++++++----- index.js | 8 +- package.json | 126 +- shell.js | 8 +- src/Client.js | 2611 +++++++++++------ src/authStrategies/BaseAuthStrategy.js | 4 +- src/authStrategies/LocalAuth.js | 37 +- src/authStrategies/NoAuth.js | 7 +- src/authStrategies/RemoteAuth.js | 135 +- src/factories/ChatFactory.js | 2 +- src/factories/ContactFactory.js | 4 +- src/structures/Base.js | 8 +- src/structures/Broadcast.js | 3 +- src/structures/BusinessContact.js | 3 +- src/structures/Buttons.js | 24 +- src/structures/Call.js | 16 +- src/structures/Channel.js | 255 +- src/structures/Chat.js | 98 +- src/structures/ClientInfo.js | 2 +- src/structures/Contact.js | 37 +- src/structures/GroupChat.js | 643 ++-- src/structures/GroupNotification.js | 33 +- src/structures/Label.js | 11 +- src/structures/List.js | 36 +- src/structures/Location.js | 9 +- src/structures/Message.js | 573 +++- src/structures/MessageMedia.js | 47 +- src/structures/Order.js | 8 +- src/structures/Payment.js | 9 +- src/structures/Poll.js | 4 +- src/structures/PollVote.js | 15 +- src/structures/PrivateChat.js | 6 +- src/structures/PrivateContact.js | 6 +- src/structures/Product.js | 2 +- src/structures/ProductMetadata.js | 3 +- src/structures/Reaction.js | 6 +- src/structures/ScheduledEvent.js | 32 +- src/util/Constants.js | 13 +- src/util/Injected/AuthStore/AuthStore.js | 10 +- src/util/Injected/Utils.js | 1041 ++++--- src/util/InterfaceController.js | 97 +- src/util/Puppeteer.js | 2 +- src/util/Util.js | 43 +- src/webCache/LocalWebCache.js | 12 +- src/webCache/RemoteWebCache.js | 14 +- src/webCache/WebCache.js | 12 +- src/webCache/WebCacheFactory.js | 18 +- tests/README.md | 18 +- tests/client.js | 267 +- tests/helper.js | 22 +- tests/structures/chat.js | 36 +- tests/structures/group.js | 49 +- tests/structures/message.js | 12 +- tools/version-checker/update-version | 19 +- 94 files changed, 6767 insertions(+), 3524 deletions(-) create mode 100644 .eslintignore create mode 100644 .gitattributes rename CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md (85%) create mode 100644 .github/COMMIT_CONVENTION.md create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/DISCLAIMER.md create mode 100644 .github/ISSUE_TEMPLATE/01-bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/02-feature_request.yml delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/SUPPORT.md create mode 100644 .github/issue-labeler.yml create mode 100644 .github/labels.yml create mode 100644 .github/pr-labeler.yml delete mode 100644 .github/stale.yml create mode 100644 .github/workflows/format-issue-bug.yml create mode 100644 .github/workflows/issue-triage.yml create mode 100644 .github/workflows/labels-sync.yml create mode 100644 .github/workflows/pr-triage.yml create mode 100644 .github/workflows/stale.yml create mode 100644 .github/workflows/tests.yml create mode 100644 .husky/commit-msg create mode 100644 .husky/pre-commit create mode 100644 .lintstagedrc.json create mode 100644 .prettierignore create mode 100644 .prettierrc.json create mode 100644 commitlint.config.js diff --git a/.editorconfig b/.editorconfig index 73c5516..618cd79 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,5 +4,9 @@ root = true indent_style = space indent_size = 4 charset = utf-8 -trim_trailing_whitespace = false -insert_final_newline = false \ No newline at end of file +trim_trailing_whitespace = true +insert_final_newline = true +end_of_line = lf + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.env.example b/.env.example index 3add97c..28e0939 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,2 @@ WWEBJS_TEST_REMOTE_ID=XXXXXXXXXX@c.us WWEBJS_TEST_CLIENT_ID=authenticated -WWEBJS_TEST_MD=1 \ No newline at end of file diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..ad93383 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,8 @@ +node_modules +dist +coverage +docs +*.min.js +.wa-version +.wwebjs_auth +.wwebjs_cache diff --git a/.eslintrc.json b/.eslintrc.json index d2bbe30..f525b8b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,7 +5,11 @@ "es6": true, "node": true }, - "extends": ["eslint:recommended", "plugin:mocha/recommended"], + "extends": [ + "eslint:recommended", + "plugin:mocha/recommended", + "plugin:prettier/recommended" + ], "globals": { "Atomics": "readonly", "SharedArrayBuffer": "readonly" @@ -13,24 +17,5 @@ "parserOptions": { "ecmaVersion": 2022 }, - "plugins": ["mocha"], - "ignorePatterns": ["docs"], - "rules": { - "indent": [ - "error", - 4 - ], - "linebreak-style": [ - "error", - "unix" - ], - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "always" - ] - } -} \ No newline at end of file + "plugins": ["mocha"] +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..71692c3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +* text=auto eol=lf + +package-lock.json linguist-generated=true text=auto eol=lf +docs/* linguist-generated=true text=auto eol=lf diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 85% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md index e73010a..fde331b 100644 --- a/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -1,4 +1,3 @@ - # Contributor Covenant Code of Conduct ## Our Pledge @@ -18,23 +17,23 @@ diverse, inclusive, and healthy community. Examples of behavior that contributes to a positive environment for our community include: -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -* Focusing on what is best not just for us as individuals, but for the +- Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or +- The use of sexualized language or imagery, and sexual attention or advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities @@ -61,7 +60,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -[pedroslopez@me.com](mailto:pedroslopez@me.com). +[pedroslopez@me.com][email]. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the @@ -107,7 +106,7 @@ Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an +standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within @@ -119,13 +118,14 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. -Community Impact Guidelines were inspired by +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. +[email]: mailto:pedroslopez@me.com [homepage]: https://www.contributor-covenant.org [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html [Mozilla CoC]: https://github.com/mozilla/diversity diff --git a/.github/COMMIT_CONVENTION.md b/.github/COMMIT_CONVENTION.md new file mode 100644 index 0000000..473d2f9 --- /dev/null +++ b/.github/COMMIT_CONVENTION.md @@ -0,0 +1,204 @@ +# Git Commit Message Convention + +> This is adapted from [Angular's commit convention][angular-commit-convention]. + +Messages must be matched by the following regex (case-insensitive): + +```ts +/^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore|types|infra)(\(.+\))?!?: .{1,72}/i; +``` + +The commit type is **case-insensitive** — `feat`, `Feat`, and `FEAT` are all valid. + +## Examples + +### Features + +Appears under "Features" header, message subheader: + +```txt +feat(message): add 'downloadMedia' option +``` + +Additional examples: + +```txt +feat(chat): add ability to pin messages +``` + +```txt +feat(contact): add getProfilePicUrl method +``` + +### Bug Fixes + +Appears under "Bug Fixes" header, client subheader, with a link to issue #28: + +```txt +fix(client): stop client breaking when QR code expires + +Closes #28 +``` + +Additional examples: + +```txt +fix(message): handle media messages without caption correctly +``` + +```txt +fix(auth): resolve authentication timeout on slow connections +``` + +### Performance Improvements + +Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation: + +```txt +perf(message): remove legacyMode option + +BREAKING CHANGE: The legacyMode option has been removed. The new message handling is always used for performance reasons. +``` + +Additional example: + +```txt +perf(client): optimize event listener registration +``` + +### Documentation + +```txt +docs(readme): update installation instructions +``` + +```txt +docs(api): add examples for message reactions +``` + +### Code Refactoring + +```txt +refactor(client): simplify authentication flow +``` + +```txt +refactor(structures): extract common message properties +``` + +### Tests + +```txt +test(message): add unit tests for media download +``` + +```txt +test(client): add integration tests for reconnection +``` + +### Build System + +```txt +build(deps): update puppeteer to v21.0.0 +``` + +```txt +build(webpack): optimize bundle size +``` + +### Continuous Integration + +```txt +ci(actions): add automated release workflow +``` + +```txt +ci(tests): run tests on multiple node versions +``` + +### Chores + +```txt +chore(gitignore): ignore .vscode directory +``` + +```txt +chore(deps): bump dependencies to latest versions +``` + +### Type Definitions + +```txt +types(message): add missing type for MessageMedia +``` + +```txt +types(client): improve ClientOptions interface +``` + +### Code Style + +```txt +style(client): fix indentation and spacing +``` + +### Reverts + +The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header: + +```txt +revert: feat(message): add 'downloadMedia' option + +This reverts commit 667ecc1654a317a13331b17617d973392f415f02. +``` + +A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: + +```txt +(): + + + +