Skip to content

Commit

Permalink
Replace periscopic with estree-util-scope
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 29, 2024
1 parent 2ecebb0 commit d306f87
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 184 deletions.
139 changes: 64 additions & 75 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
"eslint-plugin-react": "^7.0.0",
"eslint-plugin-react-hooks": "^4.0.0",
"estree-to-babel": "^9.0.0",
"estree-util-scope": "^1.0.0",
"estree-util-value-to-estree": "^3.0.0",
"estree-walker": "^3.0.0",
"globby": "^14.0.0",
"hast-util-from-html": "^2.0.0",
"hast-util-sanitize": "^5.0.0",
Expand All @@ -67,7 +69,6 @@
"ink": "^5.0.0",
"lz-string": "^1.0.0",
"p-all": "^5.0.0",
"periscopic": "^3.0.0",
"postcss": "^8.0.0",
"postcss-cli": "^11.0.0",
"preact": "^10.0.0",
Expand Down
23 changes: 19 additions & 4 deletions packages/mdx/lib/plugin/recma-document.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

import {ok as assert} from 'devlop'
import {createVisitors} from 'estree-util-scope'
import {walk} from 'estree-walker'
import {analyze} from 'periscopic'
import {positionFromEstree} from 'unist-util-position-from-estree'
import {stringifyPosition} from 'unist-util-stringify-position'
import {create} from '../util/estree-util-create.js'
Expand Down Expand Up @@ -433,9 +433,24 @@ export function recmaDocument(options) {
// export var a = 1
// ```
if (node.declaration) {
exportedIdentifiers.push(
...analyze(node.declaration).scope.declarations.keys()
)
const visitors = createVisitors()
// Walk the top-level scope.
walk(node, {
enter(node) {
visitors.enter(node)

if (
node.type === 'ArrowFunctionExpression' ||
node.type === 'FunctionDeclaration' ||
node.type === 'FunctionExpression'
) {
this.skip()
visitors.exit(node)
}
},
leave: visitors.exit
})
exportedIdentifiers.push(...visitors.scopes[0].defined)
}

// ```tsx
Expand Down
Loading

0 comments on commit d306f87

Please sign in to comment.