{"id":28335048,"url":"https://github.com/mridang/commitlint-plugin-conditionals","last_synced_at":"2026-03-01T16:34:07.597Z","repository":{"id":294676921,"uuid":"987651135","full_name":"mridang/commitlint-plugin-conditionals","owner":"mridang","description":"A commitlint plugin to enable conditional application of linting rules based on various commit attributes, such as author patterns or message content.","archived":false,"fork":false,"pushed_at":"2025-11-10T02:32:33.000Z","size":247,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-10T04:18:39.044Z","etag":null,"topics":["release-automation","semantic-release","semantic-release-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@mridang/commitlint-plugin-conditionals","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mridang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-21T11:41:02.000Z","updated_at":"2025-10-24T08:51:24.000Z","dependencies_parsed_at":"2025-05-21T15:57:48.358Z","dependency_job_id":"f4082992-b28c-4321-a11e-0f0fe0a9ff6c","html_url":"https://github.com/mridang/commitlint-plugin-conditionals","commit_stats":null,"previous_names":["mridang/commitlint-conditionals","mridang/commitlint-plugin-conditionals"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/mridang/commitlint-plugin-conditionals","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fcommitlint-plugin-conditionals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fcommitlint-plugin-conditionals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fcommitlint-plugin-conditionals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fcommitlint-plugin-conditionals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mridang","download_url":"https://codeload.github.com/mridang/commitlint-plugin-conditionals/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fcommitlint-plugin-conditionals/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29974747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T16:18:32.386Z","status":"ssl_error","status_checked_at":"2026-03-01T16:18:04.258Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["release-automation","semantic-release","semantic-release-plugin"],"created_at":"2025-05-26T21:55:06.052Z","updated_at":"2026-03-01T16:34:07.592Z","avatar_url":"https://github.com/mridang.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Commitlint - Conditional Rules Plugin\n\nA [commitlint](https://commitlint.js.org/)\nplugin to enable conditional application of linting rules based on various\ncommit attributes, such as author patterns or message content.\n\nThis plugin helps ensure that commit message conventions can be flexibly\nenforced. For instance, it allows for different linting standards for\nhuman-authored commits versus automated commits (e.g., from bots), or for\nvarying rules based on the type of changes being committed. It is designed\nto be extended with more conditional capabilities over time.\n\n### Why?\n\nMaintaining consistent and meaningful commit messages is crucial for project\nhealth, enabling better collaboration, clearer history, and automated\nchangelog generation. [Commitlint](https://commitlint.js.org/) is an excellent\ntool for enforcing these conventions.\n\nHowever, a one-size-fits-all linting approach isn't always optimal.\nDifferent types of commits or contributions might warrant different levels of\nscrutiny or slightly varied rules:\n\n- **Automated Commits:** Commits generated by bots (e.g., Dependabot,\n  Renovate, CI scripts) often have a standardized, machine-generated format.\n  Applying the same strict linting rules designed for human contributors can\n  be overly restrictive or lead to unnecessary failures for these automated\n  processes. It's often desirable to either bypass linting for these bots or\n  apply a more lenient set of rules.\n- **Work-in-Progress or Specific Branch Types:** Teams might want to enforce\n  strict rules on main development lines (`main`, `develop`) but allow more\n  flexibility on feature branches or for commits marked as \"WIP\" (Work In\n  Progress).\n- **Evolving Standards:** As a project evolves, you might want to introduce\n  new linting rules but apply them conditionally at first, or only to\n  certain types of commits, before making them universal.\n\nThis plugin, `@mridang/commitlint-plugin-conditionals`, aims to provide the\nflexibility to handle such scenarios. It allows you to define conditions\n(initially based on author patterns) under which commit linting rules are\napplied differently, or even skipped entirely. This helps maintain high\nstandards for human contributions where needed, while accommodating the\npracticalities of automated systems and diverse development workflows,\nultimately leading to a more effective and less burdensome commit linting\nprocess.\n\n## Installation\n\nInstall using NPM by using the following command:\n\n```sh\nnpm install --save @mridang/commitlint-plugin-conditionals\n```\n\n## Usage\n\nTo use this plugin, add `@mridang/commitlint-plugin-conditionals` to your `commitlint`\nconfiguration file (e.g., `commitlint.config.js` or `.commitlintrc.js`).\n\nYou'll need to list it in the `plugins` array. The rules provided by this\nplugin will then be available to be configured in the `rules` object, prefixed\nwith the plugin's name.\n\nFirst, add the plugin to the `plugins` array in your `commitlint` configuration:\n\n```javascript\n/**\n * @type {import('@commitlint/types').UserConfig}\n */\nconst config = {\n  extends: [\n    '@commitlint/config-conventional', // Or your preferred base configuration\n  ],\n  plugins: [\n    '@mridang/conditionals', // Add the plugin by its package name\n  ],\n  rules: {\n    // Rule configuration will go here\n  },\n};\n\nmodule.exports = config;\n```\n\n#### Configuring the `ignoreForAuthors` Rule\n\nThis rule is the core of the plugin.\n\n**Rule Name:** `@mridang/commitlint-plugin-conditionals/ignore-for-authors`\n\n**Options (`IgnoreForAuthorsRuleOptions`):**\n\nThe rule accepts an object with the following properties:\n\n- `ignoreAuthorPatterns?: string[]`:\n\n  - An array of string patterns (e.g., `['dependabot[bot]', 'renovate-bot']`).\n  - If a pattern matches content in the raw commit message, the rules\n    defined in `rulesToEnforce` are bypassed for that commit.\n\n- `rulesToEnforce?: ExternalRuleToEnforce[]`:\n  - An array of rule configurations to apply if the commit is **not** from an\n    ignored author.\n  - Each entry is an object:\n    - `packageName: string`: NPM package name (e.g., `'@commitlint/rules'`).\n    - `ruleName: string`: Rule name within that package (e.g., `'type-enum'`).\n    - `value: unknown`: Configuration value for that rule.\n\n**Behavior:**\n\n1.  If `ignoreAuthorPatterns` match, this rule passes, and its configured\n    `rulesToEnforce` are skipped.\n2.  If no `ignoreAuthorPatterns` match, each rule in `rulesToEnforce` is\n    dynamically loaded and executed. If any fail, this rule fails.\n3.  This rule is **asynchronous**.\n\n**Important:** This rule only controls the execution of rules listed in its\n`rulesToEnforce` option. Other rules from `extends` or elsewhere in your\nmain `rules` object will still apply to all commits unless explicitly\ndisabled or managed by a global dynamic configuration.\n\n##### Example: Conditional Rules for Specific Authors\n\nThis example shows how to use `ignoreForAuthors` to apply different `body-max-line-length`\nand `type-enum` settings for `dependabot[bot]` versus other users, while\nstill inheriting other rules from `@commitlint/config-conventional`.\n\n```javascript\nimport { RuleConfigSeverity } from '@commitlint/types';\nimport mridangConditionalsPlugin from '@mridang/commitlint-plugin-conditionals'; // eslint-disable-line\n\n/**\n * @type {import('@commitlint/types').UserConfig}\n */\nexport default {\n  extends: ['@commitlint/config-conventional'],\n  plugins: [mridangConditionalsPlugin],\n  rules: {\n    /**\n     * Disable the 'body-max-line-length' rule from '@commitlint/config-conventional'\n     * because we want our plugin to control it conditionally.\n     * Using RuleConfigSeverity.Disabled (which is 0).\n     */\n    'body-max-line-length': [RuleConfigSeverity.Disabled, 'always'],\n\n    /**\n     * Configure the rule from your plugin.\n     * The rule name is prefixed with your actual package name.\n     * Options type (for JSDoc reference if needed):\n     * import('@mridang/commitlint-conditionals').IgnoreForAuthorsRuleOptions\n     */\n    '@mridang/commitlint-conditionals/ignoreForAuthors': [\n      RuleConfigSeverity.Error, // Severity: Error (2) for this conditional rule itself\n      'always', // Condition\n      {\n        /**\n         * Use 'signOffPatternsToIgnore' to specify patterns within\n         * 'Signed-off-by:' lines.\n         */\n        signOffPatternsToIgnore: [\n          'dependabot[bot]',\n          // Add other patterns like 'bot@example.com'\n        ],\n        rulesToEnforce: [\n          // For commits not matching signOffPatternsToIgnore, enforce this:\n          {\n            packageName: '@commitlint/rules',\n            ruleName: 'body-max-line-length',\n            value: 100, // Standard limit for humans\n          },\n          // Example: Enforcing type-enum for non-bots\n          // {\n          //   packageName: '@commitlint/rules',\n          //   ruleName: 'type-enum',\n          //   value: [\n          //     'build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf',\n          //     'refactor', 'revert', 'style', 'test',\n          //   ],\n          // },\n        ],\n      },\n    ],\n    /**\n     * Note:\n     * - Other rules from '@commitlint/config-conventional' (e.g., 'type-enum'\n     * if not handled by the plugin above and its original disabled)\n     * that were NOT disabled will now apply to ALL commits.\n     * - This example makes 'body-max-line-length' conditional.\n     */\n  },\n};\n```\n\n## Known Issues\n\n- **External Rule Dependencies (`rulesToEnforce`):** When configuring `rulesToEnforce`, ensure each specified `packageName` is installed in your project and exports its rule functions in a standard `commitlint` plugin format. The plugin will dynamically load these external rules.\n- **Author Identification (`signOffPatternsToIgnore`):** This feature identifies authors by searching for your specified patterns within `Signed-off-by:` lines in the raw commit message text. It does not directly use Git's discrete author fields (e.g., `GIT_AUTHOR_NAME`).\n- **Plugin's Scope of Control:** This plugin conditionally applies only those rules explicitly listed in its `rulesToEnforce` option. It does **not** automatically bypass other rules inherited via `extends` or defined elsewhere in your main `commitlint` configuration. For a global bypass of all rules for certain authors, a dynamic JavaScript/TypeScript configuration file (`commitlint.config.js` or `.ts`) is necessary, as detailed in the \"Usage\" section.\n\n## Useful links\n\n- **[Commitlint](https://commitlint.js.org/):** The linting tool for commit\n  messages that `@mridang/commitlint-plugin-conditionals` integrates with.\n- **[Conventional Commits](https://www.conventionalcommits.org/):** The commit\n  convention that `commitlint` often enforces.\n\n## Contributing\n\nIf you have suggestions for how this app could be improved, or\nwant to report a bug, open an issue - we'd love all and any\ncontributions.\n\n## License\n\nApache License 2.0 © 2024 Mridang Agarwalla\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmridang%2Fcommitlint-plugin-conditionals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmridang%2Fcommitlint-plugin-conditionals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmridang%2Fcommitlint-plugin-conditionals/lists"}