From d883ffc476bb69af24049a11d0561090e24b05f7 Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Fri, 13 Dec 2019 21:15:27 +1300 Subject: [PATCH 1/3] refactor: Replace singular lodash packages with the main one --- index.js | 2 +- lib/options-manager.js | 2 +- package.json | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 136fc15d..81e02ce2 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ const path = require('path'); const eslint = require('eslint'); const globby = require('globby'); -const isEqual = require('lodash.isequal'); +const isEqual = require('lodash/isequal'); const multimatch = require('multimatch'); const arrify = require('arrify'); const optionsManager = require('./lib/options-manager'); diff --git a/lib/options-manager.js b/lib/options-manager.js index 5804a409..94e41314 100644 --- a/lib/options-manager.js +++ b/lib/options-manager.js @@ -2,7 +2,7 @@ const os = require('os'); const path = require('path'); const arrify = require('arrify'); -const mergeWith = require('lodash.mergewith'); +const mergeWith = require('lodash/mergewith'); const multimatch = require('multimatch'); const pathExists = require('path-exists'); const pkgConf = require('pkg-conf'); diff --git a/package.json b/package.json index d193496f..ae8ae1f6 100644 --- a/package.json +++ b/package.json @@ -66,8 +66,7 @@ "get-stdin": "^7.0.0", "globby": "^9.0.0", "has-flag": "^4.0.0", - "lodash.isequal": "^4.5.0", - "lodash.mergewith": "^4.6.2", + "lodash": "^4.17.15", "meow": "^5.0.0", "multimatch": "^4.0.0", "open-editor": "^2.0.1", From 2e6a11560113e7afa5a61487c3ea75ad84892dd5 Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Fri, 13 Dec 2019 21:28:37 +1300 Subject: [PATCH 2/3] fix: lodash functions are camel case Signed-off-by: Richie Bendall --- index.js | 8 ++++---- lib/options-manager.js | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 81e02ce2..a775be4e 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ const path = require('path'); const eslint = require('eslint'); const globby = require('globby'); -const isEqual = require('lodash/isequal'); +const isEqual = require('lodash/isEqual'); const multimatch = require('multimatch'); const arrify = require('arrify'); const optionsManager = require('./lib/options-manager'); @@ -45,7 +45,7 @@ module.exports.lintText = (string, options) => { options = optionsManager.preprocess(options); if (options.overrides && options.overrides.length > 0) { - const {overrides} = options; + const { overrides } = options; delete options.overrides; const filename = path.relative(options.cwd, options.filename); @@ -68,7 +68,7 @@ module.exports.lintText = (string, options) => { if ( multimatch(filename, options.ignores).length > 0 || - globby.gitignore.sync({cwd: options.cwd, ignore: options.ignores})(options.filename) || + globby.gitignore.sync({ cwd: options.cwd, ignore: options.ignores })(options.filename) || engine.isPathIgnored(options.filename) ) { return { @@ -118,7 +118,7 @@ module.exports.lintFiles = async (patterns, options) => { return runEslint(paths, options); } - const {overrides} = options; + const { overrides } = options; delete options.overrides; const grouped = optionsManager.groupConfigs(paths, options, overrides); diff --git a/lib/options-manager.js b/lib/options-manager.js index 94e41314..ebafa97f 100644 --- a/lib/options-manager.js +++ b/lib/options-manager.js @@ -2,7 +2,7 @@ const os = require('os'); const path = require('path'); const arrify = require('arrify'); -const mergeWith = require('lodash/mergewith'); +const mergeWith = require('lodash/mergeWith'); const multimatch = require('multimatch'); const pathExists = require('path-exists'); const pkgConf = require('pkg-conf'); @@ -31,7 +31,7 @@ const DEFAULT_EXTENSION = [ const DEFAULT_CONFIG = { useEslintrc: false, cache: true, - cacheLocation: findCacheDir({name: 'xo'}) || path.join(os.homedir() || os.tmpdir(), '.xo-cache/'), + cacheLocation: findCacheDir({ name: 'xo' }) || path.join(os.homedir() || os.tmpdir(), '.xo-cache/'), globInputPaths: false, baseConfig: { extends: [ @@ -121,7 +121,7 @@ const mergeFn = (previousValue, value) => { }; const normalizeOptions = options => { - options = {...options}; + options = { ...options }; // Aliases for humans const aliases = [ @@ -162,8 +162,8 @@ const mergeWithPackageConfig = options => { }; options.cwd = path.resolve(options.cwd); - const config = pkgConf.sync('xo', {cwd: options.cwd, skipOnFalse: true}); - const engines = pkgConf.sync('engines', {cwd: options.cwd}); + const config = pkgConf.sync('xo', { cwd: options.cwd, skipOnFalse: true }); + const engines = pkgConf.sync('engines', { cwd: options.cwd }); return { ...config, @@ -236,7 +236,7 @@ const buildConfig = options => { } if (options.space && !options.prettier) { - config.rules.indent = ['error', spaces, {SwitchCase: 1}]; + config.rules.indent = ['error', spaces, { SwitchCase: 1 }]; // Only apply if the user has the React plugin if (options.cwd && resolveFrom.silent(options.cwd, 'eslint-plugin-react')) { From ef576b13898994af54dfaf895cc5ec2b9d93e58c Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Sat, 14 Dec 2019 00:15:05 +1300 Subject: [PATCH 3/3] style: Object destructuring instead of paths and remove extra spaces in objects --- index.js | 8 ++++---- lib/options-manager.js | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index a775be4e..f4c43129 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ const path = require('path'); const eslint = require('eslint'); const globby = require('globby'); -const isEqual = require('lodash/isEqual'); +const {isEqual} = require('lodash'); const multimatch = require('multimatch'); const arrify = require('arrify'); const optionsManager = require('./lib/options-manager'); @@ -45,7 +45,7 @@ module.exports.lintText = (string, options) => { options = optionsManager.preprocess(options); if (options.overrides && options.overrides.length > 0) { - const { overrides } = options; + const {overrides} = options; delete options.overrides; const filename = path.relative(options.cwd, options.filename); @@ -68,7 +68,7 @@ module.exports.lintText = (string, options) => { if ( multimatch(filename, options.ignores).length > 0 || - globby.gitignore.sync({ cwd: options.cwd, ignore: options.ignores })(options.filename) || + globby.gitignore.sync({cwd: options.cwd, ignore: options.ignores})(options.filename) || engine.isPathIgnored(options.filename) ) { return { @@ -118,7 +118,7 @@ module.exports.lintFiles = async (patterns, options) => { return runEslint(paths, options); } - const { overrides } = options; + const {overrides} = options; delete options.overrides; const grouped = optionsManager.groupConfigs(paths, options, overrides); diff --git a/lib/options-manager.js b/lib/options-manager.js index ebafa97f..2aa067b8 100644 --- a/lib/options-manager.js +++ b/lib/options-manager.js @@ -2,7 +2,7 @@ const os = require('os'); const path = require('path'); const arrify = require('arrify'); -const mergeWith = require('lodash/mergeWith'); +const {mergeWith} = require('lodash'); const multimatch = require('multimatch'); const pathExists = require('path-exists'); const pkgConf = require('pkg-conf'); @@ -31,7 +31,7 @@ const DEFAULT_EXTENSION = [ const DEFAULT_CONFIG = { useEslintrc: false, cache: true, - cacheLocation: findCacheDir({ name: 'xo' }) || path.join(os.homedir() || os.tmpdir(), '.xo-cache/'), + cacheLocation: findCacheDir({name: 'xo'}) || path.join(os.homedir() || os.tmpdir(), '.xo-cache/'), globInputPaths: false, baseConfig: { extends: [ @@ -121,7 +121,7 @@ const mergeFn = (previousValue, value) => { }; const normalizeOptions = options => { - options = { ...options }; + options = {...options}; // Aliases for humans const aliases = [ @@ -162,8 +162,8 @@ const mergeWithPackageConfig = options => { }; options.cwd = path.resolve(options.cwd); - const config = pkgConf.sync('xo', { cwd: options.cwd, skipOnFalse: true }); - const engines = pkgConf.sync('engines', { cwd: options.cwd }); + const config = pkgConf.sync('xo', {cwd: options.cwd, skipOnFalse: true}); + const engines = pkgConf.sync('engines', {cwd: options.cwd}); return { ...config, @@ -236,7 +236,7 @@ const buildConfig = options => { } if (options.space && !options.prettier) { - config.rules.indent = ['error', spaces, { SwitchCase: 1 }]; + config.rules.indent = ['error', spaces, {SwitchCase: 1}]; // Only apply if the user has the React plugin if (options.cwd && resolveFrom.silent(options.cwd, 'eslint-plugin-react')) {