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 +(): + + + +