Coder Social home page Coder Social logo

hyiso / commitlint Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 3.0 148 KB

commitlint - Lint commit messages for Dart and Flutter projects

Home Page: https://hyiso.github.io/commitlint/

License: Apache License 2.0

Dart 99.57% Shell 0.43%
commit commit-conventions commit-hooks commit-message commitlint dart dart-library dart-package flutter flutter-apps

commitlint's Introduction

commitlint

Pub Version popularity likes CI

Dart version commitlint - A tool to lint commit messages. (Inspired by JavaScript commitlint)

commitlint lint commit messages to satisfy conventional commit format

commitlint helps your team adhere to a commit convention. By supporting pub-installed configurations it makes sharing of commit conventions easy.

About Package Name

Because a package commit_lint already exists (not in active development), the name commitlint can't be used according to Pub's naming policy. So commitlint_cli is used currently.

Getting started

Install

Add commitlint_cli to your dev_dependencies in pubspec.yaml

# Install commitlint_cli
dart pub add --dev commitlint_cli

Configuration

# Simply use configuration of a package
echo "include: package:commitlint_cli/commitlint.yaml" > commitlint.yaml

You can also customize your configuration in commitlint.yaml

# Inherit configuration of a package
include: package:commitlint_cli/commitlint.yaml

# Custom rules
rules:
  type-case:
    - 2
    - always
    - 'upper-case'

# Whether commitlint uses the default ignore rules.
defaultIgnores: true
# Pattern that matches commit message if commitlint should ignore the given message.
ignores:
  - r'^fixup'

Test

# Lint from stdin
echo 'foo: bar' | dart run commitlint_cli
⧗  input: type: add docs
✖  type must be one of [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test] type-enum

✖  found 1 errors, 0 warnings

Note: output on successful commit will be omitted, you can use the VERBOSE=true env to get positive output. (Functionality of verbose)

# Output on successful commit will be omitted
echo 'feat: test message' | dart run commitlint_cli
# Verbse Output on successful commit
echo 'feat: test message' | VERBOSE=true dart run commitlint_cli

Setup git hook

With husky (a tool for managing git hooks), commitlint cli can be used in commmit-msg git hook

Set commit-msg hook:

dart pub add --dev husky
dart run husky install
dart run husky set .husky/commit-msg 'dart run commitlint_cli --edit "$1"'

Make a commit:

git add .
git commit -m "Keep calm and commit"
# `dart run commitlint_cli --edit "$1"` will run

To get the most out of commitlint you'll want to automate it in your project lifecycle. See our Setup guide for next steps.

Documentation

See documention

  • Guides - Common use cases explained in a step-by-step pace
  • Concepts - Overarching topics important to understand the use of commitlint
  • Reference - Mostly technical documentation

commitlint's People

Contributors

dependabot[bot] avatar hyiso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

commitlint's Issues

Success prints empty line

When the tool succeeds an empty line is printed. It's a bit ugly, especially if you use a git hook

Support body in commit message

A commit body is free-form and MAY consist of any number of newline separated paragraphs.

Currently a body in a commit message breaks the ci while the local git hook succeds

How to use it in Github Actions?

Hi, I'm trying to use commitlint in Github Actions to validate commit messages in the CI. For some reason I can't get it to fail when it should. The current workflow is at nextcloud/neon@a32ce68. I was able to get it working locally with https://github.com/nektos/act when using --from=main --to=@, but that also didn't work on Github Actions. Can someone help me get this working? I'm not sure if the workflow is the problem or if there is a bug in this tool.

Ignore fixup commits

When using the commit-msg hook it would be nice to ignore fixup commits. For CI purposes I see that it could make sense to block them since you don't want to merge fixup commits, but that's not the goal of this tool.

My workaround for this is just using this as the hook: sed "s/^fixup! //" < "$1" | dart run commitlint_cli

Add `references-empty` rule

Hi!

In the JavaScript version of commitlint, there is a rule references-empty that can check for ticket numbers like:

feat: foo bar 

#3

or

feat: foo bar

PROJ-23

It would be nice, if you can support those as well.

Thanks! :)

Optional parts like body, footer

Hi,

is it possible to set rules for optional parts?

For example it should be optional to add a body, but if a body is added body-leading-blank should be enforced.

When I tried setting this up there is always an error when there is no body.

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.