diff --git a/.husky/commit-msg b/.husky/commit-msg
index 5f3e8e63..4b0e83c6 100755
--- a/.husky/commit-msg
+++ b/.husky/commit-msg
@@ -1,8 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
-# run directly, without docker support
-# pnpm commitlint --edit "${1}"
-
# through docker-compose
pnpm commitlint --edit "${1}"
diff --git a/package.json b/package.json
index 5eb87bfd..429464db 100644
--- a/package.json
+++ b/package.json
@@ -44,6 +44,7 @@
"deps:update": "pnpm dlx npm-check-updates@latest --configFileName .ncurc.yml -u --deep --mergeConfig && pnpm install",
"preinstall": "npx only-allow pnpm",
"lint": "pnpm run lint:md && pnpm run lint:js && pnpm run lint:secrets",
+ "lint:commits": "pnpm commitlint --from HEAD~1 --to HEAD --verbose",
"lint:fix": "turbo run lint:fix && pnpm lint:package-json",
"lint:js": "eslint --fix **/*.js",
"lint:md": "markdownlint --fix **/*.md --ignore '**/node_modules/**' --ignore '**/CHANGELOG.md'",
diff --git a/packages/browserslist-config/README.md b/packages/browserslist-config/README.md
index f11b83ea..f0518f7d 100644
--- a/packages/browserslist-config/README.md
+++ b/packages/browserslist-config/README.md
@@ -4,7 +4,6 @@
-
@@ -47,7 +46,7 @@ Add as dev-dependency to your monorepo
$ pnpm add -wD browserslist @wayofdev/browserslist-config
```
-Assuming that you have the following structure:
+This package should be added to the root of your monorepo, where you have a file `.browserslistrc` and a `package.json` file. Within your monorepo, you should have a structure with directories for your apps and packages, such as:
```bash
.
diff --git a/packages/browserslist-config/lint-staged.config.js b/packages/browserslist-config/lint-staged.config.js
new file mode 100644
index 00000000..528387c7
--- /dev/null
+++ b/packages/browserslist-config/lint-staged.config.js
@@ -0,0 +1,33 @@
+// @ts-check
+
+/**
+ * This files overrides the base lint-staged.config.js present in the root directory.
+ * It allows to run eslint based the package specific requirements.
+ * {@link https://github.com/okonet/lint-staged#how-to-use-lint-staged-in-a-multi-package-monorepo}
+ * {@link https://github.com/belgattitude/nextjs-monorepo-example/blob/main/docs/about-lint-staged.md}
+ */
+
+const { concatFilesForPrettier, getEslintFixCmd } = require('../../lint-staged.common.js')
+
+/**
+ * @type {Record string | string[] | Promise>}
+ */
+const rules = {
+ '**/*.{js,jsx,ts,tsx,mjs,cjs}': filenames => {
+ return getEslintFixCmd({
+ cwd: __dirname,
+ fix: true,
+ cache: true,
+ // when auto-fixing staged-files a good tip is to disable react-hooks/exhaustive-deps, cause
+ // a change here can potentially break things without proper visibility.
+ rules: ['react-hooks/exhaustive-deps: off'],
+ maxWarnings: 25,
+ files: filenames,
+ })
+ },
+ '**/*.{json,md,mdx,css,html,yml,yaml,scss}': filenames => {
+ return [`prettier --write ${concatFilesForPrettier(filenames)}`]
+ },
+}
+
+module.exports = rules
diff --git a/packages/commitlint-config/README.md b/packages/commitlint-config/README.md
index b97bdb23..73d6a95d 100644
--- a/packages/commitlint-config/README.md
+++ b/packages/commitlint-config/README.md
@@ -1,71 +1,188 @@
-# Commitlint Config
+
-Shareable commitlint configuration.
+
+

+

