Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /usr/share/nodejs/jsdom/scripts/eslint-plugin/rules/ drwxr-xr-x |
Viewing file: Select action/file-type: "use strict"; function isSuperHookInvocation(expression, hook) { if (expression.type !== "CallExpression") { return false; } const { callee } = expression; // super._hook() if ( callee.type === "MemberExpression" && callee.object.type === "Super" && callee.property.type === "Identifier" && callee.property.name === hook ) { return true; } // super._hook.apply() or super._hook.call() if ( callee.type === "MemberExpression" && callee.object.type === "MemberExpression" && callee.object.object.type === "Super" && callee.object.property.type === "Identifier" && callee.object.property.name === hook && callee.property.type === "Identifier" && (callee.property.name === "call" || callee.property.name === "apply") ) { return true; } return false; } module.exports = { meta: { type: "problem", docs: { description: "Prevent missing invocation to the super jsdom hook.", type: "array", items: { type: "object", properties: { ancestor: { type: "string" }, hook: { type: "string" } }, required: ["ancestor", "hook"], additionalProperties: false } } }, create(context) { const { options } = context; return { MethodDefinition(node) { if ( node.kind !== "method" || node.key.type !== "Identifier" ) { return; } const hookName = node.key.name; const hookOption = options.find(option => option.hook === hookName); // Don't do anything if the method is not a known hook. if (hookOption === undefined) { return; } // Check if the class is not the ancestor class defining the hook. In this case it should not call super. const isAncestorClass = node.parent.parent.id && node.parent.parent.id.name === hookOption.ancestor; if (isAncestorClass) { return; } const isMethodCallingSuper = node.value.body.body.some(statement => { return ( statement.type === "ExpressionStatement" && isSuperHookInvocation(statement.expression, hookName) ); }); if (!isMethodCallingSuper) { context.report({ node, message: `Missing invocation to the "${hookName}" jsdom hook super.` }); } } }; } }; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0048 ]-- |