Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/regexp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const excludeRE = [
/\bclass\s*([\w$]+)\s*\{/g,
// defined as local variable
// eslint-disable-next-line regexp/no-super-linear-backtracking
/\b(?:const|let|var)\s+?(\[.*?\]|\{.*?\}|.+?)\s*?[=;\n]/gs,
/\b(?:const|let|var)\s+?(\[.*?\]|\{.*?\}|.+?)\s*?(?:=|;|\n|of)/gs,
]

export const importAsRE = /^.*\sas\s+/
Expand Down
6 changes: 6 additions & 0 deletions test/existing-scanning.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ describe('regex for extract local variable', () => {
{ input: 'const { ref} = Vue', output: ['ref'] },
{ input: 'const { maybe_test, $test} = Vue', output: ['maybe_test', '$test'] },
{ input: 'const [state] = useState(1)', output: ['state'] },
{ input: `
for (const [index] of [1,2,3].entries()) {
const a = AUTO_IMPORTED;
const b = []; // Make sure that the destructuring bracket in the loop does not expand to here
}
`, output: ['index', 'a', 'b'] },

// We may not able to handle these cases
// { input: 'const b = computed(0) , test=1;', output: ['b', 'test'] },
Expand Down