JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2371635
  • Score
    100M100P100Q194892F
  • License MIT

Parser for Github, GitLab and Bitbucket issues actions, references and user

Package Exports

  • issue-parser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (issue-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

issue-parser

Parser for Github, GitLab and Bitbucket issues actions, references and user

Travis Codecov Greenkeeper badge

The parser can identify:

Install

$ npm install --save issue-parser

Usage

const issueParser = require('issue-parser');
const parse = issueParser('github');

issueParser('Issue description, ref user/package#1, Fix #2, Duplicate of #3 /cc @user');
/*
{
  refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}],
  actions: [{raw: 'Fix #2', action: 'Fix', prefix: '#', issue: '2'}],
  duplicates: [{raw: 'Duplicate of #3', action: 'Duplicate of', prefix: '#', issue: '3'}],
  mentions: [{raw: '@user', prefix: '@', user: 'user'}],
}
*/
const issueParser = require('issue-parser');
const parse = issueParser('gitlab');

issueParser('Issue description, ref group/user/package#1, implement #2, /duplicate #3 /cc @user');
/*
{
  refs: [{raw: 'group/user/package#1', slug: 'group/user/package', prefix: '#', issue: '1'}],
  actions: [{raw: 'implement #2', action: 'Implement', prefix: '#', issue: '2'}],
  duplicates: [{raw: 'Duplicate of #3', action: 'Duplicate of', prefix: '#', issue: '3'}],
  mentions: [{raw: '@user', prefix: '@', user: 'user'}],
}
*/
const issueParser = require('issue-parser')
const parse = issueParser('bitbucket');

issueParser('Issue description, ref user/package#1, fixing #2. /cc @user');
/*
{
  refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}],
  actions: [{raw: 'fixing #2', action: 'Fixing', prefix: '#', issue: '2'}],
  duplicates: [],
  mentions: [{raw: '@user', prefix: '@', user: 'user'}],
}
*/
const issueParser = require('issue-parser')
const parse = issueParser({referenceActions: ['complete'], issuePrefixes: ['🐛']});

issueParser('Issue description, related to user/package🐛1, Complete 🐛2');
/*
{
  refs: [{raw: 'user/package🐛1', slug: 'user/package', prefix: '🐛', issue: '1'}],
  actions: [{raw: 'Complete 🐛2', action: 'Complete', prefix: '🐛', issue: '2'}],
  duplicates: [],
  mentions: [],
}
*/

API

issueParser([options]) => 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.

referenceActions

Type: Array<String> String Default: ['close', 'closes', 'closed', 'closing', 'fix', 'fixes', 'fixed', 'fixing', 'resolve', 'resolves', 'resolved', 'resolving', 'implement', 'implements', 'implemented', 'implementing']

List of action keywords used to close issues and pull requests.

duplicateActions

Type: Array<String> String Default: ['Duplicate of', '/duplicate']

List of keywords used to identify duplicate issues and pull requests.

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.

parse(text) => Result

Parse an issue description and returns a Result object.

text

Type: String

Issue text to parse.

Result

actions

Type: Array<Object>

List of issues and pull requests closed. Each action 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, 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.

duplicates

Type: Array<Object>

List of issues and pull requests marked as duplicate. Each duplicate 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 duplicate, 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 closed or marked as duplicates. Each reference has the following properties:

Name Type Description
raw String The raw value parsed, for example Fix #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 Fix #1.
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 closed, marked as duplicate or referenced. 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.
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.