Skip to content

Commit

Permalink
Merge branch 'main' of github.com:tjx666/package-manager-enhancer
Browse files Browse the repository at this point in the history
  • Loading branch information
tjx666 committed Jul 13, 2024
2 parents c6e02e1 + 7d83746 commit 372ccfc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/hoverTooltips/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,19 @@ export class ModulesHoverProvider implements HoverProvider {

const stringBeforeLeftQuote = lineText.slice(0, leftQuotaIndex);
const stringAfterRightQuote = lineText.slice(rightQuotaIndex + 1);
const afterFnCallRegexp = /^\s*\)(?:;.*|\n?)$/;
const afterFnCallRegexp = /^\s*\)(?:;.*|\n?)/;
const afterStatementRegexp = /^\s*(?:;.*)?$/;
const isModule = // named imports/exports: import { pick } from 'lodash' or export * from 'antd'
(/(?:\b|\s+)from\s+$/.test(stringBeforeLeftQuote) &&
afterStatementRegexp.test(stringAfterRightQuote)) ||
// unnamed import
(/(?:\b|\s+)import\s+$/.test(stringBeforeLeftQuote) &&
afterStatementRegexp.test(stringAfterRightQuote)) ||
// dynamic imports: import( 'lodash' )
(/(?:\b|\s+)import\s*\(\s*$/.test(stringBeforeLeftQuote) &&
// dynamic imports:
// case1: import( 'lodash' )
// case2: import( 'lodash' ).then()
// case3: /** @type {import('next').NextConfig} */
(/(?:\b|\{|\s+)import\s*\(\s*$/.test(stringBeforeLeftQuote) &&
afterFnCallRegexp.test(stringAfterRightQuote)) ||
// require: require('lodash' )
(/require\s+\(\s*$/.test(stringBeforeLeftQuote) &&
Expand Down

0 comments on commit 372ccfc

Please sign in to comment.