From 4536ba59541451aace697c0d55e71c724b891d90 Mon Sep 17 00:00:00 2001 From: Nadav Kaner Date: Tue, 30 Oct 2018 00:30:03 +0200 Subject: [PATCH] refactor: use object spread --- src/getConfig.js | 5 +++-- src/resolveTaskFn.js | 2 +- test/generateTasks.spec.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/getConfig.js b/src/getConfig.js index da7c4c790..e8576a0ad 100644 --- a/src/getConfig.js +++ b/src/getConfig.js @@ -121,12 +121,13 @@ const optRmMsg = (opt, helpMsg) => ` Option ${chalk.bold(opt)} was removed. */ function validateConfig(config) { debug('Validating config') - const exampleConfig = Object.assign({}, defaultConfig, { + const exampleConfig = { + ...defaultConfig, linters: { '*.js': ['eslint --fix', 'git add'], '*.css': 'stylelint' } - }) + } const deprecatedConfig = { gitDir: () => optRmMsg('gitDir', "lint-staged now automatically resolves '.git' directory."), diff --git a/src/resolveTaskFn.js b/src/resolveTaskFn.js index 49d3dd5ab..226a926d6 100644 --- a/src/resolveTaskFn.js +++ b/src/resolveTaskFn.js @@ -29,7 +29,7 @@ function execLinter(bin, args, execaOptions, pathsToLint) { debug('args: %O', binArgs) debug('opts: %o', execaOptions) - return execa(bin, binArgs, Object.assign({}, execaOptions)) + return execa(bin, binArgs, { ...execaOptions }) } const successMsg = linter => `${symbols.success} ${linter} passed!` diff --git a/test/generateTasks.spec.js b/test/generateTasks.spec.js index 8be57b574..eb426aa0a 100644 --- a/test/generateTasks.spec.js +++ b/test/generateTasks.spec.js @@ -89,7 +89,7 @@ describe('generateTasks', () => { it('should not match non-children files', () => { const relPath = path.join(process.cwd(), '..') resolveGitDir.mockReturnValueOnce(relPath) - const result = generateTasks(Object.assign({}, config), files) + const result = generateTasks({ ...config }, files) const linter = result.find(item => item.pattern === '*.js') expect(linter).toEqual({ pattern: '*.js',