From 0acc36d9de91b934e186606630d2e490230131a3 Mon Sep 17 00:00:00 2001 From: Zastinian Date: Thu, 18 Apr 2024 00:05:26 -0600 Subject: [PATCH] feat: New Format & Configs --- .eslintrc.cjs | 66 ++++++++++++++++++++++++++++++++ .github/CONTRIBUTING.md | 40 +++++++++++++++++++ .github/ISSUE_TEMPLATE.md | 33 ++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 41 ++++++++++++++++++++ .gitignore | 6 ++- .husky/.gitignore | 1 + .husky/pre-commit | 1 + .lintstagedrc | 3 ++ .prettierignore | 6 +++ .prettierrc.mjs | 21 ++++++++++ .vscode/extensions.json | 6 +++ .vscode/settings.json | 39 +++++++++++++++++++ package.json | 54 ++++++++++++++++++++------ 13 files changed, 304 insertions(+), 13 deletions(-) create mode 100644 .eslintrc.cjs create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .husky/.gitignore create mode 100644 .husky/pre-commit create mode 100644 .lintstagedrc create mode 100644 .prettierignore create mode 100644 .prettierrc.mjs create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..9a5708a --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,66 @@ +process.env.ESLINT_TSCONFIG = "tsconfig.json" + +/** + * @type {import("eslint").Linter.Config} + */ +module.exports = { + globals: { + NodeJS: true, + NodeListOf: true, + }, + env: { + es2022: true, + node: true, + browser: true, + }, + extends: ["@antfu", "eslint-config-prettier"], + parser: "@typescript-eslint/parser", + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + }, + rules: { + "eol-last": "off", + "quotes": "off", + "semi": ["warn", "never"], + "@stylistic/js/no-tabs": "off", + "@stylistic/ts/indent": "off", + "no-constant-binary-expression": "warn", + "no-undef": "off", + "no-console": "off", + "no-debugger": "warn", + "no-sequences": "off", + "no-import-assign": "off", + "no-extend-native": "off", + "no-trailing-spaces": "warn", + "no-case-declarations": "off", + "no-prototype-builtins": "off", + "no-unused-expressions": "off", + "space-before-function-paren": "off", + "antfu/if-newline": "off", + "antfu/top-level-function": "off", + "@stylistic/js/operator-linebreak": "off", + "@stylistic/ts/brace-style": "off", + "@stylistic/js/multiline-ternary": "off", + "n/prefer-global/process": "off", + "@stylistic/js/no-mixed-spaces-and-tabs": "off", + "no-unused-vars": "off", + "unused-imports/no-unused-vars": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-invalid-this": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "object-curly-newline": [ + "warn", + { + consistent: true, + multiline: true, + }, + ], + "object-curly-spacing": ["warn", "always"], + "array-element-newline": ["warn", "consistent"], + "array-bracket-newline": ["warn", "consistent"], + }, +} diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..adcb558 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,40 @@ +# Contributing + +Follow these guidelines if you'd like to contribute to the project! + +--- + +## Table of Contents + +Read through these guidelines before you get started: + +1. [Issues & Bugs](#issues--bugs) +2. [Submitting Pull Requests](#submitting-pull-requests) + +## Issues & Bugs + +Submit an [issue][1] or [pull request][2] with a fix if you find any bugs in +the project. See [below](#submitting-pull-requests) for instructions on sending +in pull requests! + +When submitting an issue or pull request, make sure you're as detailed as possible +and fill in all answers to questions asked in the templates. For example, an issue +that simply states "X/Y/Z isn't working!" will be closed. + +## Submitting Pull Requests + +Before you do anything, make sure you check the current list of [pull requests][3] +to ensure you aren't duplicating anyone's work. Then, do the following: + +1. Fork the repository and make your changes in a git branch: `git checkout -b my-branch base-branch` +2. Make sure your feature or fix doesn't break the project! Test thoroughly. +3. Commit your changes, and be sure to leave a detailed commit message. +4. Push your branch to your forked repo on GitHub: `git push origin my-branch` +5. [Submit a pull request][3] and hold tight! +6. If any changes are requested by the project maintainers, make them and follow + this process again until the changes are merged in. + + +[1]: https://github.com/Zastinian/HedystiaMD/issues/new +[2]: https://github.com/Zastinian/HedystiaMD/compare +[3]: https://github.com/Zastinian/HedystiaMD/pulls \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..fc48c3a --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,33 @@ +# Submit a feature request or bug report + +Before you submit an issue, check to see if it has [already been reported][1]. + +--- + +Replace any ":question:" below with your information. + +## Development Environment + +- Operating system: :question: +- Browser: :question: +- Project version: :question: + +## Current Behavior + +:question: + +## Expected Behavior + +:question: + +## Steps to Reproduce + +Only fill this in if you are filing a bug report. + +1. :question: + +## Other Relevant Information + +:question: + +[1]: https://github.com/Zastinian/HedystiaMD/issues \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..d4d0cdc --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,41 @@ +# Submit a pull request + +Thank you for submitting a pull request! To speed up the review process, please ensure that everything below +is true: + +1. This is not a duplicate of an [existing pull request][1]. +2. No existing features have been broken without good reason. +3. Your commit messages are detailed +4. Documentation has been updated to reflect your changes. +5. Tests have been added or updated to reflect your changes. +6. All tests pass. + +--- + +Replace any ":question:" below with information about your pull request. + +## Pull Request Details + +Provide details about your pull request and what it adds, fixes, or changes. + +:question: + +## Breaking Changes + +Describe what features are broken by this pull request and why, if any. + +:question: + +## Issues Fixed + +Enter the issue numbers resolved by this pull request below, if any. + +1. :question: + +## Other Relevant Information + +Provide any other important details below. + +:question: + +[1]: https://github.com/Zastinian/HedystiaMD/pulls \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1f6a57c..43bba4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules/ -.hedystia/ +hedystia/ +hedystia.json pnpm-lock.yaml -dist/ +package-lock.json +bun.lockb diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 0000000..c9cdc63 --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..d0a7784 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npx lint-staged \ No newline at end of file diff --git a/.lintstagedrc b/.lintstagedrc new file mode 100644 index 0000000..5dc4476 --- /dev/null +++ b/.lintstagedrc @@ -0,0 +1,3 @@ +{ + "**/*.{ts,js,tsx,jsx}": ["eslint --ext", "prettier --check"] +} \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..dacfa3f --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +pnpm-lock.yaml +package-lock.json +bun.lockb +yarn.lock +node_modules/ +dist/ \ No newline at end of file diff --git a/.prettierrc.mjs b/.prettierrc.mjs new file mode 100644 index 0000000..de05039 --- /dev/null +++ b/.prettierrc.mjs @@ -0,0 +1,21 @@ +/** @type {import("prettier").Config} */ +export default { + printWidth: 100, + semi: false, + singleQuote: false, + jsxSingleQuote: false, + quoteProps: "consistent", + tabWidth: 2, + trailingComma: "es5", + useTabs: true, + endOfLine: "lf", + arrowParens: "always", + overrides: [ + { + files: ["*.json", "*.md", "*.toml", "*.yml"], + options: { + useTabs: false, + }, + }, + ], +}; diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..7efca3f --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7fe91d2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,39 @@ +{ + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.expand": false, + "explorer.fileNesting.patterns": { + "package.json": "pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lockb", + ".prettierrc.mjs": ".prettierignore", + ".eslintrc.cjs": ".lintstagedrc" + }, + "editor.linkedEditing": true, + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" + }, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "files.associations": { + "*.svg": "html" + }, + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], + "javascript.format.insertSpaceBeforeFunctionParenthesis": false, + "typescript.format.insertSpaceBeforeFunctionParenthesis": false, + "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false, + "typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false, + "editor.insertSpaces": false, + "editor.detectIndentation": false, + "tailwindCSS.classAttributes": [ + "class", + "className", + "ngClass", + "class:list" + ], + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } +} diff --git a/package.json b/package.json index 17fde2f..d0e3ce8 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,56 @@ { "name": "whatsapp-hedystia", "version": "2.0.0", + "description": "A whatsapp bot that can be used to play music", "main": "index.js", + "type": "commonjs", "scripts": { "start": "node index.js", - "dev": "nodemon index.js" + "dev": "nodemon index.js", + "lint": "eslint --ext .ts,.js,.tsx .", + "lint:fix": "eslint --ext .ts,.js,.tsx . --fix", + "format": "prettier --write src", + "format:check": "prettier --check src", + "prepare": "husky" }, + "keywords": [ + "baileys", + "hedystia", + "whatsapp" + ], "author": "contact@hedystia.com", - "license": "HedystiaMD - license.md", + "license": "ISC", "dependencies": { - "fluent-ffmpeg": "^2.1.2", - "qrcode-terminal": "^0.12.0", - "whatsapp-web.js": "1.21.0", - "yt-search": "^2.10.4", - "ytdl-core": "^4.11.4" + "@adiwajshing/keyed-db": "0.2.4", + "@hapi/boom": "10.0.1", + "@whiskeysockets/baileys": "6.6.0", + "awesome-phonenumber": "2.68.0", + "file-type": "16.5.3", + "fluent-ffmpeg": "2.1.2", + "formdata-node": "4.4.1", + "jimp": "0.16.1", + "moment-timezone": "0.5.34", + "node-webpmux": "3.1.1", + "pino": "8.11.0", + "qrcode-terminal": "0.12.0", + "wa-sticker-formatter": "4.4.4", + "yt-search": "2.10.4", + "ytdl-core": "^4.11.5" }, "devDependencies": { - "@types/fluent-ffmpeg": "^2.1.21", - "@types/node": "^20.4.5", - "@types/qrcode-terminal": "^0.12.0", - "@types/yt-search": "^2.3.2" + "@antfu/eslint-config": "0.43.1", + "@types/jsonwebtoken": "^9.0.6", + "@types/node": "^20.12.7", + "@typescript-eslint/parser": "7.5.0", + "eslint": "8.57.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-import": "^2.29.1", + "husky": "9.0.11", + "lint-staged": "15.2.2", + "prettier": "3.2.5" + }, + "directories": { + "handlers": "handlers", + "src": "src" } }