CallExpression: function(node) { // Check if what's being called is nsiTransferable.init() if (typeof node.callee !== 'undefined') { let nodeReference = getNodeReference(context, node.callee); let nodeObject = getNodeReference(context, nodeReference.object); if (nodeObject === undefined) { return; } if (nodeObject.name === 'nsITransferable' && nodeReference.property.name === 'init') { if (node.arguments.length > 0) { // Get the reference to the first arg and check if it's null. let arg = getNodeReference(context, node.arguments[0]); if (arg.value === null) { return context.report({node: node, message: INIT_NULL_ARG.code}); } } } } },
it('should return the name of the referenced variable', () => { var ref = { name: 'foo' }; var val = utils.getNodeReference(context, ref); assert.equal(val.name, 'bar'); });
it('should return the name of the reference if not in scope', () => { var ref = { name: 'doesNotExist' }; var val = utils.getNodeReference(context, ref); assert.equal(val.name, ref.name); });
import { getNodeReference } from 'utils'; export const DEPRECATED_ENTITIES = [ { error: NO_DOCUMENT_WRITE, object: 'document', property: 'write', }, ]; export default { create(context) { return { // eslint-disable-next-line consistent-return CallExpression(node) { const referenceNode = getNodeReference(context, node.callee); // We're only looking for calls that look like `foo.bar()`. if ( typeof referenceNode.object !== 'undefined' && referenceNode.property.type === 'Identifier' && referenceNode.object.type === 'Identifier' ) { const referenceObject = getNodeReference( context, referenceNode.object ); for (let i = 0; i < DEPRECATED_ENTITIES.length; i++) { const entity = DEPRECATED_ENTITIES[i]; // Check to see if the node matches a deprecated entity. if (