UNPKG

603 BJavaScriptView Raw
1/**
2 * @fileoverview Rule to flag when return statement contains assignment
3 * @author Ilya Volodin
4 */
5"use strict";
6
7//------------------------------------------------------------------------------
8// Rule Definition
9//------------------------------------------------------------------------------
10
11module.exports = function(context) {
12
13 return {
14
15 "ReturnStatement": function(node) {
16 if (node.argument && node.argument.type === "AssignmentExpression") {
17 context.report(node, "Return statement should not contain assignment.");
18 }
19 }
20 };
21
22};