(statement: Node, source: string)
| 886 | ).name |
| 887 | |
| 888 | const isPure = (statement: Node, source: string): boolean => { |
| 889 | switch (statement.type) { |
| 890 | case "FunctionDeclaration": |
| 891 | case "EmptyStatement": |
| 892 | return true |
| 893 | case "VariableDeclaration": |
| 894 | return statement.declarations.every( |
| 895 | declarator => |
| 896 | declarator.id.type === "Identifier" && |
| 897 | (!declarator.init || isPureExpression(declarator.init, source)) |
| 898 | ) |
| 899 | } |
| 900 | return false |
| 901 | } |
| 902 | |
| 903 | const isPureExpression = (node: Node, source: string): boolean => { |
| 904 | node = unwrapExpression(node) |
no test coverage detected