Skip to content

Commit e093b1d

Browse files
authoredApr 19, 2020
fix(deps): update dependencies
1 parent 6066b07 commit e093b1d

22 files changed

+2076
-1916
lines changed
 

‎bin/lint-staged.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const options = {
8181
debug('Options parsed from command-line:', options)
8282

8383
lintStaged(options)
84-
.then(passed => {
84+
.then((passed) => {
8585
process.exitCode = passed ? 0 : 1
8686
})
8787
.catch(() => {

‎lib/chunkFiles.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = function chunkFiles({ files, baseDir, maxArgLength = null, rela
3838
return [files]
3939
}
4040

41-
const normalizedFiles = files.map(file =>
41+
const normalizedFiles = files.map((file) =>
4242
normalize(relative || !baseDir ? file : path.resolve(baseDir, file))
4343
)
4444
const fileListLength = normalizedFiles.join(' ').length

‎lib/generateTasks.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ module.exports = function generateTasks({
2525
}) {
2626
debug('Generating linter tasks')
2727

28-
const absoluteFiles = files.map(file => normalize(path.resolve(gitDir, file)))
29-
const relativeFiles = absoluteFiles.map(file => normalize(path.relative(cwd, file)))
28+
const absoluteFiles = files.map((file) => normalize(path.resolve(gitDir, file)))
29+
const relativeFiles = absoluteFiles.map((file) => normalize(path.relative(cwd, file)))
3030

3131
return Object.entries(config).map(([pattern, commands]) => {
3232
const isParentDirPattern = pattern.startsWith('../')
@@ -35,7 +35,7 @@ module.exports = function generateTasks({
3535
relativeFiles
3636
// Only worry about children of the CWD unless the pattern explicitly
3737
// specifies that it concerns a parent directory.
38-
.filter(file => {
38+
.filter((file) => {
3939
if (isParentDirPattern) return true
4040
return !file.startsWith('..') && !path.isAbsolute(file)
4141
}),
@@ -48,7 +48,7 @@ module.exports = function generateTasks({
4848
// match both `test.js` and `subdirectory/test.js`.
4949
matchBase: !pattern.includes('/')
5050
}
51-
).map(file => normalize(relative ? file : path.resolve(cwd, file)))
51+
).map((file) => normalize(relative ? file : path.resolve(cwd, file)))
5252

5353
const task = { pattern, commands, fileList }
5454
debug('Generated task: \n%O', task)

‎lib/gitWorkflow.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class GitWorkflow {
8585
*/
8686
async getBackupStash(ctx) {
8787
const stashes = await this.execGit(['stash', 'list'])
88-
const index = stashes.split('\n').findIndex(line => line.includes(STASH))
88+
const index = stashes.split('\n').findIndex((line) => line.includes(STASH))
8989
if (index === -1) {
9090
ctx.gitGetBackupStashError = true
9191
throw new Error('lint-staged automatic backup is missing!')
@@ -102,7 +102,7 @@ class GitWorkflow {
102102
const deletedFiles = lsFiles
103103
.split('\n')
104104
.filter(Boolean)
105-
.map(file => path.resolve(this.gitDir, file))
105+
.map((file) => path.resolve(this.gitDir, file))
106106
debug('Found deleted files:', deletedFiles)
107107
return deletedFiles
108108
}
@@ -113,9 +113,9 @@ class GitWorkflow {
113113
async backupMergeStatus() {
114114
debug('Backing up merge state...')
115115
await Promise.all([
116-
readFile(this.mergeHeadFilename).then(buffer => (this.mergeHeadBuffer = buffer)),
117-
readFile(this.mergeModeFilename).then(buffer => (this.mergeModeBuffer = buffer)),
118-
readFile(this.mergeMsgFilename).then(buffer => (this.mergeMsgBuffer = buffer))
116+
readFile(this.mergeHeadFilename).then((buffer) => (this.mergeHeadBuffer = buffer)),
117+
readFile(this.mergeModeFilename).then((buffer) => (this.mergeModeBuffer = buffer)),
118+
readFile(this.mergeMsgFilename).then((buffer) => (this.mergeMsgBuffer = buffer))
119119
])
120120
debug('Done backing up merge state!')
121121
}
@@ -149,7 +149,7 @@ class GitWorkflow {
149149
const status = await this.execGit(['status', '--porcelain'])
150150
const partiallyStaged = status
151151
.split('\n')
152-
.filter(line => {
152+
.filter((line) => {
153153
/**
154154
* See https://git-scm.com/docs/git-status#_short_format
155155
* The first letter of the line represents current index status,
@@ -158,7 +158,7 @@ class GitWorkflow {
158158
const [index, workingTree] = line
159159
return index !== ' ' && workingTree !== ' ' && index !== '?' && workingTree !== '?'
160160
})
161-
.map(line => line.substr(3)) // Remove first three letters (index, workingTree, and a whitespace)
161+
.map((line) => line.substr(3)) // Remove first three letters (index, workingTree, and a whitespace)
162162
debug('Found partially staged files:', partiallyStaged)
163163
return partiallyStaged.length ? partiallyStaged : null
164164
}
@@ -203,7 +203,7 @@ class GitWorkflow {
203203
await this.restoreMergeStatus()
204204

205205
// If stashing resurrected deleted files, clean them out
206-
await Promise.all(this.deletedFiles.map(file => unlink(file)))
206+
await Promise.all(this.deletedFiles.map((file) => unlink(file)))
207207

208208
debug('Done backing up original state!')
209209
} catch (error) {
@@ -303,7 +303,7 @@ class GitWorkflow {
303303
await this.restoreMergeStatus()
304304

305305
// If stashing resurrected deleted files, clean them out
306-
await Promise.all(this.deletedFiles.map(file => unlink(file)))
306+
await Promise.all(this.deletedFiles.map((file) => unlink(file)))
307307

308308
// Clean out patch
309309
await unlink(this.getHiddenFilepath(PATCH_UNSTAGED))

‎lib/printErrors.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
// istanbul ignore next
44
// Work-around for duplicated error logs, see #142
5-
const errMsg = err => (err.privateMsg != null ? err.privateMsg : err.message)
5+
const errMsg = (err) => (err.privateMsg != null ? err.privateMsg : err.message)
66

77
module.exports = function printErrors(errorInstance, logger) {
88
if (Array.isArray(errorInstance.errors)) {
9-
errorInstance.errors.forEach(lintError => {
9+
errorInstance.errors.forEach((lintError) => {
1010
logger.error(errMsg(lintError))
1111
})
1212
} else {

‎lib/resolveGitRepo.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const fsLstat = promisify(fs.lstat)
1515
* Resolve path to the .git directory, with special handling for
1616
* submodules and worktrees
1717
*/
18-
const resolveGitConfigDir = async gitDir => {
18+
const resolveGitConfigDir = async (gitDir) => {
1919
const defaultDir = normalize(path.join(gitDir, '.git'))
2020
const stats = await fsLstat(defaultDir)
2121
// If .git is a directory, use it
@@ -28,7 +28,7 @@ const resolveGitConfigDir = async gitDir => {
2828
/**
2929
* Resolve git directory and possible submodule paths
3030
*/
31-
const resolveGitRepo = async cwd => {
31+
const resolveGitRepo = async (cwd) => {
3232
try {
3333
debugLog('Resolving git repo from `%s`', cwd)
3434

‎lib/resolveTaskFn.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const symbols = require('log-symbols')
88

99
const debug = require('debug')('lint-staged:task')
1010

11-
const successMsg = linter => `${symbols.success} ${linter} passed!`
11+
const successMsg = (linter) => `${symbols.success} ${linter} passed!`
1212

1313
/**
1414
* Create and returns an error instance with a given message.
@@ -81,7 +81,7 @@ module.exports = function resolveTaskFn({ command, files, gitDir, isFn, relative
8181
}
8282
debug('execaOptions:', execaOptions)
8383

84-
return async ctx => {
84+
return async (ctx) => {
8585
const promise = shell
8686
? execa.command(isFn ? command : `${command} ${files.join(' ')}`, execaOptions)
8787
: execa(cmd, isFn ? args : args.concat(files), execaOptions)

‎lib/runAll.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const MESSAGES = {
2929
GIT_ERROR: 'Skipped because of previous git error.'
3030
}
3131

32-
const shouldSkipApplyModifications = ctx => {
32+
const shouldSkipApplyModifications = (ctx) => {
3333
// Should be skipped in case of git errors
3434
if (ctx.gitError) {
3535
return MESSAGES.GIT_ERROR
@@ -40,14 +40,14 @@ const shouldSkipApplyModifications = ctx => {
4040
}
4141
}
4242

43-
const shouldSkipRevert = ctx => {
43+
const shouldSkipRevert = (ctx) => {
4444
// Should be skipped in case of unknown git errors
4545
if (ctx.gitError && !ctx.gitApplyEmptyCommitError && !ctx.gitRestoreUnstagedChangesError) {
4646
return MESSAGES.GIT_ERROR
4747
}
4848
}
4949

50-
const shouldSkipCleanup = ctx => {
50+
const shouldSkipCleanup = (ctx) => {
5151
// Should be skipped in case of unknown git errors
5252
if (ctx.gitError && !ctx.gitApplyEmptyCommitError && !ctx.gitRestoreUnstagedChangesError) {
5353
return MESSAGES.GIT_ERROR
@@ -149,11 +149,11 @@ const runAll = async (
149149
})
150150

151151
// Add files from task to match set
152-
task.fileList.forEach(file => {
152+
task.fileList.forEach((file) => {
153153
matchedFiles.add(file)
154154
})
155155

156-
hasDeprecatedGitAdd = subTasks.some(subTask => subTask.command === 'git add')
156+
hasDeprecatedGitAdd = subTasks.some((subTask) => subTask.command === 'git add')
157157

158158
chunkListrTasks.push({
159159
title: `Running tasks for ${task.pattern}`,
@@ -184,7 +184,7 @@ const runAll = async (
184184
// Skip if the first step (backup) failed
185185
if (ctx.gitError) return MESSAGES.GIT_ERROR
186186
// Skip chunk when no every task is skipped (due to no matches)
187-
if (chunkListrTasks.every(task => task.skip())) return 'No tasks to run.'
187+
if (chunkListrTasks.every((task) => task.skip())) return 'No tasks to run.'
188188
return false
189189
}
190190
})
@@ -199,7 +199,7 @@ const runAll = async (
199199

200200
// If all of the configured tasks should be skipped
201201
// avoid executing any lint-staged logic
202-
if (listrTasks.every(task => task.skip())) {
202+
if (listrTasks.every((task) => task.skip())) {
203203
logger.log('No staged files match any of provided globs.')
204204
return 'No tasks to run.'
205205
}
@@ -210,37 +210,37 @@ const runAll = async (
210210
[
211211
{
212212
title: 'Preparing...',
213-
task: ctx => git.prepare(ctx, shouldBackup)
213+
task: (ctx) => git.prepare(ctx, shouldBackup)
214214
},
215215
{
216216
title: 'Hiding unstaged changes to partially staged files...',
217-
task: ctx => git.hideUnstagedChanges(ctx),
218-
enabled: ctx => ctx.hasPartiallyStagedFiles
217+
task: (ctx) => git.hideUnstagedChanges(ctx),
218+
enabled: (ctx) => ctx.hasPartiallyStagedFiles
219219
},
220220
...listrTasks,
221221
{
222222
title: 'Applying modifications...',
223-
task: ctx => git.applyModifications(ctx),
223+
task: (ctx) => git.applyModifications(ctx),
224224
// Always apply back unstaged modifications when skipping backup
225-
skip: ctx => shouldBackup && shouldSkipApplyModifications(ctx)
225+
skip: (ctx) => shouldBackup && shouldSkipApplyModifications(ctx)
226226
},
227227
{
228228
title: 'Restoring unstaged changes to partially staged files...',
229-
task: ctx => git.restoreUnstagedChanges(ctx),
230-
enabled: ctx => ctx.hasPartiallyStagedFiles,
229+
task: (ctx) => git.restoreUnstagedChanges(ctx),
230+
enabled: (ctx) => ctx.hasPartiallyStagedFiles,
231231
skip: shouldSkipApplyModifications
232232
},
233233
{
234234
title: 'Reverting to original state because of errors...',
235-
task: ctx => git.restoreOriginalState(ctx),
236-
enabled: ctx =>
235+
task: (ctx) => git.restoreOriginalState(ctx),
236+
enabled: (ctx) =>
237237
shouldBackup &&
238238
(ctx.taskError || ctx.gitApplyEmptyCommitError || ctx.gitRestoreUnstagedChangesError),
239239
skip: shouldSkipRevert
240240
},
241241
{
242242
title: 'Cleaning up...',
243-
task: ctx => git.cleanup(ctx),
243+
task: (ctx) => git.cleanup(ctx),
244244
enabled: () => shouldBackup,
245245
skip: shouldSkipCleanup
246246
}

‎lib/validateConfig.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ const format = require('stringify-object')
88
const debug = require('debug')('lint-staged:cfg')
99

1010
const TEST_DEPRECATED_KEYS = new Map([
11-
['concurrent', key => typeof key === 'boolean'],
12-
['chunkSize', key => typeof key === 'number'],
13-
['globOptions', key => typeof key === 'object'],
14-
['linters', key => typeof key === 'object'],
15-
['ignore', key => Array.isArray(key)],
16-
['subTaskConcurrency', key => typeof key === 'number'],
17-
['renderer', key => typeof key === 'string'],
18-
['relative', key => typeof key === 'boolean']
11+
['concurrent', (key) => typeof key === 'boolean'],
12+
['chunkSize', (key) => typeof key === 'number'],
13+
['globOptions', (key) => typeof key === 'object'],
14+
['linters', (key) => typeof key === 'object'],
15+
['ignore', (key) => Array.isArray(key)],
16+
['subTaskConcurrency', (key) => typeof key === 'number'],
17+
['renderer', (key) => typeof key === 'string'],
18+
['relative', (key) => typeof key === 'boolean']
1919
])
2020

21-
const formatError = helpMsg => `● Validation Error:
21+
const formatError = (helpMsg) => `● Validation Error:
2222
2323
${helpMsg}
2424
@@ -68,7 +68,7 @@ module.exports = function validateConfig(config) {
6868

6969
if (
7070
(!Array.isArray(task) ||
71-
task.some(item => typeof item !== 'string' && typeof item !== 'function')) &&
71+
task.some((item) => typeof item !== 'string' && typeof item !== 'function')) &&
7272
typeof task !== 'string' &&
7373
typeof task !== 'function'
7474
) {

‎package.json

+20-20
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
}
3535
},
3636
"dependencies": {
37-
"chalk": "^3.0.0",
38-
"commander": "^4.0.1",
37+
"chalk": "^4.0.0",
38+
"commander": "^5.0.0",
3939
"cosmiconfig": "^6.0.0",
4040
"debug": "^4.1.1",
4141
"dedent": "^0.7.0",
42-
"execa": "^3.4.0",
42+
"execa": "^4.0.0",
4343
"listr": "^0.14.3",
4444
"log-symbols": "^3.0.0",
4545
"micromatch": "^4.0.2",
@@ -49,27 +49,27 @@
4949
"stringify-object": "^3.3.0"
5050
},
5151
"devDependencies": {
52-
"@babel/core": "^7.7.4",
53-
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
54-
"@babel/preset-env": "^7.7.4",
55-
"babel-eslint": "^10.0.3",
56-
"babel-jest": "^24.9.0",
52+
"@babel/core": "^7.9.0",
53+
"@babel/plugin-proposal-object-rest-spread": "^7.9.5",
54+
"@babel/preset-env": "^7.9.5",
55+
"babel-eslint": "^10.1.0",
56+
"babel-jest": "^25.3.0",
5757
"consolemock": "^1.1.0",
58-
"eslint": "^6.7.2",
58+
"eslint": "^6.8.0",
5959
"eslint-config-okonet": "^7.0.2",
60-
"eslint-config-prettier": "^6.7.0",
61-
"eslint-plugin-flowtype": "^4.5.2",
62-
"eslint-plugin-import": "^2.18.2",
60+
"eslint-config-prettier": "^6.10.1",
61+
"eslint-plugin-flowtype": "^4.7.0",
62+
"eslint-plugin-import": "^2.20.2",
6363
"eslint-plugin-jsx-a11y": "^6.2.3",
64-
"eslint-plugin-node": "^10.0.0",
65-
"eslint-plugin-prettier": "^3.1.1",
66-
"eslint-plugin-react": "^7.17.0",
67-
"fs-extra": "^8.1.0",
68-
"husky": "^3.1.0",
69-
"jest": "^24.9.0",
64+
"eslint-plugin-node": "^11.1.0",
65+
"eslint-plugin-prettier": "^3.1.3",
66+
"eslint-plugin-react": "^7.19.0",
67+
"fs-extra": "^9.0.0",
68+
"husky": "^4.2.5",
69+
"jest": "^25.3.0",
7070
"jest-snapshot-serializer-ansi": "^1.0.0",
71-
"nanoid": "^2.1.7",
72-
"prettier": "^1.19.1"
71+
"nanoid": "^3.1.3",
72+
"prettier": "^2.0.4"
7373
},
7474
"config": {
7575
"commitizen": {

‎test/__mocks__/advanced-config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
'*.css': filenames => `echo ${filenames.join(' ')}`,
3-
'*.js': filenames => filenames.map(filename => `echo ${filename}`)
2+
'*.css': (filenames) => `echo ${filenames.join(' ')}`,
3+
'*.js': (filenames) => filenames.map((filename) => `echo ${filename}`)
44
}

‎test/__mocks__/npm-which.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const mockFn = jest.fn(path => {
1+
const mockFn = jest.fn((path) => {
22
if (path.includes('missing')) {
33
throw new Error(`not found: ${path}`)
44
}

‎test/chunkFiles.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('chunkFiles', () => {
1616

1717
it('should chunk too long argument string', () => {
1818
const chunkedFiles = chunkFiles({ baseDir, files, maxArgLength: 20 })
19-
expect(chunkedFiles).toEqual(files.map(file => [file]))
19+
expect(chunkedFiles).toEqual(files.map((file) => [file]))
2020
})
2121

2222
it('should take into account relative setting', () => {

‎test/generateTasks.spec.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from 'path'
55
import generateTasks from '../lib/generateTasks'
66
import resolveGitRepo from '../lib/resolveGitRepo'
77

8-
const normalizePath = path => normalize(path)
8+
const normalizePath = (path) => normalize(path)
99

1010
const files = [
1111
'test.js',
@@ -52,15 +52,15 @@ describe('generateTasks', () => {
5252
gitDir,
5353
files
5454
})
55-
task.fileList.forEach(file => {
55+
task.fileList.forEach((file) => {
5656
expect(path.isAbsolute(file)).toBe(true)
5757
})
5858
})
5959

6060
it('should not match non-children files', async () => {
6161
const relPath = path.join(process.cwd(), '..')
6262
const result = await generateTasks({ config, cwd, gitDir: relPath, files })
63-
const linter = result.find(item => item.pattern === '*.js')
63+
const linter = result.find((item) => item.pattern === '*.js')
6464
expect(linter).toEqual({
6565
pattern: '*.js',
6666
commands: 'root-js',
@@ -71,7 +71,7 @@ describe('generateTasks', () => {
7171
it('should return an empty file list for linters with no matches.', async () => {
7272
const result = await generateTasks({ config, cwd, gitDir, files })
7373

74-
result.forEach(task => {
74+
result.forEach((task) => {
7575
if (task.commands === 'unknown-js' || task.commands === 'parent-dir-css-or-js') {
7676
expect(task.fileList.length).toEqual(0)
7777
} else {
@@ -82,7 +82,7 @@ describe('generateTasks', () => {
8282

8383
it('should match pattern "*.js"', async () => {
8484
const result = await generateTasks({ config, cwd, gitDir, files })
85-
const linter = result.find(item => item.pattern === '*.js')
85+
const linter = result.find((item) => item.pattern === '*.js')
8686
expect(linter).toEqual({
8787
pattern: '*.js',
8888
commands: 'root-js',
@@ -98,7 +98,7 @@ describe('generateTasks', () => {
9898

9999
it('should match pattern "**/*.js"', async () => {
100100
const result = await generateTasks({ config, cwd, gitDir, files })
101-
const linter = result.find(item => item.pattern === '**/*.js')
101+
const linter = result.find((item) => item.pattern === '**/*.js')
102102
expect(linter).toEqual({
103103
pattern: '**/*.js',
104104
commands: 'any-js',
@@ -114,7 +114,7 @@ describe('generateTasks', () => {
114114

115115
it('should match pattern "deeper/*.js"', async () => {
116116
const result = await generateTasks({ config, cwd, gitDir, files })
117-
const linter = result.find(item => item.pattern === 'deeper/*.js')
117+
const linter = result.find((item) => item.pattern === 'deeper/*.js')
118118
expect(linter).toEqual({
119119
pattern: 'deeper/*.js',
120120
commands: 'deeper-js',
@@ -124,7 +124,7 @@ describe('generateTasks', () => {
124124

125125
it('should match pattern ".hidden/*.js"', async () => {
126126
const result = await generateTasks({ config, cwd, gitDir, files })
127-
const linter = result.find(item => item.pattern === '.hidden/*.js')
127+
const linter = result.find((item) => item.pattern === '.hidden/*.js')
128128
expect(linter).toEqual({
129129
pattern: '.hidden/*.js',
130130
commands: 'hidden-js',
@@ -134,7 +134,7 @@ describe('generateTasks', () => {
134134

135135
it('should match pattern "*.{css,js}"', async () => {
136136
const result = await generateTasks({ config, cwd, gitDir, files })
137-
const linter = result.find(item => item.pattern === '*.{css,js}')
137+
const linter = result.find((item) => item.pattern === '*.{css,js}')
138138
expect(linter).toEqual({
139139
pattern: '*.{css,js}',
140140
commands: 'root-css-or-js',
@@ -160,7 +160,7 @@ describe('generateTasks', () => {
160160
gitDir,
161161
files
162162
})
163-
const linter = result.find(item => item.pattern === '*.js')
163+
const linter = result.find((item) => item.pattern === '*.js')
164164
expect(linter).toEqual({
165165
pattern: '*.js',
166166
commands: 'root-js',
@@ -175,7 +175,7 @@ describe('generateTasks', () => {
175175
gitDir,
176176
files
177177
})
178-
const linter = result.find(item => item.pattern === '../*.{css,js}')
178+
const linter = result.find((item) => item.pattern === '../*.{css,js}')
179179
expect(linter).toEqual({
180180
commands: 'parent-dir-css-or-js',
181181
fileList: [`${gitDir}/test.js`, `${gitDir}/test.css`].map(normalizePath),
@@ -185,7 +185,7 @@ describe('generateTasks', () => {
185185

186186
it('should be able to return relative paths for "*.{css,js}"', async () => {
187187
const result = await generateTasks({ config, cwd, gitDir, files, relative: true })
188-
const linter = result.find(item => item.pattern === '*.{css,js}')
188+
const linter = result.find((item) => item.pattern === '*.{css,js}')
189189
expect(linter).toEqual({
190190
pattern: '*.{css,js}',
191191
commands: 'root-css-or-js',

‎test/gitWorkflow.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import fs from 'fs-extra'
2+
import { nanoid } from 'nanoid'
23
import normalize from 'normalize-path'
34
import os from 'os'
45
import path from 'path'
5-
import nanoid from 'nanoid'
66

77
import execGitBase from '../lib/execGit'
88
import GitWorkflow from '../lib/gitWorkflow'
@@ -29,7 +29,7 @@ const createTempDir = async () => {
2929
* @param {String} dirname
3030
* @returns {Promise<Void>}
3131
*/
32-
const removeTempDir = async dirname => {
32+
const removeTempDir = async (dirname) => {
3333
await fs.remove(dirname)
3434
}
3535

@@ -40,7 +40,7 @@ const appendFile = async (filename, content, dir = cwd) =>
4040
fs.appendFile(path.resolve(dir, filename), content)
4141

4242
/** Wrap execGit to always pass `gitOps` */
43-
const execGit = async args => execGitBase(args, { cwd })
43+
const execGit = async (args) => execGitBase(args, { cwd })
4444

4545
/** Initialize git repo for test */
4646
const initGitRepo = async () => {

‎test/index.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import lintStaged from '../lib/index'
1212
jest.mock('../lib/getStagedFiles')
1313

1414
const replaceSerializer = (from, to) => ({
15-
test: val => typeof val === 'string' && from.test(val),
16-
print: val => val.replace(from, to)
15+
test: (val) => typeof val === 'string' && from.test(val),
16+
print: (val) => val.replace(from, to)
1717
})
1818

19-
const mockCosmiconfigWith = result => {
19+
const mockCosmiconfigWith = (result) => {
2020
cosmiconfig.mockImplementationOnce(() => ({
2121
search: () => Promise.resolve(result)
2222
}))

‎test/makeCmdTasks.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('makeCmdTasks', () => {
7777

7878
it('should work with function task accepting arguments', async () => {
7979
const res = await makeCmdTasks({
80-
commands: filenames => filenames.map(file => `test ${file}`),
80+
commands: (filenames) => filenames.map((file) => `test ${file}`),
8181
gitDir,
8282
files: ['test.js', 'test2.js']
8383
})
@@ -88,7 +88,7 @@ describe('makeCmdTasks', () => {
8888

8989
it('should work with array of mixed string and function tasks', async () => {
9090
const res = await makeCmdTasks({
91-
commands: [() => 'test', 'test2', files => files.map(file => `test ${file}`)],
91+
commands: [() => 'test', 'test2', (files) => files.map((file) => `test ${file}`)],
9292
gitDir,
9393
files: ['test.js', 'test2.js', 'test3.js']
9494
})

‎test/runAll.unmocked.2.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import fs from 'fs-extra'
21
import makeConsoleMock from 'consolemock'
2+
import fs from 'fs-extra'
3+
import { nanoid } from 'nanoid'
34
import normalize from 'normalize-path'
45
import os from 'os'
56
import path from 'path'
6-
import nanoid from 'nanoid'
77

88
jest.mock('../lib/file')
99

@@ -38,7 +38,7 @@ const createTempDir = async () => {
3838
* @param {String} dirname
3939
* @returns {Promise<Void>}
4040
*/
41-
const removeTempDir = async dirname => {
41+
const removeTempDir = async (dirname) => {
4242
await fs.remove(dirname)
4343
}
4444

@@ -50,7 +50,7 @@ const appendFile = async (filename, content, dir = cwd) =>
5050
fs.appendFile(path.join(dir, filename), content)
5151

5252
// Wrap execGit to always pass `gitOps`
53-
const execGit = async args => execGitBase(args, { cwd })
53+
const execGit = async (args) => execGitBase(args, { cwd })
5454

5555
// Execute runAll before git commit to emulate lint-staged
5656
const gitCommit = async (options, args = ['-m test']) => {

‎test/runAll.unmocked.spec.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import fs from 'fs-extra'
21
import makeConsoleMock from 'consolemock'
2+
import fs from 'fs-extra'
3+
import { nanoid } from 'nanoid'
34
import normalize from 'normalize-path'
45
import os from 'os'
56
import path from 'path'
6-
import nanoid from 'nanoid'
77

88
jest.unmock('execa')
99

@@ -13,12 +13,12 @@ import runAll from '../lib/runAll'
1313
jest.setTimeout(20000)
1414

1515
const testJsFilePretty = `module.exports = {
16-
foo: "bar"
16+
foo: "bar",
1717
};
1818
`
1919

2020
const testJsFileUgly = `module.exports = {
21-
'foo': 'bar',
21+
'foo': 'bar'
2222
}
2323
`
2424

@@ -46,7 +46,7 @@ const createTempDir = async () => {
4646
* @param {String} dirname
4747
* @returns {Promise<Void>}
4848
*/
49-
const removeTempDir = async dirname => {
49+
const removeTempDir = async (dirname) => {
5050
await fs.remove(dirname)
5151
}
5252

@@ -412,7 +412,7 @@ describe('runAll', () => {
412412
await expect(
413413
gitCommit({
414414
config: {
415-
'*.js': files => [
415+
'*.js': (files) => [
416416
`touch ${cwd}/.git/index.lock`,
417417
`prettier --write ${files.join(' ')}`,
418418
`git add ${files.join(' ')}`
@@ -440,14 +440,14 @@ describe('runAll', () => {
440440
expect(await execGit(['diff'])).not.toEqual(diff)
441441
expect(await execGit(['diff'])).toMatchInlineSnapshot(`
442442
"diff --git a/test.js b/test.js
443-
index f80f875..1c5643c 100644
443+
index 1eff6a0..8baadc8 100644
444444
--- a/test.js
445445
+++ b/test.js
446446
@@ -1,3 +1,3 @@
447447
module.exports = {
448-
- 'foo': 'bar',
448+
- 'foo': 'bar'
449449
-}
450-
+ foo: \\"bar\\"
450+
+ foo: \\"bar\\",
451451
+};"
452452
`)
453453

@@ -905,7 +905,7 @@ describe('runAll', () => {
905905

906906
test.each([['on'], ['off']])(
907907
'should handle files with non-ascii characters when core.quotepath is %s',
908-
async quotePath => {
908+
async (quotePath) => {
909909
await execGit(['config', 'core.quotepath', quotePath])
910910

911911
// Stage multiple ugly files
@@ -1015,7 +1015,7 @@ describe('runAll', () => {
10151015
expect(await readFile('test.js')).toMatchInlineSnapshot(`
10161016
"<<<<<<< ours
10171017
module.exports = {
1018-
foo: \\"bar\\"
1018+
foo: \\"bar\\",
10191019
};
10201020
=======
10211021
const obj = {

‎test/validateConfig.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ describe('validateConfig', () => {
3939
it('should not throw and should print nothing for function task', () => {
4040
expect(() =>
4141
validateConfig({
42-
'*.js': filenames => {
42+
'*.js': (filenames) => {
4343
const files = filenames.join(' ')
4444
return `eslint --fix ${files} && git add ${files}`
4545
},
46-
'*.css': [filenames => filenames.map(filename => `eslint --fix ${filename}`)]
46+
'*.css': [(filenames) => filenames.map((filename) => `eslint --fix ${filename}`)]
4747
})
4848
).not.toThrow()
4949
expect(console.printHistory()).toMatchSnapshot()

‎wallaby.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
module.exports = wallaby => ({
3+
module.exports = (wallaby) => ({
44
files: [
55
{ pattern: 'test/__fixtures__/*', instrument: false },
66
'lib/*.js',

‎yarn.lock

+1,966-1,806
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.