Parser for Github, GitLab and Bitbucket issues actions, references and mentions
Installations
npm install issue-parser
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
^18.17 || >=20.6.1
Node Version
20.13.1
NPM Version
10.5.2
Score
99.2
Supply Chain
100
Quality
81.7
Maintenance
100
Vulnerability
98.6
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
semantic-release
Download Statistics
Total Downloads
213,885,447
Last Day
301,374
Last Week
1,462,823
Last Month
6,710,201
Last Year
76,917,742
GitHub Statistics
22 Stars
111 Commits
3 Forks
5 Watching
8 Branches
11 Contributors
Bundle Size
19.77 kB
Minified
6.94 kB
Minified + Gzipped
Package Meta Information
Latest Version
7.0.1
Package Id
issue-parser@7.0.1
Unpacked Size
25.92 kB
Size
6.64 kB
File Count
5
NPM Version
10.5.2
Node Version
20.13.1
Publised On
31 May 2024
Total Downloads
Cumulative downloads
Total Downloads
213,885,447
Last day
-9.6%
301,374
Compared to previous day
Last week
-15.6%
1,462,823
Compared to previous week
Last month
6.3%
6,710,201
Compared to previous month
Last year
53.7%
76,917,742
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
issue-parser
Parser for Github, GitLab and Bitbucket issues actions, references and mentions
The parser can identify:
- GitHub closing keywords, duplicate keyword, issue references and user mentions
- GitLab closing keywords, duplicate keyword, issue references and user mentions
- Bitbucket closing keywords, issue references and user mentions
- Custom or additional keywords
Install
1$ npm install --save issue-parser
Usage
GitHub format
1const issueParser = require('issue-parser'); 2const parse = issueParser('github'); 3 4parse('Issue description, ref user/package#1, Fix #2, Duplicate of #3 /cc @user'); 5/* 6{ 7 refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}], 8 actions: { 9 close: [{raw: 'Fix #2', action: 'Fix', prefix: '#', issue: '2'}], 10 duplicate: [{raw: 'Duplicate of #3', action: 'Duplicate of', prefix: '#', issue: '3'}], 11 }, 12 mentions: [{raw: '@user', prefix: '@', user: 'user'}], 13} 14*/
GitLab format
1const issueParser = require('issue-parser'); 2const parse = issueParser('gitlab'); 3 4parse('Issue description, ref group/user/package#1, !2, implement #3, /duplicate #4 /cc @user'); 5/* 6{ 7 refs: [ 8 {raw: 'group/user/package#1', slug: 'group/user/package', prefix: '#', issue: '1'}, 9 {raw: '!2', slug: 'group/user/package', prefix: '!', issue: '2'}, 10 ], 11 actions: { 12 close: [{raw: 'implement #3', action: 'Implement', prefix: '#', issue: '4'}], 13 duplicate: [{raw: 'Duplicate of #4', action: 'Duplicate of', prefix: '#', issue: '4'}], 14 }, 15 mentions: [{raw: '@user', prefix: '@', user: 'user'}], 16} 17*/
Bitbucket format
1const issueParser = require('issue-parser'); 2const parse = issueParser('bitbucket'); 3 4parse('Issue description, ref user/package#1, fixing #2. /cc @user'); 5/* 6{ 7 refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}], 8 actions: { 9 close: [{raw: 'fixing #2', action: 'Fixing', prefix: '#', issue: '2'}], 10 }, 11 mentions: [{raw: '@user', prefix: '@', user: 'user'}], 12} 13*/
Custom format
1const issueParser = require('issue-parser'); 2const parse = issueParser({actions: {fix: ['complete'], hold: ['holds up']}, issuePrefixes: ['🐛']}); 3 4parse('Issue description, related to user/package🐛1, Complete 🐛2, holds up 🐛3'); 5/* 6{ 7 refs: [{raw: 'user/package🐛1', slug: 'user/package', prefix: '🐛', issue: '1'}], 8 actions: { 9 fix: [{raw: 'Complete 🐛2', action: 'Complete', prefix: '🐛', issue: '2'}], 10 hold: [{raw: 'holds up 🐛3', action: 'Holds up', prefix: '🐛', issue: '3'}], 11 }, 12} 13*/
Extend existing format
1const issueParser = require('issue-parser'); 2const parse = issueParser('github', {actions: {parent: ['parent of'], related: ['related to']}}); 3 4parse('Issue description, ref user/package#1, Fix #2, Parent of #3, related to #4 /cc @user'); 5/* 6{ 7 refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}], 8 actions: { 9 close: [{raw: 'Fix #2', action: 'Fix', prefix: '#', issue: '2'}], 10 parent: [{raw: 'Parent of #3', action: 'Parent of', prefix: '#', issue: '3'}], 11 related: [{raw: 'related to #4', action: 'Related to', prefix: '#', issue: '4'}], 12 }, 13 mentions: [{raw: '@user', prefix: '@', user: 'user'}], 14} 15*/
Features
Parse references
1#1
1{refs: [{raw: '#1', slug: undefined, prefix: '#', issue: '1'}]}
Parse repository slug
1owner/repo#1
1{refs: [{raw: 'owner/repo#1', slug: 'owner/repo', prefix: '#', issue: '1'}]}
Parse closing keywords
1Fix #1
1{actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}}
Parse duplicate keywords
1Duplicate of #1
1{actions: {duplicate: [{raw: 'Duplicate of #1', action: 'Duplicate of', slug: undefined, prefix: '#', issue: '1'}]}}
Parse user mentions
1@user
1{mentions: [{raw: '@user', prefix: '@', user: 'user'}]}
Parse references with full issue URL
1https://github.com/owner/repo/pull/1 2 3Fix https://github.com/owner/repo/issues/2
1{ 2 refs: [{raw: 'https://github.com/owner/repo/pull/1', slug: 'owner/repo', prefix: undefined, issue: '1'},] 3 actions: { 4 close: [ 5 {raw: 'Fix https://github.com/owner/repo/issues/2', action: 'Fix', slug: 'owner/repo', prefix: undefined, issue: '2'} 6 ] 7 } 8}
Ignore keywords case
1FIX #1
1{actions: {close: [{raw: 'FIX #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}}
Support delimiters between action keyword and issue
1Fix: #1
1{actions: {close: [{raw: 'Fix: #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}}
Ignore references in back-tick quotes
1Fix #1 `Fix #2` @user1 `@user2`
1{ 2 actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}, 3 mentions: [{raw: '@user1', prefix: '@', user: 'user1'}] 4}
Include references in escaped back-tick quotes
1\`Fix #1\` \`@user\`
1{ 2 actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}, 3 mentions: [{raw: '@user1', prefix: '@', user: 'user1'}] 4}
Ignore references in fenced blocks
1Fix #1 2 3```js 4console.log('Fix #2'); 5``` 6 7@user1 8 9```js 10console.log('@user2'); 11```
1{ 2 actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}, 3 mentions: [{raw: '@user1', prefix: '@', user: 'user1'}] 4}
Include references in escaped fenced blocks
1\`\`\` 2Fix #1 3\`\`\` 4 5\`\`\` 6@user 7\`\`\`
1{ 2 actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}, 3 mentions: [{raw: '@user', prefix: '@', user: 'user'}] 4}
Ignore references in <code> tags
1Fix #1 2<code>Fix #2</code> 3<code><code>Fix #3</code></code> 4@user1 5<code>@user2</code>
1{ 2 actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}, 3 mentions: [{raw: '@user1', prefix: '@', user: 'user1'}] 4}
Include references in escaped <code> tags
1`<code>`Fix #1`</code>` 2`<code>`@user`</code>`
1{ 2 actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}, 3 mentions: [{raw: '@user', prefix: '@', user: 'user'}] 4}
Ignore malformed references
1Fix #1 Fix #2a Fix a#3
1{actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}}
API
issueParser([options], [overrides]) => parse
Create a parser.
options
Type: Object
String
Parser options. Can be github
, gitlab
or bitbucket
for predefined options, or an object for custom options.
actions
Type: Object
Default:
{close: ['close', 'closes', 'closed', 'closing', 'fix', 'fixes', 'fixed', 'fixing', 'resolve', 'resolves', 'resolved', 'resolving', 'implement', 'implements', 'implemented', 'implementing'], duplicate: ['Duplicate of', '/duplicate']}
Object with type of action as key and array of keywords as value.
Each keyword match will be placed in the corresponding property of the result
action
object. For example the with the configuration {actions: fix: ['fixed', 'fixing']}
each action matching fixed
or fixing
will be under result.actions.fix
.
delimiters
Type: Array<String>
String
Default: [':']
List of delimiter characters allowed between an action keywords and the issue reference. The characters space (
) and tab (
) are always allowed.
mentionsPrefixes
Type: Array<String>
String
Default: ['@']
List of keywords used to identify user mentions.
issuePrefixes
Type: Array<String>
String
Default: ['#', 'gh-']
List of keywords used to identify issues and pull requests.
hosts
Type: Array<String>
String
Default: ['https://github.com', 'https://gitlab.com']
List of base URL used to identify issues and pull requests with full URL.
issueURLSegments
Type: Array<String>
String
Default: ['issues', 'pull', 'merge_requests']
List of URL segment used to identify issues and pull requests with full URL.
overrides
Type: Object
Option overrides. Useful when using predefined options
(such as github
, gitlab
or bitbucket
). The overrides
object can define the same properties as options
.
For example, the following will use all the github
predefined options but with a different hosts
option:
1const issueParser = require('issue-parser'); 2const parse = issueParser('github', {hosts: ['https://custom-url.com']});
parse(text) => Result
Parse an issue description and returns a Result object.
text
Type: String
Issue text to parse.
Result
actions
Type: Object
List of matching actions by type.
Each type of action is an array of objects with the following properties:
Name | Type | Description |
---|---|---|
raw | String | The raw value parsed, for example Fix #1 . |
action | String | The keyword used to identify the action, capitalized. |
slug | String | The repository owner and name, for issue referred as <owner>/<repo>#<issue number> . |
prefix | String | The prefix used to identify the issue. |
issue | String | The issue number. |
refs
Type: Array<Object>
List of issues and pull requests referenced, but not matched with an action.
Each reference has the following properties:
Name | Type | Description |
---|---|---|
raw | String | The raw value parsed, for example #1 . |
slug | String | The repository owner and name, for issue referred as <owner>/<repo>#<issue number> . |
prefix | String | The prefix used to identify the issue. |
issue | String | The issue number. |
mentions
Type: Array<Object>
List of users mentioned.
Each mention has the following properties:
Name | Type | Description |
---|---|---|
raw | String | The raw value parsed, for example @user . |
prefix | String | The prefix used to identify the mention. |
user | String | The user name |
allRefs
Type: Array<Object>
List of all issues and pull requests referenced or matching an action.
Each reference has the following properties:
Name | Type | Description |
---|---|---|
raw | String | The raw value parsed, for example Fix #1 . |
action | String | The keyword used to identify the action or the duplicate, capitalized. Only if matched by an action. |
slug | String | The repository owner and name, for issue referred as <owner>/<repo>#<issue number> . |
prefix | String | The prefix used to identify the issue. |
issue | String | The issue number. |
No vulnerabilities found.
No security vulnerabilities found.
Other packages similar to issue-parser
@types/issue-parser
TypeScript definitions for issue-parser
@zentered/issue-forms-body-parser
Parser for GitHub Issue Form body, also available as GitHub Action
@scalepublishing/issue-parser
Parse and export contents of a SCALE issue
github-issue-parser
markdown parser for github issues