X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=eslint%2Fdocs%2Fdeveloper-guide%2Fcode-path-analysis%2FREADME.md;h=1c84b2e1f73b969e02b74a30d2b3dbc9ea45ebca;hb=5422a9ccba27ca22ad96eeaeafe705b61947a40a;hp=c283d51bf91507ab272746de94e525b976326403;hpb=61dc968b37dcd73951953ed0039ea9cc25002085;p=pve-eslint.git diff --git a/eslint/docs/developer-guide/code-path-analysis/README.md b/eslint/docs/developer-guide/code-path-analysis/README.md index c283d51..1c84b2e 100644 --- a/eslint/docs/developer-guide/code-path-analysis/README.md +++ b/eslint/docs/developer-guide/code-path-analysis/README.md @@ -195,8 +195,6 @@ bar(); ### To check whether or not this is reachable ```js -var last = require("lodash").last; - function isReachable(segment) { return segment.reachable; } @@ -215,7 +213,7 @@ module.exports = function(context) { // Checks reachable or not. "ExpressionStatement": function(node) { - var codePath = last(codePathStack); + var codePath = codePathStack[codePathStack.length - 1]; // Checks the current code path segments. if (!codePath.currentSegments.some(isReachable)) { @@ -239,8 +237,6 @@ So a rule must not modify those instances. Please use a map of information instead. ```js -var last = require("lodash").last; - function hasCb(node, context) { if (node.type.indexOf("Function") !== -1) { return context.getDeclaredVariables(node).some(function(v) { @@ -285,8 +281,10 @@ module.exports = function(context) { // Manages state of code paths. "onCodePathSegmentStart": function(segment) { + var funcInfo = funcInfoStack[funcInfoStack - 1]; + // Ignores if `cb` doesn't exist. - if (!last(funcInfoStack).hasCb) { + if (!funcInfo.hasCb) { return; } @@ -304,7 +302,7 @@ module.exports = function(context) { // Checks reachable or not. "CallExpression": function(node) { - var funcInfo = last(funcInfoStack); + var funcInfo = funcInfoStack[funcInfoStack - 1]; // Ignores if `cb` doesn't exist. if (!funcInfo.hasCb) {