Skip to content

Automation hub repository holding lint configuration files in order to keep it centralized for CI and IDEs

Notifications You must be signed in to change notification settings

br-automation-com/ahub-lint-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ahub-lint-config

A centralized repository for Automation Hub lint configurations, ensuring consistent commit message conventions and linting rules across multiple projects and CI systems. Lint configs are published as a public npm package so that they can be easily used in both CI pipelines and local development setups.


Conventional Commits Linter

Goal: Enforce Conventional Commits to keep commit messages organized and meaningful.

Why Conventional Commits?

  1. Standardized commit messages improve readability and automation.
  2. Automatic versioning and changelog generation become simpler.
  3. Consistent commit messages help the entire team quickly understand the nature of changes.

Usage

1. GitHub Actions

You can fail your PR or push build if a commit doesn’t follow the conventional commit specification. Here’s a sample job that uses @ahub-public/commitlint-config to verify commit messages:

commitlint:
  runs-on: ubuntu-latest
  steps:
    - name: Check out code
      uses: actions/checkout@v3
      with:
        fetch-depth: 0

    - name: Install Node.js
      uses: actions/setup-node@v4
      with:
        node-version: 20

    - name: Install commitlint & public ahub lint config
      run: |
        npm install commitlint@latest @commitlint/config-conventional @ahub-public/commitlint-config
        # Dynamically create a .commitlintrc.js file that extends your config
        echo "module.exports = { extends: ['@ahub-public/commitlint-config'] };" > .commitlintrc.js

    - name: Validate current commit (last commit) with commitlint
      if: github.event_name == 'push'
      run: npx commitlint --last --verbose

    - name: Validate PR commits with commitlint
      if: github.event_name == 'pull_request'
      run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

What’s happening:

We install Commitlint, the conventional config, and our ahub config from npm. We generate a temporary .commitlintrc.js extending @ahub-public/commitlint-config. Depending on whether it’s a push or a pull request, we lint the appropriate commits.

2. Local Usage (Pre-Commit Hook with Husky)

To catch invalid commit messages before pushing to GitHub, you can install Husky to manage local Git hooks.

Install Husky and commitlint in your project:

npm install -D husky commitlint @commitlint/config-conventional @ahub-public/commitlint-config

Add a local .commitlintrc.js referencing the ahub config:

// .commitlintrc.js
module.exports = {
  extends: ['@ahub-public/commitlint-config']
};

Create a commit-msg hook:

npx husky add .husky/commit-msg "npx commitlint --edit $1"
git add .husky/commit-msg

Now, whenever you run git commit, Husky calls Commitlint to validate the message. If it doesn’t pass, it rejects the commit locally.

Additional Info

Benefits:

  • Automated release notes and versioning
  • Streamlined collaboration and clearer commit history

Happy Linting!
Help your team produce consistent commit messages for cleaner repos and smoother release workflows. Feel free to submit issues or pull requests to this repository if you have ideas or improvements.

About

Automation hub repository holding lint configuration files in order to keep it centralized for CI and IDEs

Resources

Stars

Watchers

Forks

Packages

No packages published