Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'Identifier': function (node) {
if (node.parent.type === 'MemberExpression' && node.parent.property === node) {
return // handled by MemberExpression
}
// ignore specifier identifiers
if (node.parent.type.slice(0, 6) === 'Import') return
if (!deprecated.has(node.name)) return
if (declaredScope(context, node.name) !== 'module') return
context.report({
node,
message: message(deprecated.get(node.name)),
})
},
VariableDeclarator: function ({ id, init }) {
if (init == null) return
if (init.type !== 'Identifier') return
if (!namespaces.has(init.name)) return
// check for redefinition in intermediate scopes
if (declaredScope(context, init.name) !== 'module') return
// DFS traverse child namespaces
function testKey(pattern, namespace, path = [init.name]) {
if (!(namespace instanceof Exports)) return
if (pattern.type !== 'ObjectPattern') return
for (const property of pattern.properties) {
if (
property.type === 'ExperimentalRestProperty'
|| property.type === 'RestElement'
|| !property.key
) {
continue
}
'VariableDeclarator': function ({ id, init }) {
if (init == null) return
if (init.type !== 'Identifier') return
if (!namespaces.has(init.name)) return
// check for redefinition in intermediate scopes
if (declaredScope(context, init.name) !== 'module') return
// DFS traverse child namespaces
function testKey(pattern, namespace, path = [init.name]) {
if (!(namespace instanceof Exports)) return
if (pattern.type !== 'ObjectPattern') return
for (let property of pattern.properties) {
if (property.key.type !== 'Identifier') {
context.report({
node: property,
message: 'Only destructure top-level names.',
})
continue
}