+
-## Install
+
+
+
+
+
+
+
+
+# Shareable Commitlint Config
+
+## 📄 About
+
+A shareable [commitlint](https://commitlint.js.org/#/) configuration for enforcing consistent commit messages in your projects.
+
+### → Purpose
+
+Consistent commit messages are important for project collaboration, maintainability, and project history. This commitlint configuration provides a set of rules to ensure that all commits in your project follow a consistent structure, making it easier for your team to understand what changes were made and why.
+
+
+
+To use this configuration, you'll need to install the `@commitlint/cli` package as a devDependency in your project:
```bash
-# install with yarn
-$ yarn add -D @commitlint/cli @wayofdev/commitlint-config
+# Install as dev-dependency into root of monorepo
+$ pnpm add -wD @commitlint/cli @wayofdev/commitlint-config
+```
-# install with pnpm
-$ pnpm add -Dw @commitlint/cli @wayofdev/commitlint-config
+This package should be added to the root of your monorepo, where you have a file `commitlint.config.js` and a `package.json` file. Within your monorepo, you should have a structure with directories for your apps and packages, such as:
+
+```bash
+.
+├── commitlint.config.js (root)
+├── package.json (root)
+├── apps
+│ └── my-first-app
+│ ├── package.json
+│ └── ... (other app files)
+└── packages
+ └── my-first-package
+ ├── package.json
+ └── ... (other package files)
```
-## Usage
+
-**`commitlint.config.js`**
+### → Configure
-```js
-module.exports = {
- extends: ['@wayofdev/commitlint-config'],
-};
+1. To configure the `commitlint.config.js` file, include the following line:
+
+ ```javascript
+ module.exports = {
+ extends: ["@wayofdev/commitlint-config"],
+ }
+ ```
+
+ This extends the `@wayofdev/commitlint-config` configuration and uses its [pre-defined configuration](https://github.com/wayofdev/npm-shareable-configs/blob/master/packages/commitlint-config/index.js).
+
+ Alternatively the configuration can be defined in a `commitlint.config.js`, `.commitlintrc.js`, `.commitlintrc`, `.commitlintrc.json`, `.commitlintrc.yml` file or a `commitlint` field in `package.json`.
+
+2. Install Husky
+
+ Install `husky` as devDependency, a handy git hook helper available on npm.
+
+ ```bash
+ # Install as dev-dependency into root of monorepo
+ $ pnpm add -wD husky is-ci
+
+ # Activate hooks
+ $ pnpm husky install
+ ```
+
+3. Add hook
+
+ ```bash
+ $ npx husky add .husky/commit-msg 'pnpm commitlint --edit "${1}"'
+ ```
+
+4. Add scripts to `package.json`
+
+ ```bash
+ $ pnpm pkg set scripts.lint:commits="pnpm commitlint --from HEAD~1 --to HEAD --verbose"
+ $ pnpm pkg set scripts.prepare="is-ci || husky install"
+ ```
+
+
+
+## 💻 Usage
+
+### → Test simple usage
+
+For a first simple usage test of commitlint you can do the following:
+
+```bash
+# using pnpm
+$ pnpm commitlint --from HEAD~1 --to HEAD --verbose
+
+# or, using npx
+$ npx commitlint --from HEAD~1 --to HEAD --verbose
+
+# or, if script was added
+$ pnpm lint:commits
+```
+
+This will check your last commit and return an error if invalid or a positive output if valid.
+
+### → Test the hook
+
+You can test the hook by simply committing. You should see something like this if everything works.
+
+```bash
+$ git commit -m "foo: this will fail"
+husky > commit-msg (node v10.1.0)
+No staged files match any of provided globs.
+⧗ input: foo: this will fail
+✖ type must be one of [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test] [type-enum]
+
+✖ found 1 problems, 0 warnings
+ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
+
+husky > commit-msg hook failed (add --no-verify to bypass)
```
-## Extending
+
+
+## 🛠️ Extending
+
+This shows, how config can be extended with your custom rules.
**`commitlint.config.js`**
```js
module.exports = {
- extends: ['@wayofdev/commitlint-config'],
- rules: {
- 'body-leading-blank': [2, 'always'],
- },
-};
+ extends: ["@wayofdev/commitlint-config"],
+ rules: {
+ "body-leading-blank": [2, "always"],
+ },
+}
```
-## Add a Husky Hook
+
-Install husky:
+## 🤝 License
-```bash
-# using yarn
-$ yarn dlx husky-init --yarn2 && yarn && npm pkg set scripts.prepare="husky install" && yarn prepare
+[](./LICENSE)
-# using pnpm
-$ pnpm dlx husky-init && pnpm install && pnpm pkg set scripts.prepare="husky install" && pnpm prepare
-```
+
-Add the hook:
+## 🧱 Credits and Useful Resources
-```bash
-# using npm
-$ npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "${1}"'
+Based on:
-# using yarn
-$ yarn dlx husky add .husky/pre-commit 'npx --no -- commitlint --edit "${1}"'
+- [shareable-configs](https://github.com/waldronmatt/shareable-configs) from [waldronmatt](https://github.com/waldronmatt)
-# using pnpm
-$ pnpm dlx husky add .husky/pre-commit 'npx --no -- commitlint --edit "${1}"'
-```
+Guides:
+
+- [Official commitlint setup guide](https://commitlint.js.org/#/./guides-local-setup?id=guides-local-setup)
+
+
+
+## 🙆🏼♂️ Author Information
+
+This repository was created in **2023** by [lotyp / wayofdev](https://github.com/wayofdev).
-## Under The Hood
+
-### `index.js`
+## 🙌 Want to Contribute?
-- `@commitlint/config-conventional`
+Thank you for considering contributing to the wayofdev community!
+We are open to all kinds of contributions. If you want to:
-## License
+- 🤔 Suggest a feature
+- 🐛 Report an issue
+- 📖 Improve documentation
+- 👨💻 Contribute to the code
-MIT
+You are more than welcome. Before contributing, kindly check our [guidelines](https://next-starter-tpl-docs.wayof.dev/contribution).
diff --git a/packages/commitlint-config/lint-staged.config.js b/packages/commitlint-config/lint-staged.config.js
new file mode 100644
index 00000000..528387c7
--- /dev/null
+++ b/packages/commitlint-config/lint-staged.config.js
@@ -0,0 +1,33 @@
+// @ts-check
+
+/**
+ * This files overrides the base lint-staged.config.js present in the root directory.
+ * It allows to run eslint based the package specific requirements.
+ * {@link https://github.com/okonet/lint-staged#how-to-use-lint-staged-in-a-multi-package-monorepo}
+ * {@link https://github.com/belgattitude/nextjs-monorepo-example/blob/main/docs/about-lint-staged.md}
+ */
+
+const { concatFilesForPrettier, getEslintFixCmd } = require('../../lint-staged.common.js')
+
+/**
+ * @type {Record string | string[] | Promise>}
+ */
+const rules = {
+ '**/*.{js,jsx,ts,tsx,mjs,cjs}': filenames => {
+ return getEslintFixCmd({
+ cwd: __dirname,
+ fix: true,
+ cache: true,
+ // when auto-fixing staged-files a good tip is to disable react-hooks/exhaustive-deps, cause
+ // a change here can potentially break things without proper visibility.
+ rules: ['react-hooks/exhaustive-deps: off'],
+ maxWarnings: 25,
+ files: filenames,
+ })
+ },
+ '**/*.{json,md,mdx,css,html,yml,yaml,scss}': filenames => {
+ return [`prettier --write ${concatFilesForPrettier(filenames)}`]
+ },
+}
+
+module.exports = rules
diff --git a/packages/commitlint-config/package.json b/packages/commitlint-config/package.json
index eeaf5b34..65ce4acd 100644
--- a/packages/commitlint-config/package.json
+++ b/packages/commitlint-config/package.json
@@ -17,18 +17,32 @@
"directory": "packages/commitlint-config"
},
"license": "MIT",
- "author": "lotyp7@gmail.com",
- "main": "index.js",
+ "author": {
+ "name": "Andrij Orlenko",
+ "email": "lotyp7@gmail.com",
+ "url": "https://github.com/lotyp"
+ },
+ "exports": {
+ ".": {
+ "require": "./src/index.js"
+ }
+ },
+ "main": "src/index.js",
"files": [
- "index.js",
+ "src/*",
"scripts/*"
],
"scripts": {
- "test": "echo \"No test specified\""
+ "clean": "rimraf ./dist ./coverage ./tsconfig.tsbuildinfo",
+ "lint": "eslint --ext .ts,.js,.cjs,.mjs --cache --cache-location ../../.cache/eslint/commitlint-config.eslintcache",
+ "lint:fix": "eslint --ext .ts,.tsx,.js,.jsx,.mjs,.cjs,.mts,.cts --fix --cache --cache-location ../../.cache/eslint/commitlint-config.eslintcache"
},
"dependencies": {
"@commitlint/config-conventional": "^17.4.2"
},
+ "devDependencies": {
+ "rimraf": "^4.1.2"
+ },
"peerDependencies": {
"@commitlint/cli": ">= 17"
},
diff --git a/packages/commitlint-config/index.js b/packages/commitlint-config/src/index.js
similarity index 100%
rename from packages/commitlint-config/index.js
rename to packages/commitlint-config/src/index.js
diff --git a/packages/eslint-config-bases/lint-staged.config.js b/packages/eslint-config-bases/lint-staged.config.js
index 73f38b5c..528387c7 100644
--- a/packages/eslint-config-bases/lint-staged.config.js
+++ b/packages/eslint-config-bases/lint-staged.config.js
@@ -13,7 +13,7 @@ const { concatFilesForPrettier, getEslintFixCmd } = require('../../lint-staged.c
* @type {Record string | string[] | Promise>}
*/
const rules = {
- '**/*.{js,jsx,ts,tsx}': filenames => {
+ '**/*.{js,jsx,ts,tsx,mjs,cjs}': filenames => {
return getEslintFixCmd({
cwd: __dirname,
fix: true,
diff --git a/packages/eslint-config-bases/package.json b/packages/eslint-config-bases/package.json
index 5df241ad..f9f36d49 100644
--- a/packages/eslint-config-bases/package.json
+++ b/packages/eslint-config-bases/package.json
@@ -23,8 +23,7 @@
"eslint-sonar",
"eslint-storybook",
"eslint-tailwind",
- "eslint-tailwindcss",
- "eslint-typescript"
+ "eslint-tailwindcss"
],
"homepage": "https://github.com/wayofdev/npm-shareable-configs/tree/master/packages/eslint-config-bases#readme",
"bugs": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 572fafb3..a9bff696 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -61,9 +61,12 @@ importers:
specifiers:
'@commitlint/cli': '>= 17'
'@commitlint/config-conventional': ^17.4.2
+ rimraf: ^4.1.2
dependencies:
'@commitlint/cli': 17.4.2
'@commitlint/config-conventional': 17.4.2
+ devDependencies:
+ rimraf: 4.1.2
packages/eslint-config-bases:
specifiers: