Giter VIP home page Giter VIP logo

wayofdev / npm-shareable-configs Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 1.0 2.71 MB

Shareable configurations with fully automated package publishing to NPM Registry.

Home Page: https://wayof.dev

License: MIT License

JavaScript 89.36% Makefile 9.37% Shell 1.27%
browserslist-config commitlint-config eslint-config htmlhint-config lint-staged-config markdownlint-config monorepo pnpm pnpm-workspace postcss-config

npm-shareable-configs's Introduction


Logo for light mode Logo for dark mode


Build Status Software License

NPM Shareable Configs

This repository shareable contains configurations with fully automated package publishing to the NPM Registry.

๐Ÿ“„ About

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.

โ†’ Purpose

  • 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.

๐Ÿš€ Featured Packages

Tool Package Version Description
browserslist browserslist-config npm Share target browsers between different front-end tools, like Autoprefixer, Stylelint and babel-preset-env
commitlint commitlint-config npm Helps your team adhere to a commit convention.
eslint eslint-config-bases npm 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 npm Static code analysis tool you need for your HTML.
lint-staged lint-staged-config npm Run linters on git staged files.
markdownlint markdownlint-config npm A Node.js style checker and lint tool for Markdown/CommonMark files.
postcss postcss-config npm Add vendor prefixes to CSS rules using values from Can I Use. Autoprefixer will use the
secretlint secretlint-config npm Pluggable linting tool to prevent committing credential
stylelint stylelint-config npm Linter that helps you avoid errors and enforce conventions in your styles
tsconfig tsconfig-config npm Typescript configuration for projects

๐Ÿ’ฟ Installation

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)

โ†’ Root Level Configuration

To install the necessary tools and configurations for your monorepo, follow these steps:

  1. 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
  2. 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
  3. 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 commitlint configuration package:

      $ pnpm add -Dw \
        @commitlint/cli \
        @wayofdev/commitlint-config
    • Follow the configuration instructions in the commitlint-config README.md.

    eslint:

    • Install the eslint configuration package:

      $ pnpm add -Dw \
      	eslint \
      	@wayofdev/eslint-config-bases
    • Follow the configuration instructions in the commitlint-config README.md.

    secretlint:

    • Install the secretlint configuration package:

      $ pnpm add -Dw \
        @secretlint \
        @wayofdev/secretlint-config
    • Follow the configuration instructions in the secretlint-config README.md.

    tsconfig:

    • Install the tsconfig configuration package:

      $ pnpm add -Dw \
        typescript \
        @wayofdev/tsconfig-config
    • Follow the configuration instructions in the tsconfig-config README.md.

    lint-staged:

    • Install the lint-staged configuration package:

      $ pnpm add -Dw \
        lint-staged \
        @wayofdev/lint-staged-config
    • Follow the configuration instructions in the lint-staged-config README.md.

    markdownlint:

    • Install the markdownlint configuration package:

      $ pnpm add -Dw \
        markdownlint \
        markdownlint-cli \
        @wayofdev/markdownlint-config
    • Follow the configuration instructions in the markdownlint-config README.md.


โ†’ Per App/Package Configuration

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.

  1. Install @wayofdev/eslint-config-bases to all apps and packages in monorepo. Following tree structure, from Installation section

    eslint:

    $ 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-config README.md.

  2. Install @wayofdev/postcss-config in apps or packages, where it needs to be used. We will install it to apps/web, as it contains NextJS application, and we want to add TailwindCSS support, which requires postcss:

    postcss:

    $ pnpm \
      --filter="@wayofdev/web" \
      add -D postcss @wayofdev/postcss-config

    Follow the configuration instructions in the postcss-config README.md.

  3. Install @wayofdev/stylelint-config in apps or packages, where CSS and/or SCSS is used. We will install it to apps/web.

    stylelint:

    $ pnpm \
      --filter="@wayofdev/web" \
      add -D stylelint @wayofdev/stylelint-config

    Follow the configuration instructions in the stylelint-config README.md.

  4. Install @wayofdev/htmlhint-config in apps or packages, where HTML is used.

    htmlhint:

    $ pnpm \
      --filter="@wayofdev/web" \
      add -D htmlhint @wayofdev/htmlhint-config

    Follow the configuration instructions in the htmlhint-config README.md.

  5. Install @wayofdev/browserslist-config in apps or packages, where you need to check projects against browser compatability.

    browserslist:

    $ pnpm \
      --filter="@wayofdev/web" \
      add -D browserslist @wayofdev/browserslist-config

    Follow the configuration instructions in the browserslist-config README.md.

Check out Turbo Guide about linting in mono-repositories for more information.


โš™๏ธ Configuration

โ†’ Commitlint

Commitlint is a tool that ensures that your commit messages meet certain standards. To configure the commitlint.config.js file, follow these steps:

  1. Create an empty commitlint.config.js file:

    touch commitlint.config.js
  2. 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-config package, which provides a set of commonly used commit message rules. You can customize these rules by modifying the commitlint.config.js file.

โ†’ Lint-Staged

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:

  1. In the root directory of your project, create the file lint-staged.config.js:

    touch lint-staged.config.js
  2. 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

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:

  1. Add pnpm scripts to your package.json file:

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

    This will add a prepare script that will run the husky install command when you run pnpm install.

  2. Run the prepare command once to configure Husky:

    pnpm run prepare
  3. 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-staged on the files that have been staged in Git before you make a commit.

  4. Add a commit-msg hook that runs commitlint:

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

    This will run commitlint on 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.


๐Ÿงช Testing

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

๐Ÿค License

Licence

FOSSA Status


๐Ÿงฑ Useful Resources


๐Ÿ™†๐Ÿผโ€โ™‚๏ธ Author Information

This repository was created in 2022 by lotyp / wayofdev.


๐Ÿซก Contributors

Contributors

Contributors

๐Ÿค‘ Sponsors

Reproto Logo
Reproto

๐ŸŽ–๏ธ Financial Support
VarsityBase Logo
VarsityBase

๐ŸŽ–๏ธ Financial Support
Vercel Logo
Vercel

โ˜๏ธ Infrastructure Support
Sentry Logo
Sentry

โ˜๏ธ Infrastructure Support
ZenHub Logo
ZenHub

โ˜๏ธ Infrastructure Support

npm-shareable-configs's People

Contributors

github-actions[bot] avatar igomur avatar lotyp avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

fossabot

npm-shareable-configs's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @changesets/cli to v2.27.5
  • chore(deps): update dependency lint-staged to v15.2.5
  • chore(deps): update dependency rimraf to v5.0.7
  • chore(deps): update dependency rimraf to v5.0.7
  • chore(deps): update pnpm to v8.15.8
  • fix(deps): update dependency @rushstack/eslint-patch to v1.10.3
  • fix(deps): update dependency eslint-plugin-react to v7.34.2
  • fix(deps): update secretlint monorepo to v8.2.4 (@secretlint/secretlint-rule-preset-recommend, secretlint)
  • chore(deps): update dependency @types/node to v20.13.0
  • chore(deps): update dependency es-check to v7.2.1
  • chore(deps): update dependency npm-run-all2 to v6.2.0
  • chore(deps): update dependency prettier to v3.3.0
  • chore(deps): update react monorepo (@types/react, @types/react-dom, eslint-plugin-react-hooks, react, react-dom)
  • fix(deps): update dependency @tanstack/eslint-plugin-query to v5.35.6
  • fix(deps): update dependency eslint-plugin-jest to v28.5.0
  • fix(deps): update dependency eslint-plugin-promise to v6.2.0
  • fix(deps): update dependency eslint-plugin-regexp to v2.6.0
  • fix(deps): update dependency eslint-plugin-tailwindcss to v3.17.0
  • fix(deps): update dependency markdownlint-cli to v0.41.0
  • fix(deps): update dependency prettier to v3.3.0
  • chore(deps): update dependency eslint to v9
  • fix(deps): update dependency eslint-plugin-sonarjs to v1
  • fix(deps): update dependency eslint-plugin-unicorn to v53
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/apply-labels.yml
.github/workflows/auto-merge-release.yml
.github/workflows/ci-packages.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/cache v4
  • wagoid/commitlint-github-action v6
.github/workflows/create-arch-diagram.yml
.github/workflows/create-changesets-release.yml
.github/workflows/shellcheck.yml
npm
package.json
  • @changesets/changelog-github 0.5.0
  • @changesets/cli 2.27.1
  • @commitlint/cli 19.2.2
  • @commitlint/config-conventional 19.2.2
  • @types/node 20.12.7
  • @types/prettier 3.0.0
  • @types/shell-quote 1.7.5
  • actionlint 2.0.6
  • commitizen 4.3.0
  • eslint 8.57.0
  • husky 9.0.11
  • is-ci 3.0.1
  • lint-staged 15.2.2
  • markdownlint 0.34.0
  • markdownlint-cli 0.39.0
  • npm-run-all2 6.1.2
  • prettier 3.2.5
  • rimraf 5.0.5
  • secretlint 8.2.3
  • shell-quote 1.8.1
  • sort-package-json 2.10.0
  • turbo 1.13.2
  • typescript 5.4.5
  • actionlint 2.0.6
  • markdownlint 0.34.0
  • secretlint 8.2.3
  • sort-package-json 2.10.0
  • node >=18.0.0
  • pnpm 8.15.7
packages/browserslist-config/package.json
  • browserslist ^4.22.2
  • rimraf ^5.0.5
packages/commitlint-config/package.json
  • @commitlint/config-conventional 19.2.2
  • @types/node ^20.10.7
  • es-check ^7.1.1
  • rimraf ^5.0.5
  • @commitlint/cli >= 17
packages/eslint-config-bases/package.json
  • @html-eslint/eslint-plugin ^0.24.0
  • @html-eslint/parser ^0.24.0
  • @rushstack/eslint-patch ^1.6.1
  • @tanstack/eslint-plugin-query ^5.17.7
  • @testing-library/jest-dom ^6.2.0
  • @testing-library/react ^15.0.0
  • @typescript-eslint/eslint-plugin ^7.0.0
  • @typescript-eslint/parser ^7.0.0
  • eslint-config-prettier ^9.1.0
  • eslint-import-resolver-typescript ^3.6.1
  • eslint-plugin-import ^2.29.1
  • eslint-plugin-jest ^28.0.0
  • eslint-plugin-jest-dom ^5.1.0
  • eslint-plugin-jest-formatting ^3.1.0
  • eslint-plugin-jsx-a11y ^6.8.0
  • eslint-plugin-mdx ^3.0.0
  • eslint-plugin-prettier ^5.1.2
  • eslint-plugin-promise ^6.1.1
  • eslint-plugin-react ^7.33.2
  • eslint-plugin-react-hooks ^4.6.0
  • eslint-plugin-regexp ^2.2.0
  • eslint-plugin-security ^3.0.0
  • eslint-plugin-sonarjs ^0.25.0
  • eslint-plugin-storybook ^0.8.0
  • eslint-plugin-tailwindcss ^3.13.1
  • eslint-plugin-testing-library ^6.2.0
  • eslint-plugin-unicorn ^52.0.0
  • prettier ^3.1.1
  • @graphql-eslint/eslint-plugin ^3.20.1
  • @testing-library/jest-dom ^6.2.0
  • @testing-library/react ^15.0.0
  • @types/jest ^29.5.11
  • @types/node ^20.10.7
  • @types/prettier ^3.0.0
  • @types/react ^18.2.47
  • @types/react-dom ^18.2.18
  • es-check ^7.1.1
  • eslint ^8.56.0
  • graphql ^16.8.1
  • react ^18.2.0
  • react-dom ^18.2.0
  • rimraf ^5.0.5
  • tailwindcss ^3.4.1
  • typescript ^5.3.3
  • @graphql-eslint/eslint-plugin ^3.17.0
  • eslint ^8.45.0
  • graphql ^16.6.0
  • prettier ^3.0.0
  • react ^18.2.0
  • react-dom ^18.2.0
  • tailwindcss ^3.2.7
  • typescript ^5.1.6
packages/htmlhint-config/package.json
  • rimraf ^5.0.5
  • htmlhint >= 1
packages/lint-staged-config/package.json
  • @types/jest ^29.5.11
  • @types/node ^20.10.7
  • @types/prettier ^3.0.0
  • @types/react ^18.2.47
  • @types/react-dom ^18.2.18
  • es-check ^7.1.1
  • lint-staged >= 13
packages/markdownlint-config/package.json
  • markdownlint-cli ^0.39.0
  • markdownlint >= 0
packages/postcss-config/package.json
  • autoprefixer ^10.4.16
  • postcss ^8.4.33
  • postcss-100vh-fix ^1.0.2
  • postcss-cli ^11.0.0
  • postcss-flexbugs-fixes ^5.0.2
  • postcss-normalize ^10.0.1
  • postcss-preset-env ^9.3.0
  • postcss-reporter ^7.0.5
  • @types/postcss-reporter ^7.0.5
  • es-check ^7.1.1
  • postcss >= 8
  • sanitize.css >= 13
  • tailwindcss >= 3
packages/secretlint-config/package.json
  • @secretlint/secretlint-rule-preset-recommend ^8.1.0
  • rimraf ^5.0.5
  • secretlint >= 6
packages/stylelint-config/package.json
  • @double-great/stylelint-a11y ^3.0.0
  • stylelint ^16.1.0
  • stylelint-config-recommended ^14.0.0
  • stylelint-config-standard ^36.0.0
  • stylelint-config-standard-scss ^13.0.0
  • stylelint-high-performance-animation ^1.10.0
  • stylelint-no-unsupported-browser-features ^8.0.0
  • stylelint-order ^6.0.4
  • @types/node ^20.10.7
  • es-check ^7.1.1
  • stylelint ^14 || ^15 || ^16
packages/tsconfig-config/package.json
  • typescript ^5

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: renovate.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid configuration option: mergeStrategy, Invalid configuration option: requireStatusChecks, Invalid configuration option: statusCheckContexts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.