This repository shareable contains configurations with fully automated package publishing to the NPM Registry.
This is a mono-repository that contains a collection of separate, shareable npm packages that provide various configuration files for commonly used tools in modern web development.
-
This repository serves the following purposes:
- Provides a centralized location for managing configuration files for commonly used tools in web development.
- Allows for easy sharing and reuse of configurations across multiple projects.
- Ensures consistency and adherence to best practices in your code.
- Saves time by providing pre-configured packages that work well together.
- Can improve the quality of your code and streamline your development workflow.
- Suitable for both beginner and experienced web developers.
| Tool | Package | Version | Description |
|---|---|---|---|
| browserslist | browserslist-config | Share target browsers between different front-end tools, like Autoprefixer, Stylelint and babel-preset-env | |
| commitlint | commitlint-config | Helps your team adhere to a commit convention. | |
| eslint | eslint-config-bases | Statically analyzes your code to quickly find problems. It is built into most text editors and you can run ESLint as part of your continuous integration pipeline. | |
| htmlhint | htmlhint-config | Static code analysis tool you need for your HTML. | |
| lint-staged | lint-staged-config | Run linters on git staged files. | |
| markdownlint | markdownlint-config | A Node.js style checker and lint tool for Markdown/CommonMark files. | |
| postcss | postcss-config | Add vendor prefixes to CSS rules using values from Can I Use. Autoprefixer will use the | |
| secretlint | secretlint-config | Pluggable linting tool to prevent committing credential | |
| stylelint | stylelint-config | Linter that helps you avoid errors and enforce conventions in your styles | |
| tsconfig | tsconfig-config | Typescript configuration for projects |
Looking for an already configured starter template? Check out our project: wayofdev/next-starter-tpl — Fully configured, ready-to-start template with everything already configured for you!
This section covers installation when configs contained in this repository are used in a monorepo type of project. Here's an example structure of a monorepo:
├── package.json (root)
├── apps
│ ├── docs # nextra app
│ │ ├── package.json # @wayofdev/docs
│ │ └── ... (other app files)
│ └── web # nextjs app
│ ├── package.json # @wayofdev/web
│ └── ... (other app files)
└── packages
├── ui # shared react ui components package
│ ├── package.json # @wayofdev/ui
│ └── ... (other package files)
└── common-i18n # common i18n package
├── package.json # @wayofdev/common-i18n
└── ... (other package files)To install the necessary tools and configurations for your monorepo, follow these steps:
-
Install the required tools as dev-dependencies inside the root of your monorepo:
$ pnpm add -Dw \ husky \ is-ci \ npm-run-all \ rimraf \ sort-package-json \ turbo \ prettier
-
Install changesets in the root of your monorepo to manage your versioning and changelogs with a focus on monorepos:
$ pnpm add -Dw \ @changesets/cli \ @changesets/changelog-github
-
Install the necessary config packages with their dependencies that are needed at the root level of your monorepo. Here are some examples:
commitlint:-
Install the
commitlintconfiguration package:$ pnpm add -Dw \ @commitlint/cli \ @wayofdev/commitlint-config
-
Follow the configuration instructions in the
commitlint-configREADME.md.
eslint:-
Install the
eslintconfiguration package:$ pnpm add -Dw \ eslint \ @wayofdev/eslint-config-bases
-
Follow the configuration instructions in the
commitlint-configREADME.md.
secretlint:-
Install the
secretlintconfiguration package:$ pnpm add -Dw \ @secretlint \ @wayofdev/secretlint-config
-
Follow the configuration instructions in the
secretlint-configREADME.md.
tsconfig:-
Install the
tsconfigconfiguration package:$ pnpm add -Dw \ typescript \ @wayofdev/tsconfig-config
-
Follow the configuration instructions in the
tsconfig-configREADME.md.
lint-staged:-
Install the
lint-stagedconfiguration package:$ pnpm add -Dw \ lint-staged \ @wayofdev/lint-staged-config
-
Follow the configuration instructions in the
lint-staged-configREADME.md.
markdownlint:-
Install the
markdownlintconfiguration package:$ pnpm add -Dw \ markdownlint \ markdownlint-cli \ @wayofdev/markdownlint-config
-
Follow the configuration instructions in the
markdownlint-configREADME.md.
-
In addition, this repository provides a guide for managing linting in a monorepo, which can be tricky. Most workspaces are likely to contain code that needs to be linted, making it difficult to determine the most efficient way to do so.
To address this, we propose a method that plays to Turborepo's strengths: running lint tasks inside the workspaces, not from root, and sharing as much config as possible between workspaces.
By following this guide, you can ensure that your code is consistently and thoroughly linted, while also leveraging the benefits of a monorepo. This guide is suitable for both beginner and experienced web developers.
-
Install
@wayofdev/eslint-config-basesto allappsandpackagesin monorepo. Following tree structure, from Installation sectioneslint:$ pnpm \ --filter="@wayofdev/web" \ --filter="@wayofdev/docs" \ --filter="@wayofdev/ui" \ --filter="@wayofdev/common-i18n" \ add -D eslint @wayofdev/eslint-config-bases
Follow the configuration instructions in the
eslint-configREADME.md. -
Install
@wayofdev/postcss-configin apps or packages, where it needs to be used. We will install it toapps/web, as it contains NextJS application, and we want to add TailwindCSS support, which requirespostcss:postcss:$ pnpm \ --filter="@wayofdev/web" \ add -D postcss @wayofdev/postcss-configFollow the configuration instructions in the
postcss-configREADME.md. -
Install
@wayofdev/stylelint-configin apps or packages, where CSS and/or SCSS is used. We will install it toapps/web.stylelint:$ pnpm \ --filter="@wayofdev/web" \ add -D stylelint @wayofdev/stylelint-configFollow the configuration instructions in the
stylelint-configREADME.md. -
Install
@wayofdev/htmlhint-configin apps or packages, where HTML is used.htmlhint:$ pnpm \ --filter="@wayofdev/web" \ add -D htmlhint @wayofdev/htmlhint-configFollow the configuration instructions in the
htmlhint-configREADME.md. -
Install
@wayofdev/browserslist-configin apps or packages, where you need to check projects against browser compatability.browserslist:$ pnpm \ --filter="@wayofdev/web" \ add -D browserslist @wayofdev/browserslist-configFollow the configuration instructions in the
browserslist-configREADME.md.
Check out Turbo Guide about linting in mono-repositories for more information.
Commitlint is a tool that ensures that your commit messages meet certain standards. To configure the commitlint.config.js file, follow these steps:
-
Create an empty
commitlint.config.jsfile:touch commitlint.config.js
-
Paste the following code into the file:
$ tee -a commitlint.config.js <<EOF module.exports = { extends: ["@wayofdev/commitlint-config"], } EOF
This will extend the
@wayofdev/commitlint-configpackage, which provides a set of commonly used commit message rules. You can customize these rules by modifying thecommitlint.config.jsfile.
Lint-Staged is a tool that allows you to run linters on only the files that have been staged in Git. To configure Lint-Staged, follow these steps:
-
In the root directory of your project, create the file
lint-staged.config.js:touch lint-staged.config.js
-
Add the following contents to
lint-staged.config.js:// @ts-check const { concatFilesForPrettier, jsonRules, secretsRules, mdRules, yamlRules, } = require('@wayofdev/lint-staged-config') const rules = { ...jsonRules, ...yamlRules, ...secretsRules, ...mdRules, '**/*.{js,jsx,cjs,mjs,ts,tsx,mts,cts}': filenames => { return [`prettier --write ${concatFilesForPrettier(filenames)}`] }, } module.exports = rules
Husky is a tool that allows you to set up Git hooks, which are scripts that run automatically when certain Git commands are executed. To configure Husky, follow these steps:
-
Add pnpm scripts to your
package.jsonfile:pnpm pkg set scripts.prepare="is-ci || husky install"
This will add a
preparescript that will run thehusky installcommand when you runpnpm install. -
Run the
preparecommand once to configure Husky:pnpm run prepare
-
Add a pre-commit hook that runs
lint-staged:pnpm husky add .husky/pre-commit "pnpm lint-staged --verbose --concurrent false"This will run
lint-stagedon the files that have been staged in Git before you make a commit. -
Add a commit-msg hook that runs
commitlint:pnpm husky add .husky/commit-msg 'pnpm commitlint --edit "${1}"'This will run
commitlinton the commit message that you write before you make a commit.
By following these steps, you can ensure that your commits meet certain standards and that your code is properly formatted before you make a commit.
You can check Makefile or package.json to get full list of commands for local testing. For testing, you can use these commands to test:
make test-
This repository is based on:
-
Other monorepo examples:
- base-configs - A collection of base configs for code quality and linting tools.
- threepio - Shareable configurations that are used within the Galaxy.
- medly - Share common configurations across different projects.
- code-quality-tools - Shareable configurations for various coding-style/best practices/lint tools.
- frontend-configs - NPM-Published front-end shareable configurations.
This repository was created in 2022 by lotyp / wayofdev.
|
Reproto 🎖️ Financial Support |
![]() VarsityBase 🎖️ Financial Support |
Vercel ☁️ Infrastructure Support |
Sentry ☁️ Infrastructure Support |
ZenHub ☁️ Infrastructure Support |


