Giter Site home page Giter Site logo

whizark / commitlint-config-cz Goto Github PK

View Code? Open in Web Editor NEW
33.0 3.0 9.0 546 KB

:gear: commitlint sharable configuration, automatically converts/merges your cz-customizable (commitizen) config.

License: MIT License

JavaScript 100.00%
commitizen conventional-changelog conventional-changelog-lint cz-cli cz-customizable commitlint commitlint-config conventional-commits

commitlint-config-cz's Introduction

commitlint-config-cz

npm Build Status Build status Coverage Status

commitlint sharable configuration files for cz-customizable (customizable Commitizen adapter for conventional commits and conventional changelog).

You can now consistently manage your commit types/scopes for cz-customizable and commitlint in one place.

commitlint-config-cz merges {types,scopes,scopeOverrides} (cz-customizable config) with rules.{type-enum,scope-enum} (commitlint config) and includes some modules and API for config conversion.

Supported Config

commitlint-config-cz use only one config in the following order of precedence.

  1. config.cz-customizable.config in package.json.
  2. .cz-config.js in your package root (supported by cz-customizable).

Installation

  1. Install & setup (commitizen &) cz-customizable.

  2. Install commitlint.

  3. Install commitlint-config-cz as a local dependency.

    npm install commitlint-config-cz --save-dev

Usage

Extend your commitlint config by cz in commitlint.config.js.

module.exports = {
    extends: [
        'other-config',
        'cz'
    ]
};

Modules & API

commitlint-config-cz includes some modules and API for config conversion.

config.js

Gets the converted commitlint config from the cz-customizable config which is defined in package.json or .cz-config.js in your package root.

const config = require('commitlint-config-cz/lib/config')();

get(pathOrCzConfig: string | Object, defaultConfig?: Object): Object

Gets the commitlint config from a path to config file.

const getConfig = require('commitlint-config-cz/lib/config').get;

// From a path.
const config = getConfig('path/to/.cz-config.js');
const getConfig = require('commitlint-config-cz/lib/config').get;
const czConfig  = { /* `cz-customizable` config object. */ };

// From a `cz-customizable` config object.
const config = getConfig(czConfig);
const getConfig     = require('commitlint-config-cz/lib/config').get;
const czConfig      = { /* `cz-customizable` config object. */ };
const defaultConfig = {  // The default `commitlint` config.
    rules: {
        'scope-enum': [  // rule
            2,           // [1] level
            'always',    // [2] applicability
            [],          // [3] value
        ],
        'type-enum' : [  // rule
            2,           // [1] level
            'always',    // [2] applicability
            [],          // [3] value
        ],
    },
};

// Converts and merges the `cz-customizable` config with the default `commitlint` config.
const config = getConfig(czConfig, defaultConfig);
  1. If cz-customizable config has scopes, scopeOverrides or types field, the value(s) [3] of the default commitlint config is/are REPLACED by converted value(s).
    Level [1] and applicability [2] remain as they are.
  2. scope-enum rule or/and type-enum rule is/are REMOVED, if its value is an empty array.

cz-config.js

Gets the cz-customizable config as an object from package.json or .cz-config.js in your package root.

const czConfig = require('commitlint-config-cz/lib/cz-config')();

get(path: string): Object

Gets the cz-customizable config as an object from a path.

const getCzConfig = require('commitlint-config-cz/lib/cz-config').get;

const czConfig = getCzConfig('path/to/.cz-config.js');

scopes.js

Gets the value for scope-enum rule from package.json or .cz-config.js in your package root.

const scopes = require('commitlint-config-cz/lib/scopes')();

get(czConfig: Object): string[]

Gets the value for scope-enum rule from a cz-customizable config object.

const getScopes = require('commitlint-config-cz/lib/scopes').get;
const czConfig  = { /* cz-customizable config object. */ };

const scopes = getScopes(czConfig);

types.js

Gets the value for type-enum rule from package.json or .cz-config.js in your package root.

const types = require('commitlint-config-cz/lib/types')();

get(czConfig: Object): string[]

Gets the value for type-enum rule from package.json or cz-customizable config object.

const getTypes = require('commitlint-config-cz/lib/types').get;
const czConfig = { /* `cz-customizable` config object. */ };

const types = getTypes(czConfig);

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.