Skip to content

Commit

Permalink
refactor: revised all packages
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed Feb 17, 2023
1 parent cd21ac1 commit 6088d40
Show file tree
Hide file tree
Showing 52 changed files with 1,332 additions and 665 deletions.
5 changes: 0 additions & 5 deletions .changeset/funny-trainers-learn.md

This file was deleted.

14 changes: 14 additions & 0 deletions .changeset/lovely-carrots-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@wayofdev/browserslist-config': major
'@wayofdev/eslint-config-bases': major
'@wayofdev/markdownlint-config': major
'@wayofdev/lint-staged-config': major
'@wayofdev/commitlint-config': major
'@wayofdev/secretlint-config': major
'@wayofdev/stylelint-config': major
'@wayofdev/htmlhint-config': major
'@wayofdev/tsconfig-config': major
'@wayofdev/postcss-config': major
---

refactor: changed configs, paths, added docs
14 changes: 0 additions & 14 deletions .changeset/violet-steaks-sin.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release-or-version-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
commit: 'chore: update versions'
title: 'chore: update versions'
cwd: ${{ github.workspace }}
publish: pnpm run cs:release
publish: pnpm run cs:publish
version: pnpm run cs:version
setupGitUser: true
# Optional, might be used in conjunction with GITHUB_TOKEN to
Expand Down
22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,27 @@
],
"scripts": {
"build": "turbo build",
"clean": "run-p clean:global-cache turbo run clean --parallel",
"clean": "run-p clean:global-cache clean:turbo",
"clean:turbo": "turbo clean --parallel",
"clean:global-cache": "rimraf ./.cache",
"commit": "git-cz",
"cs:release": "pnpm publish -r",
"cs:version": "pnpm changeset version",
"cs": "changeset",
"cs:publish": "changeset publish",
"cs:release": "turbo build lint test && changeset version && changeset publish",
"cs:version": "changeset version",
"deps:check": "pnpm dlx npm-check-updates@latest --configFileName .ncurc.yml --deep --mergeConfig",
"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": "pnpm lint:md && pnpm lint:js && pnpm lint:secrets",
"lint:commits": "pnpm commitlint --from HEAD~1 --to HEAD --verbose",
"lint:fix": "turbo run lint:fix && pnpm lint:package-json",
"lint:fix": "turbo lint:fix && pnpm lint:package-json",
"lint:js": "eslint --fix **/*.js",
"lint:md": "markdownlint --fix **/*.md --ignore '**/node_modules/**' --ignore '**/CHANGELOG.md'",
"lint:package-json": "sort-package-json package.json packages/*/package.json",
"lint:secrets": "secretlint **/*",
"lint:turbo": "turbo lint",
"lint:types": "turbo run lint:types --parallel",
"lint:types": "turbo lint:types --parallel",
"lint:dist": "turbo lint:dist",
"prepare": "is-ci || husky install",
"test-unit": "turbo test-unit"
},
Expand All @@ -74,18 +78,20 @@
"lint-staged": "^13.1.1",
"markdownlint": "^0.27.0",
"markdownlint-cli": "^0.33.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.4",
"rimraf": "^4.1.2",
"secretlint": "^6.2.0",
"shell-quote": "^1.8.0",
"sort-package-json": "^2.4.1",
"turbo": "^1.7.4",
"typescript": "^4.9.5"
},
"peerDependencies": {
"actionlint": "^2.0.6",
"markdownlint": "^0.27.0",
"secretlint": "^6.2.0",
"sort-package-json": "^2.4.1",
"markdownlint": "^0.27.0"
"sort-package-json": "^2.4.1"
},
"packageManager": "pnpm@7.27.0",
"engines": {
Expand Down
67 changes: 30 additions & 37 deletions packages/browserslist-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,60 +21,57 @@

## 📄 About

Shareable configuration for [Browserslist](https://github.com/browserslist/browserslist) — a popular library for defining the target browsers for your projects. It helps you to maintain consistency across different projects and ensure that your projects support the same set of browsers.
Shareable configuration for [Browserslist](https://github.com/browserslist/browserslist) — a popular library for defining the target browsers for your projects.

This repository is used for [wayofdev](https://github.com/wayofdev) projects and can be used also by others.
It helps you maintain consistency across different projects and ensures that your projects support the same set of browsers. This configuration can be used by any project, not just projects from [wayofdev](https://github.com/wayofdev).

### → Purpose

The purpose is to provide a single, consistent configuration for all your projects. It eliminates the need to define the target browsers in each project, which saves time and reduces the risk of errors.
The purpose of this package is to provide a single, consistent configuration for all your projects, saving you time and reducing the risk of errors. Specifically, it achieves this goal by:

This package contains a pre-defined set of target browsers that are widely used, so you can include it in your projects and get started right away.

Additionally, it makes it easy to update the target browsers across all your projects when needed.
- Eliminating the need to define the target browsers in each project
- Providing a pre-defined set of widely used target browsers
- Making it easy to update the target browsers across all your projects when needed

Overall, Browserslist Config helps maintain a high-quality user experience for your users, regardless of which browsers they use.

<br>

## 💿 Installation

Add as dev-dependency to your monorepo

```bash
# Install as dev-dependency into root of monorepo
$ pnpm add -wD browserslist @wayofdev/browserslist-config
```

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:
To use `@wayofdev/browserslist-config` in your TypeScript projects within a monorepository:

```bash
.
├── .browserslistrc (root)
├── package.json (root)
├── apps
│ └── my-first-app
│ ├── package.json
│ └── ... (other app files)
└── packages
└── my-first-package
├── package.json
└── ... (other package files)
```
1. Install the package using your preferred package manager in the root of the monorepository. For example, using `pnpm`:

<br>
```bash
pnpm add -Dw browserslist @wayofdev/browserslist-config
```

### → Configure
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.

```bash
.
├── .browserslistrc (root)
├── package.json (root)
├── apps
│ └── my-first-app
│ ├── package.json
│ └── ... (other app files)
└── packages
└── my-first-package
├── package.json
└── ... (other package files)
```

1. To configure the `.browserslistrc` file, include the following line:
2. To configure the `.browserslistrc` file, include the following line:

```typescript
```js
extends @wayofdev/browserslist-config
```

This extends the `@wayofdev/browserslist-config` configuration and uses its pre-defined browser support ranges.

2. For each package or app in your monorepository that needs to use the `browserslist` package, add a `browserslist` field in the `package.json` file with the desired browser support ranges. The `package.json` file is located in either the `./packages/[package-name]` or `./apps/[app-name]` directory.
3. For each package or app in your monorepository that needs to use the `browserslist` package, add a `browserslist` field in the `package.json` file with the desired browser support ranges. The `package.json` file is located in either the `./packages/[package-name]` or `./apps/[app-name]` directory.

**For example:**

Expand All @@ -87,15 +84,12 @@ This package should be added to the root of your monorepo, where you have a file
}
```

<br>

### → Scripts

Adding the following script to your root `package.json` file makes it easier to run the `browserslist` command in your monorepository:

```bash
# Adds browserslist command
$ pnpm pkg set scripts.lint:browsers="browserslist"
pnpm pkg set scripts.lint:browsers="browserslist"
```

For `npm` users, replace `pnpm` with `npm` in the above command.
Expand All @@ -115,7 +109,6 @@ This script allows you to run the `browserslist` command by simply typing `pnpm
Based on:

- [shareable-configs](https://github.com/waldronmatt/shareable-configs) from [waldronmatt](https://github.com/waldronmatt)
- other, various best practices

Examples:

Expand Down
3 changes: 1 addition & 2 deletions packages/browserslist-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"scripts": {
"clean": "rimraf ./dist ./coverage ./tsconfig.tsbuildinfo",
"lint": "eslint --ext .ts,.js,.cjs,.mjs --cache --cache-location ../../.cache/eslint/browserslist-config.eslintcache",
"lint:fix": "eslint --ext .ts,.tsx,.js,.jsx,.mjs,.cjs,.mts,.cts --fix --cache --cache-location ../../.cache/eslint/browserslist-config.eslintcache",
"test": "echo \"No test specified\""
"lint:fix": "eslint --ext .ts,.tsx,.js,.jsx,.mjs,.cjs,.mts,.cts --fix --cache --cache-location ../../.cache/eslint/browserslist-config.eslintcache"
},
"dependencies": {
"browserslist": "^4.21.5"
Expand Down
5 changes: 5 additions & 0 deletions packages/commitlint-config/.escheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ecmaVersion": "es2020",
"module": false,
"files": "./src/**/*.js"
}
65 changes: 39 additions & 26 deletions packages/commitlint-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,14 @@ A shareable [commitlint](https://commitlint.js.org/#/) configuration for enforci

### → 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.
- Provides a set of rules to ensure that all commits in your project follow a consistent structure.
- Consistent commit messages are important for project collaboration, maintainability, and project history.
- The commitlint configuration helps 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.

<br>

## 💿 Installation

To use this configuration, you'll need to install the `@commitlint/cli` package as a devDependency in your project:

```bash
# Install as dev-dependency into root of monorepo
$ pnpm add -wD @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
Expand All @@ -55,48 +50,49 @@ This package should be added to the root of your monorepo, where you have a file
└── ... (other package files)
```

<br>
1. To use this configuration, you'll need to install this package as a devDependency in your monorepository's root:

### → Configure
```bash
pnpm add -wD @commitlint/cli @wayofdev/commitlint-config
```

1. To configure the `commitlint.config.js` file, include the following line:
2. To configure the `commitlint.config.js` file, include the following line:

```javascript
```js
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`.
This extends the `@wayofdev/commitlint-config` and uses its [pre-defined configuration](https://github.com/wayofdev/npm-shareable-configs/blob/master/packages/commitlint-config/index.js).

2. Install Husky
Alternatively the configuration can be defined in a `commitlint.config.js`, `.commitlintrc.js`, `.commitlintrc`, `.commitlintrc.json`, `.commitlintrc.yml` file

Install `husky` as devDependency, a handy git hook helper available on npm.
3. Install [Husky](https://typicode.github.io/husky/#/) in your monorepository as devDependency. Husky is 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
4. Add commit-msg hook:

```bash
$ npx husky add .husky/commit-msg 'pnpm commitlint --edit "${1}"'
npx husky add .husky/commit-msg 'pnpm commitlint --edit "${1}"'
```

4. Add scripts to `package.json`
5. 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"
pnpm pkg set scripts.lint:commits="pnpm commitlint --from HEAD~1 --to HEAD --verbose"

pnpm pkg set scripts.prepare="is-ci || husky install"
```

<br>
<br>

## 💻 Usage

Expand All @@ -119,7 +115,9 @@ This will check your last commit and return an error if invalid or a positive ou

### → Test the hook

You can test the hook by simply committing. You should see something like this if everything works.
You can test the hook by simply committing. If the commit message is valid, the commit will go through, otherwise you will see an error message.

Here's an example of what the error message would look like if your commit message doesn't meet the required format:

```bash
$ git commit -m "foo: this will fail"
Expand All @@ -134,9 +132,18 @@ No staged files match any of provided globs.
husky > commit-msg hook failed (add --no-verify to bypass)
```

If your commit message meets the required format, you should see a message like this:

```bash
$ git commit -m "feat: add new feature"
husky > commit-msg (node v10.1.0)
[master 9d41607] feat: add new feature
1 file changed, 1 insertion(+)
```

<br>

## 🛠️ Extending
## 🧩 Extending

This shows, how config can be extended with your custom rules.

Expand Down Expand Up @@ -165,6 +172,11 @@ Based on:

- [shareable-configs](https://github.com/waldronmatt/shareable-configs) from [waldronmatt](https://github.com/waldronmatt)

Related projects:

- [husky](https://typicode.github.io/husky/#/)
- [lint-staged](https://github.com/okonet/lint-staged)

Guides:

- [Official commitlint setup guide](https://commitlint.js.org/#/./guides-local-setup?id=guides-local-setup)
Expand All @@ -188,3 +200,4 @@ We are open to all kinds of contributions. If you want to:
- 👨‍💻 Contribute to the code

You are more than welcome. Before contributing, kindly check our [guidelines](https://next-starter-tpl-docs.wayof.dev/contribution).

5 changes: 4 additions & 1 deletion packages/commitlint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@
"scripts": {
"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"
"lint:dist": "es-check -v",
"lint:fix": "eslint --ext .ts,.tsx,.js,.jsx,.mjs,.cjs,.mts,.cts --fix --cache --cache-location ../../.cache/eslint/commitlint-config.eslintcache",
"lint:types": "tsc --project tsconfig.json --noEmit"
},
"dependencies": {
"@commitlint/config-conventional": "^17.4.2"
},
"devDependencies": {
"es-check": "^7.1.0",
"rimraf": "^4.1.2"
},
"peerDependencies": {
Expand Down
Loading

0 comments on commit 6088d40

Please sign in to comment.