From 500b6df9dc3d3d18b56f801c14f434080c37feb1 Mon Sep 17 00:00:00 2001 From: ido Date: Sun, 17 Apr 2016 10:57:57 +0300 Subject: [PATCH] update lodash to 4 update dependencies --- package.json | 29 +++++++++++++++-------------- src/RTCodeError.js | 2 +- src/reactTemplates.js | 12 ++++++------ src/stringUtils.js | 10 +++++++++- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index d9e2558..486d766 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "build": "npm run lint && npm run test", "lint": "eslint .", "test": "node dist-test/src/test.js && node dist-test/src/styleTest.js", + "testd": "node test/src/test.js && node test/src/styleTest.js", "test-cov": "istanbul cover test/src/test.js -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/", "patch": "npm version patch -m\"update version to %s\" && git push && git push --tags", "minor": "npm version minor -m\"update version to %s\" && git push && git push --tags", @@ -30,27 +31,27 @@ }, "homepage": "https://github.com/wix/react-templates", "dependencies": { - "chalk": "^1.1.1", + "chalk": "^1.1.3", "cheerio": "^0.20.0", "css": "^2.2.1", "escodegen": "^1.8.0", "esprima": "^2.7.1", - "lodash": "^3.10.1", + "lodash": "^4.11.1", "optionator": "^0.8.0", "text-table": "^0.2.0" }, "devDependencies": { - "babel-cli": "^6.6.0", - "babel-core": "^6.6.0", + "babel-cli": "^6.7.5", + "babel-core": "^6.7.6", "babel-loader": "^6.2.4", "babel-preset-es2015": "^6.6.0", - "brace": "0.7.0", + "brace": "^0.8.0", "brfs": "^1.4.1", - "coveralls": "^2.11.8", - "eslint": "^2.2.0", + "coveralls": "^2.11.9", + "eslint": "^2.8.0", "eslint-config-wix-editor": "^0.2.3", - "eslint-plugin-lodash": "^1.2.2", - "eslint-plugin-react": "^4.1.0", + "eslint-plugin-lodash": "^1.6.5", + "eslint-plugin-react": "^4.3.0", "eslint-plugin-wix-editor": "^1.1.1", "grunt": "^0.4.5", "grunt-babel": "^6.0.0", @@ -58,15 +59,15 @@ "grunt-contrib-requirejs": "^0.4.4", "grunt-contrib-uglify": "^0.11.0", "grunt-contrib-watch": "^0.6.1", - "grunt-eslint": "^18.0.0", + "grunt-eslint": "^18.1.0", "grunt-tape": "0.0.2", - "istanbul": "^0.4.2", + "istanbul": "^0.4.3", "json-loader": "^0.5.4", "react": "^0.14.2", "react-dom": "^0.14.2", - "react-native": "^0.21.0", - "tape": "^4.4.0", - "webpack": "^1.12.14" + "react-native": "^0.23.1", + "tape": "^4.5.1", + "webpack": "^1.13.0" }, "keywords": [ "templates", diff --git a/src/RTCodeError.js b/src/RTCodeError.js index 5433e7c..bd9382d 100644 --- a/src/RTCodeError.js +++ b/src/RTCodeError.js @@ -102,7 +102,7 @@ function buildFormat(context, node, msg, args) { * @param {Array.} args * @return {RTCodeError} */ -RTCodeError.buildFormat = _.restParam(buildFormat, 3); +RTCodeError.buildFormat = _.rest(buildFormat, 3); /** * @param {*} context diff --git a/src/reactTemplates.js b/src/reactTemplates.js index ca7880f..140f5e6 100644 --- a/src/reactTemplates.js +++ b/src/reactTemplates.js @@ -425,7 +425,7 @@ function convertHtmlToReact(node, context) { // Order matters here. Each rt-repeat iteration wraps over the rt-scope, so // the scope variables are evaluated in context of the current iteration. if (node.attribs[repeatAttr]) { - data.repeatFunction = generateInjectedFunc(context, 'repeat' + _.capitalize(data.item), 'return ' + data.body); + data.repeatFunction = generateInjectedFunc(context, 'repeat' + stringUtils.capitalize(data.item), 'return ' + data.body); data.repeatBinds = ['this'].concat(_.reject(context.boundParams, p => p === data.item || p === data.item + 'Index' || data.innerScope && p in data.innerScope.innerMapping)); data.body = repeatTemplate(data); } @@ -449,8 +449,8 @@ function handleScopeAttribute(node, context, data) { data.innerScope.outerMapping = _.zipObject(context.boundParams, context.boundParams); - _(node.attribs[scopeAttr]).split(';').invoke('trim').compact().forEach(scopePart => { - var scopeSubParts = _(scopePart).split(' as ').invoke('trim').value(); + _(node.attribs[scopeAttr]).split(';').invokeMap('trim').compact().forEach(scopePart => { + var scopeSubParts = _(scopePart).split(' as ').invokeMap('trim').value(); if (scopeSubParts.length < 2) { throw RTCodeError.build(context, node, `invalid scope part '${scopePart}'`); } @@ -463,10 +463,10 @@ function handleScopeAttribute(node, context, data) { // function call, as with the ones we generate for rt-scope. stringUtils.addIfMissing(context.boundParams, alias); - data.innerScope.scopeName += _.capitalize(alias); + data.innerScope.scopeName += stringUtils.capitalize(alias); data.innerScope.innerMapping[alias] = `var ${alias} = ${value};`; validateJS(data.innerScope.innerMapping[alias], node, context); - }).value(); + }); } function validateIfAttribute(node, context, data) { @@ -501,7 +501,7 @@ function handleSelfClosingHtmlTags(nodes) { var externalNodes = []; node.children = handleSelfClosingHtmlTags(node.children); if (node.type === 'tag' && (_.includes(reactSupport.htmlSelfClosingTags, node.name) || - _.includes(reactTemplatesSelfClosingTags, node.name))) { + _.includes(reactTemplatesSelfClosingTags, node.name))) { externalNodes = _.filter(node.children, isTag); _.forEach(externalNodes, i => i.parent = node); node.children = _.reject(node.children, isTag); diff --git a/src/stringUtils.js b/src/stringUtils.js index 9b33a0a..5365cba 100644 --- a/src/stringUtils.js +++ b/src/stringUtils.js @@ -11,4 +11,12 @@ function addIfMissing(array, obj) { } } -module.exports = {addIfMissing}; +/** + * @param {string} str + * @return {string} + */ +function capitalize(str) { + return str[0].toUpperCase() + str.slice(1); +} + +module.exports = {addIfMissing, capitalize};