From a0f39e34357f460f16c059f961301a73266fb0e3 Mon Sep 17 00:00:00 2001
From: ido <idok@wix.com>
Date: Wed, 19 Aug 2015 13:45:00 +0300
Subject: [PATCH] add lodash3 rules

---
 .eslintrc                 |  9 +++++++--
 Gruntfile.js              |  9 ---------
 package.json              |  1 +
 playground/examples.js    |  2 +-
 src/formatters/stylish.js |  2 +-
 src/reactTemplates.js     | 12 ++++++------
 src/stringUtils.js        |  2 +-
 7 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/.eslintrc b/.eslintrc
index a2389a1..b315d56 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,5 +1,5 @@
 {
-    "plugins": ["react"],
+    "plugins": ["react", "lodash3"],
     "rules": {
         "no-array-constructor": 2,
         "no-catch-shadow": 2,
@@ -156,7 +156,12 @@
         "react/react-in-jsx-scope": 1,
         "react/self-closing-comp": 1,
         "react/wrap-multilines": 1,
-        "react/sort-comp": 1
+        "react/sort-comp": 1,
+
+        "lodash3/prop-shorthand": 2,
+        "lodash3/matches-prop-shorthand": 2,
+        "lodash3/prefer-chain": 1,
+        "lodash3/preferred-alias": 2
     },
     "env": {
         "browser": false,
diff --git a/Gruntfile.js b/Gruntfile.js
index 3a50cbd..8fff0d1 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -15,13 +15,6 @@ module.exports = function (grunt) {
                     '!playground/dist/**/*.js',
                     '!playground/**/*.rt.js'
                 ]
-            },
-            teamcity: {
-                options: {
-                    format: 'checkstyle',
-                    'output-file': 'target/eslint.xml'
-                },
-                src: ['<%= eslint.all.src %>']
             }
         },
         jasmine_node: {
@@ -116,8 +109,6 @@ module.exports = function (grunt) {
     grunt.registerTask('default', ['eslint:all']);
     grunt.registerTask('test', ['node_tap']);
 
-    grunt.registerTask('teamcity', ['eslint:teamcity']);
-
     grunt.registerTask('rt', function () {
         var reactTemplates = require('./src/cli');
         var files = grunt.file.expand('playground/*.rt');
diff --git a/package.json b/package.json
index 3142f51..c6efc9f 100644
--- a/package.json
+++ b/package.json
@@ -36,6 +36,7 @@
     "brace": "^0.5.1",
     "brfs": "^1.4.0",
     "coveralls": "^2.11.3",
+    "eslint-plugin-lodash3": "0.0.0",
     "eslint-plugin-react": "^3.1.0",
     "grunt": "^0.4.5",
     "grunt-browserify": "^3.8.0",
diff --git a/playground/examples.js b/playground/examples.js
index ea5a626..d0a0a8f 100644
--- a/playground/examples.js
+++ b/playground/examples.js
@@ -19,7 +19,7 @@ define(['lodash', 'react', './examples.rt',
     //samples = _.map(samples, function (v, k) {
     //    return {name: k, templateProps: _.template(v[0])({name: k}), templateHTML: v[1]};
     //});
-    _.each(samples, function (v, k) {
+    _.forEach(samples, function (v, k) {
         samples[k] = {name: k, templateProps: _.template(v[0])({name: k}), templateHTML: v[1]};
     });
 
diff --git a/src/formatters/stylish.js b/src/formatters/stylish.js
index fc04e85..857c11e 100644
--- a/src/formatters/stylish.js
+++ b/src/formatters/stylish.js
@@ -120,7 +120,7 @@ module.exports = function (results) {
         infos = 0,
         summaryColor = 'cyan';
 
-    _.each(results, function (result, k) {
+    _.forEach(results, function (result, k) {
         var messages = result;
 
         if (messages.length === 0) {
diff --git a/src/reactTemplates.js b/src/reactTemplates.js
index 48eacb7..69a0035 100644
--- a/src/reactTemplates.js
+++ b/src/reactTemplates.js
@@ -300,7 +300,7 @@ function generateProps(node, context) {
  * @return {string}
  */
 function convertTagNameToConstructor(tagName, context) {
-    var isHtmlTag = _.contains(reactDOMSupport[context.options.targetVersion], tagName);
+    var isHtmlTag = _.includes(reactDOMSupport[context.options.targetVersion], tagName);
     if (shouldUseCreateElement(context)) {
         isHtmlTag = isHtmlTag || tagName.match(/^\w+(-\w+)$/);
         return isHtmlTag ? "'" + tagName + "'" : tagName;
@@ -327,7 +327,7 @@ function defaultContext(html, options) {
  * @return {boolean}
  */
 function hasNonSimpleChildren(node) {
-    return _.any(node.children, function (child) {
+    return _.some(node.children, function (child) {
         return child.type === 'tag' && child.attribs[templateAttr];
     });
 }
@@ -353,13 +353,13 @@ function convertHtmlToReact(node, context) {
 
             // these are variables that were already in scope, unrelated to the ones declared in rt-scope
             data.outerScopeMapping = {};
-            _.each(context.boundParams, function (boundParam) {
+            _.forEach(context.boundParams, function (boundParam) {
                 data.outerScopeMapping[boundParam] = boundParam;
             });
 
             // these are variables declared in the rt-scope attribute
             data.innerScopeMapping = {};
-            _.each(node.attribs[scopeAttr].split(';'), function (scopePart) {
+            _.forEach(node.attribs[scopeAttr].split(';'), function (scopePart) {
                 if (scopePart.trim().length === 0) {
                     return;
                 }
@@ -402,7 +402,7 @@ function convertHtmlToReact(node, context) {
                 data.props = propsTemplateSimple({generatedProps: data.props, rtProps: node.attribs[propsAttr]});
             } else {
                 data.props = propsTemplate({generatedProps: data.props, rtProps: node.attribs[propsAttr]});
-                if (!_.contains(context.injectedFunctions, propsMergeFunction)) {
+                if (!_.includes(context.injectedFunctions, propsMergeFunction)) {
                     context.injectedFunctions.push(propsMergeFunction);
                 }
             }
@@ -466,7 +466,7 @@ function handleSelfClosingHtmlTags(nodes) {
         .map(function (node) {
             var externalNodes = [];
             node.children = handleSelfClosingHtmlTags(node.children);
-            if (node.type === 'tag' && _.contains(htmlSelfClosingTags, node.name)) {
+            if (node.type === 'tag' && _.includes(htmlSelfClosingTags, node.name)) {
                 externalNodes = _.filter(node.children, isTag);
                 _.forEach(externalNodes, function (child) {
                     child.parent = node;
diff --git a/src/stringUtils.js b/src/stringUtils.js
index 703276b..d626e37 100644
--- a/src/stringUtils.js
+++ b/src/stringUtils.js
@@ -22,7 +22,7 @@ function capitalize(str) {
  * @param {*} obj
  */
 function addIfMissing(array, obj) {
-    if (!_.contains(array, obj)) {
+    if (!_.includes(array, obj)) {
         array.push(obj);
     }
 }