Skip to content

Commit ae2bdd9

Browse files
committed
fix(regex): [list] ignore matches in aggregate export statements
- https://regex101.com/r/KQEDdZ/14 Signed-off-by: Lexus Drumgold <[email protected]>
1 parent cd20ef3 commit ae2bdd9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/__tests__/export-list.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ describe('unit:EXPORT_LIST_REGEX', () => {
1111
TEST_SUBJECT.lastIndex = 0
1212
})
1313

14+
it('should ignore match in aggregate export statement', () => {
15+
// Arrange
16+
const code = dedent`
17+
export { default } from './make'
18+
export {
19+
DEFAULTS,
20+
plugin as default,
21+
type Options
22+
} from './plugin'
23+
export type { Config, Result } from './interfaces'
24+
export type { default as Options } from './options'
25+
`
26+
27+
// Act + Expect
28+
expect(TEST_SUBJECT.test(code)).to.be.false
29+
})
30+
1431
it('should ignore match in multi-line comment', () => {
1532
// Arrange
1633
const code = dedent`

src/export-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
* @const {RegExp} EXPORT_LIST_REGEX
5454
*/
5555
const EXPORT_LIST_REGEX: RegExp =
56-
/(?<=^|[\n;])export(?:(?:\s+(?<type>type)\s*)|\s*)(?<exports>{[\w\t\n\r "$'*,./{}-]+?})/g
56+
/(?<=^|[\n;](?:[\t ]*(?:\w+ )?)?)export(?:(?:\s+(?<type>type)\s*)|\s*)(?<exports>{[\w\t\n\r "$'*,./{}-]+?})(?=;?[\t\n;]*?(?!(?:\n*\/\/)|(?:\n*\/\*)|(?:\s*from.*?)))/g
5757

5858
export default EXPORT_LIST_REGEX

0 commit comments

Comments
 (0)