From c20effaa232e7c1cc21843e66abf6354d4067835 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 5 Jul 2016 15:26:42 -0400 Subject: [PATCH 1/4] Framework: Install and enable babel-plugin-lodash --- .babelrc | 3 ++- npm-shrinkwrap.json | 50 ++++++++++++++++++++------------------------- package.json | 1 + 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/.babelrc b/.babelrc index 9ccf5f32b3912..ab13fe0593d28 100644 --- a/.babelrc +++ b/.babelrc @@ -10,6 +10,7 @@ "add-module-exports", "syntax-jsx", "transform-react-jsx", - "transform-react-display-name" + "transform-react-display-name", + "lodash" ] } diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 0535031c18995..55e53f1f0bec0 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -232,7 +232,7 @@ "version": "6.9.0" }, "babel-helper-remap-async-to-generator": { - "version": "6.8.0" + "version": "6.11.2" }, "babel-helper-replace-supers": { "version": "6.8.0" @@ -267,6 +267,14 @@ "babel-plugin-jscript": { "version": "1.0.4" }, + "babel-plugin-lodash": { + "version": "3.2.0", + "dependencies": { + "lodash": { + "version": "4.13.1" + } + } + }, "babel-plugin-member-expression-literals": { "version": "1.0.1" }, @@ -455,7 +463,7 @@ "version": "6.11.1" }, "babylon": { - "version": "6.8.2" + "version": "6.8.3" }, "backo2": { "version": "1.0.2" @@ -491,7 +499,7 @@ "version": "3.1.3" }, "binary-extensions": { - "version": "1.4.1" + "version": "1.5.0" }, "bl": { "version": "1.1.2" @@ -587,7 +595,7 @@ } }, "caniuse-db": { - "version": "1.0.30000488" + "version": "1.0.30000492" }, "caseless": { "version": "0.11.0" @@ -644,7 +652,7 @@ "version": "1.6.0" }, "chrono-node": { - "version": "1.2.3" + "version": "1.2.4" }, "classnames": { "version": "1.1.1" @@ -910,7 +918,7 @@ "version": "1.1.2", "dependencies": { "object-keys": { - "version": "1.0.9" + "version": "1.0.11" } } }, @@ -1101,12 +1109,7 @@ "version": "1.1.1" }, "es5-ext": { - "version": "0.10.11", - "dependencies": { - "es6-symbol": { - "version": "3.0.2" - } - } + "version": "0.10.12" }, "es6-iterator": { "version": "2.0.0" @@ -1219,7 +1222,7 @@ "version": "1.1.3" }, "globals": { - "version": "9.8.0" + "version": "9.9.0" }, "strip-json-comments": { "version": "1.0.4" @@ -2101,7 +2104,7 @@ } }, "loud-rejection": { - "version": "1.5.0" + "version": "1.6.0" }, "lower-case": { "version": "1.1.3" @@ -2278,9 +2281,6 @@ "node-gyp": { "version": "3.4.0", "dependencies": { - "glob": { - "version": "7.0.5" - }, "graceful-fs": { "version": "4.1.4" }, @@ -2371,10 +2371,10 @@ "version": "0.4.0" }, "object.assign": { - "version": "4.0.3", + "version": "4.0.4", "dependencies": { "object-keys": { - "version": "1.0.9" + "version": "1.0.11" } } }, @@ -2609,7 +2609,7 @@ "version": "1.2.4" }, "protochain": { - "version": "1.0.3" + "version": "1.0.5" }, "proxy-addr": { "version": "1.0.10" @@ -2911,7 +2911,7 @@ "version": "0.1.3" }, "rimraf": { - "version": "2.5.2", + "version": "2.5.3", "dependencies": { "glob": { "version": "7.0.5" @@ -2981,12 +2981,6 @@ "cliui": { "version": "3.2.0" }, - "glob": { - "version": "7.0.5" - }, - "minimatch": { - "version": "3.0.2" - }, "set-blocking": { "version": "1.0.0" }, @@ -3403,7 +3397,7 @@ "version": "1.4.2" }, "tiny-emitter": { - "version": "1.0.2" + "version": "1.1.0" }, "tinymce": { "version": "4.3.12" diff --git a/package.json b/package.json index 939d9a4575afa..0f1fa10897653 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "babel-core": "6.9.1", "babel-loader": "6.2.4", "babel-plugin-add-module-exports": "0.2.1", + "babel-plugin-lodash": "3.2.0", "babel-plugin-syntax-jsx": "6.8.0", "babel-plugin-transform-class-properties": "6.9.1", "babel-plugin-transform-export-extensions": "6.8.0", From 1b11aa97bec58b1cdff6a3d2fabe8b0ff6ca86af Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 5 Jul 2016 15:26:53 -0400 Subject: [PATCH 2/4] Framework: Remove no-lodash-import rule from ESLint configuration --- .eslintrc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index fa6da0ea7fb25..d6ba9db125e75 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -115,7 +115,6 @@ module.exports = { // Common top-of-file requires, expressions between external, interal 'vars-on-top': 1, // Custom rules - 'wpcalypso/no-lodash-import': 2, 'wpcalypso/i18n-ellipsis': 1, 'wpcalypso/i18n-no-variables': 1, 'wpcalypso/i18n-no-placeholders-only': 1, From b56e7722ca6858e1b4500458910c8da3f5f2913a Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 5 Jul 2016 15:27:12 -0400 Subject: [PATCH 3/4] State: Import Lodash site selector dependencies from root --- client/state/sites/selectors.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/client/state/sites/selectors.js b/client/state/sites/selectors.js index 35a524437582a..2a838ef150730 100644 --- a/client/state/sites/selectors.js +++ b/client/state/sites/selectors.js @@ -3,12 +3,7 @@ /** * External dependencies */ -import map from 'lodash/map'; -import filter from 'lodash/filter'; -import some from 'lodash/some'; -import includes from 'lodash/includes'; -import find from 'lodash/find'; -import get from 'lodash/get'; +import { map, filter, some, includes, find, get } from 'lodash'; /** * Internal dependencies From 3d5e4d292e270b7b8dfceaf05f797c6a3d424fad Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 5 Jul 2016 15:38:32 -0400 Subject: [PATCH 4/4] Framework: Ensure config test mocks mock only targeted fs functions --- server/config/test/data/mocks.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/config/test/data/mocks.js b/server/config/test/data/mocks.js index a9dc7f490af29..4b12f6303739f 100644 --- a/server/config/test/data/mocks.js +++ b/server/config/test/data/mocks.js @@ -1,4 +1,8 @@ +/** + * External dependencies + */ import path from 'path'; +import fs from 'fs'; function toJSON( val ) { return JSON.stringify( val ); @@ -6,11 +10,13 @@ function toJSON( val ) { export default { INVALID_PATH: { + ...fs, existsSync: () => false, readFileSync: () => '' }, VALID_SECRETS: { + ...fs, existsSync: ( file ) => { switch ( path.basename( file ) ) { case 'secrets.json': @@ -38,6 +44,7 @@ export default { }, VALID_ENV_FILES: { + ...fs, existsSync: ( file ) => { switch ( path.basename( file ) ) { case '_shared.json':