// Example from: https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-reserved-words/src/index.ts import { declare } from "@babel/helper-plugin-utils"; import { types as t, type NodePath } from "@babel/core"; import { isIdentifierName } from "@babel/helper-validator-identifier"; const QT_SCRIPT_RESERVED_WORDS = new Set(["for"]); function isQtScriptReservedWord(name: string): boolean { return isIdentifierName(name) && QT_SCRIPT_RESERVED_WORDS.has(name); } export default declare((_api) => { return { name: "test", visitor: { Identifier(path: NodePath) { if (isQtScriptReservedWord(path.node.name)) { console.log(path.node.name); path.scope.rename(path.node.name); } }, }, }; });