diff --git a/index.js b/index.js index 70f2cb2..94c18ca 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,7 @@ "use strict"; +var arrayMethodPattern = /^(?:push|pop|shift|unshift|fill|reverse|splice)$/; + module.exports = { rules: { "no-let": function(context) { @@ -26,17 +28,29 @@ module.exports = { } } } - } }, + "no-array-mutation": function(context) { + return { + "Identifier": function(node) { + if (node.parent.type === "MemberExpression" + && node.parent.parent.callee === node.parent + && arrayMethodPattern.test(node.name)) { + context.report(node, "No array mutation allowed."); + } + } + } + } + }, configs: { recommended: { rules: { 'redux/no-let': 2, 'redux/no-this': 2, - 'redux/no-mutation': 2 + 'redux/no-mutation': 2, + 'redux/no-array-mutation': 2 } } - } + } };