Skip to content

Commit ce9a711

Browse files
committed
Require Node.js 12.20 and move to ESM
1 parent eb494e9 commit ce9a711

File tree

8 files changed

+23
-36
lines changed

8 files changed

+23
-36
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 14
14-
- 12
15-
- 10
13+
- 16
1614
steps:
1715
- uses: actions/checkout@v2
18-
- uses: actions/setup-node@v1
16+
- uses: actions/setup-node@v2
1917
with:
2018
node-version: ${{ matrix.node-version }}
2119
- run: npm install

index.d.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
/**
22
Regular expression for matching issue references.
33
4-
@returns A `RegExp` for matching issue references.
5-
64
@example
75
```
8-
import issueRegex = require('issue-regex');
6+
import issueRegex from 'issue-regex';
97
108
'Fixes #143 and avajs/ava#1023'.match(issueRegex());
119
//=> ['#143', 'avajs/ava#1023']
1210
```
1311
*/
14-
declare function issueRegex(): RegExp;
15-
16-
export = issueRegex;
12+
export default function issueRegex(): RegExp;

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
2-
31
// https://regex101.com/r/SQrOlx/14
4-
module.exports = () => /(?:(?<![/\w-.])\w[\w-.]+\/\w[\w-.]+|\B)#[1-9]\d*\b/g;
2+
export default function issueRegex() {
3+
return /(?:(?<![/\w-.])\w[\w-.]+?\/\w[\w-.]+?|\B)#[1-9]\d*?\b/g;
4+
}

index.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import {expectType} from 'tsd';
2-
import issueRegex = require('.');
2+
import issueRegex from './index.js';
33

44
expectType<RegExp>(issueRegex());

license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
"description": "Regular expression for matching issue references",
55
"license": "MIT",
66
"repository": "sindresorhus/issue-regex",
7+
"funding": "https://github.com/sponsors/sindresorhus",
78
"author": {
89
"name": "Sindre Sorhus",
910
"email": "[email protected]",
10-
"url": "sindresorhus.com"
11+
"url": "https://sindresorhus.com"
1112
},
13+
"type": "module",
14+
"exports": "./index.js",
1215
"engines": {
13-
"node": ">=10"
16+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
1417
},
1518
"scripts": {
1619
"test": "xo && ava && tsd"
@@ -27,7 +30,6 @@
2730
"request",
2831
"reference",
2932
"references",
30-
"ref",
3133
"regex",
3234
"regexp",
3335
"regular",
@@ -37,8 +39,8 @@
3739
"link"
3840
],
3941
"devDependencies": {
40-
"ava": "^1.4.1",
41-
"tsd": "^0.7.2",
42-
"xo": "^0.24.0"
42+
"ava": "^3.15.0",
43+
"tsd": "^0.17.0",
44+
"xo": "^0.44.0"
4345
}
4446
}

readme.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,27 @@
22

33
> Regular expression for matching issue references
44
5-
65
## Install
76

87
```
98
$ npm install issue-regex
109
```
1110

12-
1311
## Usage
1412

1513
```js
16-
const issueRegex = require('issue-regex');
14+
import issueRegex from 'issue-regex';
1715

1816
'Fixes #143 and avajs/ava#1023'.match(issueRegex());
1917
//=> ['#143', 'avajs/ava#1023']
2018
```
2119

22-
2320
## API
2421

2522
### issueRegex()
2623

2724
Returns a `RegExp` for matching issue references.
2825

29-
3026
## Related
3127

3228
- [linkify-issues](https://github.com/sindresorhus/linkify-issues) - Linkify GitHub issue references
33-
34-
35-
## License
36-
37-
MIT © [Sindre Sorhus](https://sindresorhus.com)

test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import test from 'ava';
2-
import issueRegex from '.';
2+
import issueRegex from './index.js';
33

44
const matches = [
55
'#1',
66
'#3223',
77
'sindresorhus/dofle#33',
8-
'foo-bar/unicorn.rainbow#21'
8+
'foo-bar/unicorn.rainbow#21',
99
];
1010

1111
const nonMatches = [
@@ -19,13 +19,13 @@ const nonMatches = [
1919
'dofle#33',
2020
'#123hashtag',
2121
'non/-repo#123',
22-
'this/is/not/repo#123'
22+
'this/is/not/repo#123',
2323
];
2424

2525
test('main', t => {
2626
t.deepEqual(
2727
'Fixes #143 and avajs/ava#1023'.match(issueRegex()),
28-
['#143', 'avajs/ava#1023']
28+
['#143', 'avajs/ava#1023'],
2929
);
3030

3131
for (const x of matches) {
@@ -68,7 +68,7 @@ test('main #2', t => {
6868
'#123',
6969
'#123',
7070
'another/repo#123',
71-
'#123'
71+
'#123',
7272
];
7373

7474
t.deepEqual(actual.match(issueRegex()), expected);

0 commit comments

Comments
 (0)