Skip to content
Permalink
Browse files
Chore: improve performance of :function selector (#15181)
  • Loading branch information
mdjermanovic committed Oct 21, 2021
1 parent 31af1c8 commit 90a5b6b4aeff7343783f85418c683f2c9901ab07
Showing with 21 additions and 0 deletions.
  1. +7 −0 lib/linter/node-event-generator.js
  2. +14 −0 tests/lib/linter/node-event-generator.js
@@ -98,6 +98,13 @@ function getPossibleTypes(parsedSelector) {
case "adjacent":
return getPossibleTypes(parsedSelector.right);

case "class":
if (parsedSelector.name === "function") {
return ["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"];
}

return null;

default:
return null;

@@ -257,6 +257,20 @@ describe("NodeEventGenerator", () => {
]
);

assertEmissions(
"function foo(){} var x; (function (p){}); () => {};",
[":function", "ExpressionStatement > :function", "VariableDeclaration, :function[params.length=1]"],
ast => [
[":function", ast.body[0]], // function foo(){}
["VariableDeclaration, :function[params.length=1]", ast.body[1]], // var x;
[":function", ast.body[2].expression], // function (p){}
["ExpressionStatement > :function", ast.body[2].expression], // function (p){}
["VariableDeclaration, :function[params.length=1]", ast.body[2].expression], // function (p){}
[":function", ast.body[3].expression], // () => {}
["ExpressionStatement > :function", ast.body[3].expression] // () => {}
]
);

assertEmissions(
"foo;",
[

0 comments on commit 90a5b6b

Please sign in to comment.