Skip to content

Commit 3ea3f4b

Browse files
committed
fix(regex): [list] ignore nested aggregate export statement matches
- https://regex101.com/r/KQEDdZ/21 Signed-off-by: Lexus Drumgold <[email protected]>
1 parent 7f8e3e6 commit 3ea3f4b

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

src/__snapshots__/export-list.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,20 @@ exports[`unit:EXPORT_LIST_REGEX > exports > should match nested export statement
111111
},
112112
},
113113
{
114-
"0": "export type { Config, Result }",
114+
"0": "export type { default as Options }",
115115
"1": "type",
116-
"2": "{ Config, Result }",
116+
"2": "{ default as Options }",
117117
"groups": {
118-
"exports": "{ Config, Result }",
118+
"exports": "{ default as Options }",
119119
"type": "type",
120120
},
121121
},
122122
{
123-
"0": "export type { default as Options }",
123+
"0": "export type { Config, Result }",
124124
"1": "type",
125-
"2": "{ default as Options }",
125+
"2": "{ Config, Result }",
126126
"groups": {
127-
"exports": "{ default as Options }",
127+
"exports": "{ Config, Result }",
128128
"type": "type",
129129
},
130130
},

src/__tests__/export-list.spec.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,34 @@ describe('unit:EXPORT_LIST_REGEX', () => {
118118
plugin as default,
119119
type Options
120120
}
121-
export type { Config, Result }
121+
export { defineBuildConfig, type BuildConfig } from "#src"
122+
export type {
123+
JsonObject,
124+
LiteralUnion,
125+
Nullable
126+
} from '@flex-development/tutils'
127+
export {
128+
addFive,
129+
addFour,
130+
addThree,
131+
addTwo,
132+
squareFive,
133+
squareFour,
134+
squareThree,
135+
squareTwo
136+
} from './lib'
137+
export * as constants from "./constants"
122138
export type { default as Options }
139+
export type { default as Options } from "./options"
140+
export * from './utils'
141+
export interface User {}
142+
export abstract class House {}
143+
export const { name1, name2: bar } = o;
144+
export const [ name1, name2 ] = array;
145+
export default async function foo() {}
146+
export default foo
147+
export default 1 + 1;
148+
export type { Config, Result }
123149
}
124150
`
125151

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;](?:[\t ]*(?:\w+ )?)?)export(?:(?:\s+(?<type>type)\s*)|\s*)(?<exports>{[\w\t\n\r "$'*,./{}-]+?})(?=;?[\t\n;]*?(?!(?:\n*\/\/)|(?:\n*\/\*)|(?:\s*from.*?)))/g
56+
/(?<=^[\t ]*|[\n;](?:[\t ]*(?:\w+ )?)?)export(?:(?:\s+(?<type>type)\s*)|\s*)(?<exports>{[\w\t\n\r "$'*,./-]*?})(?=[\t\n ;](?!from)|$)/g
5757

5858
export default EXPORT_LIST_REGEX

0 commit comments

Comments
 (0)