From da28ea6bc33579c0b5baa31ceb4faf2484f7b76a Mon Sep 17 00:00:00 2001 From: Agustin Colchado Date: Mon, 1 Apr 2024 01:01:17 -0700 Subject: [PATCH] Updates dependencies and removes unneeded Lodash libs (#64) - eslint node plugin is no longer maintained, so switching to the eslint recommended presets that are based on our es2021 settings - removes lodash dependencies that can be replaced by basic native code. - version bump in prep for a release of the changes --- .eslintrc | 37 ----------------- .eslintrc.json | 10 +++++ package-lock.json | 99 --------------------------------------------- package.json | 6 +-- src/SpurConfig.js | 11 ++--- test/.eslintrc | 24 ----------- test/.eslintrc.json | 9 +++++ 7 files changed, 26 insertions(+), 170 deletions(-) delete mode 100644 .eslintrc create mode 100644 .eslintrc.json delete mode 100644 test/.eslintrc create mode 100644 test/.eslintrc.json diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index efd4fa2..0000000 --- a/.eslintrc +++ /dev/null @@ -1,37 +0,0 @@ -{ - "env": { - "es6": true, - "node": true - }, - "plugins": ["node"], - "parserOptions": { - "ecmaVersion": 6 - }, - "rules": { - "node/no-unsupported-features": [2, { - "version": 6 - } - ], - "arrow-parens": ["error", "always"], - "no-shadow": 0, - "radix": 0, - "keyword-spacing": 0, - "consistent-return": 0, - "arrow-body-style": 0, - "no-use-before-define": 0, - "quotes": [ - "error", - "single", - { - "avoidEscape": true - } - ], - "semi": ["error", "always"], - "one-var": [ - "error", - { - "uninitialized": "always" - } - ] - } -} diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..09092c0 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "env": { + "commonjs": true, + "es2021": true, + "node": true + }, + "extends": "eslint:recommended", + "rules": { + } +} diff --git a/package-lock.json b/package-lock.json index 05e983a..0d92fde 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,15 +9,11 @@ "version": "2.0.5", "license": "MIT", "dependencies": { - "lodash.foreach": "4.5.0", - "lodash.isfunction": "3.0.9", "lodash.merge": "4.6.2", "require-all": "3.0.0" }, "devDependencies": { - "@types/jest": "29.5.12", "eslint": "8.57.0", - "eslint-plugin-node": "11.1.0", "jest": "29.7.0" } }, @@ -1260,16 +1256,6 @@ "@types/istanbul-lib-report": "*" } }, - "node_modules/@types/jest": { - "version": "29.5.12", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.12.tgz", - "integrity": "sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==", - "dev": true, - "dependencies": { - "expect": "^29.0.0", - "pretty-format": "^29.0.0" - } - }, "node_modules/@types/node": { "version": "20.11.30", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz", @@ -1959,45 +1945,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint-plugin-es": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", - "integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==", - "dev": true, - "dependencies": { - "eslint-utils": "^2.0.0", - "regexpp": "^3.0.0" - }, - "engines": { - "node": ">=8.10.0" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=4.19.1" - } - }, - "node_modules/eslint-plugin-node": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", - "integrity": "sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==", - "dev": true, - "dependencies": { - "eslint-plugin-es": "^3.0.0", - "eslint-utils": "^2.0.0", - "ignore": "^5.1.1", - "minimatch": "^3.0.4", - "resolve": "^1.10.1", - "semver": "^6.1.0" - }, - "engines": { - "node": ">=8.10.0" - }, - "peerDependencies": { - "eslint": ">=5.16.0" - } - }, "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -2014,30 +1961,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^1.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, - "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/eslint-visitor-keys": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", @@ -3405,16 +3328,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lodash.foreach": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-4.5.0.tgz", - "integrity": "sha512-aEXTF4d+m05rVOAUG3z4vZZ4xVexLKZGF0lIxuHZ1Hplpk/3B6Z1+/ICICYRLm7c41Z2xiejbkCkJoTlypoXhQ==" - }, - "node_modules/lodash.isfunction": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz", - "integrity": "sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw==" - }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -3904,18 +3817,6 @@ "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", "dev": true }, - "node_modules/regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, "node_modules/require-all": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/require-all/-/require-all-3.0.0.tgz", diff --git a/package.json b/package.json index ea2d7e2..a2b89fe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "spur-config", "description": "Configuration framework to help manage complex application configurations in Node.js.", - "version": "2.0.5", + "version": "2.0.6", "main": "./src/SpurConfig", "author": { "name": "Agustin Colchado", @@ -32,15 +32,11 @@ "url": "git://github.com/opentable/spur-config.git" }, "dependencies": { - "lodash.foreach": "4.5.0", - "lodash.isfunction": "3.0.9", "lodash.merge": "4.6.2", "require-all": "3.0.0" }, "devDependencies": { - "@types/jest": "29.5.12", "eslint": "8.57.0", - "eslint-plugin-node": "11.1.0", "jest": "29.7.0" } } diff --git a/src/SpurConfig.js b/src/SpurConfig.js index c1f21ec..983ef5a 100644 --- a/src/SpurConfig.js +++ b/src/SpurConfig.js @@ -1,7 +1,5 @@ const fs = require('fs'); const path = require('path'); -const _forEach = require('lodash.foreach'); -const _isFunction = require('lodash.isfunction'); const _merge = require('lodash.merge'); const requireAll = require('require-all'); @@ -60,9 +58,12 @@ class SpurConfig { } } - loadPluginsByObject(pluginsObject) { - _forEach(pluginsObject, (plugin, pluginName) => { - if (_isFunction(plugin)) { + loadPluginsByObject(pluginsObject = {}) { + const pluginNames = Object.keys(pluginsObject); + + pluginNames.forEach((pluginName) => { + const plugin = pluginsObject[pluginName]; + if (typeof plugin === 'function') { this.plugins[pluginName] = plugin.bind(this); } else { this.loadPluginsByObject(plugin); diff --git a/test/.eslintrc b/test/.eslintrc deleted file mode 100644 index c6ff3a1..0000000 --- a/test/.eslintrc +++ /dev/null @@ -1,24 +0,0 @@ -{ - "extends": "../.eslintrc", - "env": { - "es6": true, - "mocha": true, - "node": true, - "jasmine": true - }, - "globals": { - "sinon": true, - "injector": true, - "testServer": true, - "nock": true, - "_": true - }, - "rules": { - "no-unused-expressions": 0, - "max-len": 0, - "arrow-body-style": 0, - "no-console": 0, - "import/no-extraneous-dependencies": 0, - "import/no-unresolved": 0 - } -} diff --git a/test/.eslintrc.json b/test/.eslintrc.json new file mode 100644 index 0000000..d525306 --- /dev/null +++ b/test/.eslintrc.json @@ -0,0 +1,9 @@ +{ + "extends": "../.eslintrc.json", + "env": { + "jest": true + }, + "rules": { + "no-unused-vars": 0 + } +}