Skip to content

Commit

Permalink
fix(deps): update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Apr 19, 2020
1 parent 6066b07 commit e093b1d
Show file tree
Hide file tree
Showing 22 changed files with 2,076 additions and 1,916 deletions.
2 changes: 1 addition & 1 deletion bin/lint-staged.js
Expand Up @@ -81,7 +81,7 @@ const options = {
debug('Options parsed from command-line:', options)

lintStaged(options)
.then(passed => {
.then((passed) => {
process.exitCode = passed ? 0 : 1
})
.catch(() => {
Expand Down
2 changes: 1 addition & 1 deletion lib/chunkFiles.js
Expand Up @@ -38,7 +38,7 @@ module.exports = function chunkFiles({ files, baseDir, maxArgLength = null, rela
return [files]
}

const normalizedFiles = files.map(file =>
const normalizedFiles = files.map((file) =>
normalize(relative || !baseDir ? file : path.resolve(baseDir, file))
)
const fileListLength = normalizedFiles.join(' ').length
Expand Down
8 changes: 4 additions & 4 deletions lib/generateTasks.js
Expand Up @@ -25,8 +25,8 @@ module.exports = function generateTasks({
}) {
debug('Generating linter tasks')

const absoluteFiles = files.map(file => normalize(path.resolve(gitDir, file)))
const relativeFiles = absoluteFiles.map(file => normalize(path.relative(cwd, file)))
const absoluteFiles = files.map((file) => normalize(path.resolve(gitDir, file)))
const relativeFiles = absoluteFiles.map((file) => normalize(path.relative(cwd, file)))

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

const task = { pattern, commands, fileList }
debug('Generated task: \n%O', task)
Expand Down
18 changes: 9 additions & 9 deletions lib/gitWorkflow.js
Expand Up @@ -85,7 +85,7 @@ class GitWorkflow {
*/
async getBackupStash(ctx) {
const stashes = await this.execGit(['stash', 'list'])
const index = stashes.split('\n').findIndex(line => line.includes(STASH))
const index = stashes.split('\n').findIndex((line) => line.includes(STASH))
if (index === -1) {
ctx.gitGetBackupStashError = true
throw new Error('lint-staged automatic backup is missing!')
Expand All @@ -102,7 +102,7 @@ class GitWorkflow {
const deletedFiles = lsFiles
.split('\n')
.filter(Boolean)
.map(file => path.resolve(this.gitDir, file))
.map((file) => path.resolve(this.gitDir, file))
debug('Found deleted files:', deletedFiles)
return deletedFiles
}
Expand All @@ -113,9 +113,9 @@ class GitWorkflow {
async backupMergeStatus() {
debug('Backing up merge state...')
await Promise.all([
readFile(this.mergeHeadFilename).then(buffer => (this.mergeHeadBuffer = buffer)),
readFile(this.mergeModeFilename).then(buffer => (this.mergeModeBuffer = buffer)),
readFile(this.mergeMsgFilename).then(buffer => (this.mergeMsgBuffer = buffer))
readFile(this.mergeHeadFilename).then((buffer) => (this.mergeHeadBuffer = buffer)),
readFile(this.mergeModeFilename).then((buffer) => (this.mergeModeBuffer = buffer)),
readFile(this.mergeMsgFilename).then((buffer) => (this.mergeMsgBuffer = buffer))
])
debug('Done backing up merge state!')
}
Expand Down Expand Up @@ -149,7 +149,7 @@ class GitWorkflow {
const status = await this.execGit(['status', '--porcelain'])
const partiallyStaged = status
.split('\n')
.filter(line => {
.filter((line) => {
/**
* See https://git-scm.com/docs/git-status#_short_format
* The first letter of the line represents current index status,
Expand All @@ -158,7 +158,7 @@ class GitWorkflow {
const [index, workingTree] = line
return index !== ' ' && workingTree !== ' ' && index !== '?' && workingTree !== '?'
})
.map(line => line.substr(3)) // Remove first three letters (index, workingTree, and a whitespace)
.map((line) => line.substr(3)) // Remove first three letters (index, workingTree, and a whitespace)
debug('Found partially staged files:', partiallyStaged)
return partiallyStaged.length ? partiallyStaged : null
}
Expand Down Expand Up @@ -203,7 +203,7 @@ class GitWorkflow {
await this.restoreMergeStatus()

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

debug('Done backing up original state!')
} catch (error) {
Expand Down Expand Up @@ -303,7 +303,7 @@ class GitWorkflow {
await this.restoreMergeStatus()

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

// Clean out patch
await unlink(this.getHiddenFilepath(PATCH_UNSTAGED))
Expand Down
4 changes: 2 additions & 2 deletions lib/printErrors.js
Expand Up @@ -2,11 +2,11 @@

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

module.exports = function printErrors(errorInstance, logger) {
if (Array.isArray(errorInstance.errors)) {
errorInstance.errors.forEach(lintError => {
errorInstance.errors.forEach((lintError) => {
logger.error(errMsg(lintError))
})
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/resolveGitRepo.js
Expand Up @@ -15,7 +15,7 @@ const fsLstat = promisify(fs.lstat)
* Resolve path to the .git directory, with special handling for
* submodules and worktrees
*/
const resolveGitConfigDir = async gitDir => {
const resolveGitConfigDir = async (gitDir) => {
const defaultDir = normalize(path.join(gitDir, '.git'))
const stats = await fsLstat(defaultDir)
// If .git is a directory, use it
Expand All @@ -28,7 +28,7 @@ const resolveGitConfigDir = async gitDir => {
/**
* Resolve git directory and possible submodule paths
*/
const resolveGitRepo = async cwd => {
const resolveGitRepo = async (cwd) => {
try {
debugLog('Resolving git repo from `%s`', cwd)

Expand Down
4 changes: 2 additions & 2 deletions lib/resolveTaskFn.js
Expand Up @@ -8,7 +8,7 @@ const symbols = require('log-symbols')

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

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

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

return async ctx => {
return async (ctx) => {
const promise = shell
? execa.command(isFn ? command : `${command} ${files.join(' ')}`, execaOptions)
: execa(cmd, isFn ? args : args.concat(files), execaOptions)
Expand Down
34 changes: 17 additions & 17 deletions lib/runAll.js
Expand Up @@ -29,7 +29,7 @@ const MESSAGES = {
GIT_ERROR: 'Skipped because of previous git error.'
}

const shouldSkipApplyModifications = ctx => {
const shouldSkipApplyModifications = (ctx) => {
// Should be skipped in case of git errors
if (ctx.gitError) {
return MESSAGES.GIT_ERROR
Expand All @@ -40,14 +40,14 @@ const shouldSkipApplyModifications = ctx => {
}
}

const shouldSkipRevert = ctx => {
const shouldSkipRevert = (ctx) => {
// Should be skipped in case of unknown git errors
if (ctx.gitError && !ctx.gitApplyEmptyCommitError && !ctx.gitRestoreUnstagedChangesError) {
return MESSAGES.GIT_ERROR
}
}

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

// Add files from task to match set
task.fileList.forEach(file => {
task.fileList.forEach((file) => {
matchedFiles.add(file)
})

hasDeprecatedGitAdd = subTasks.some(subTask => subTask.command === 'git add')
hasDeprecatedGitAdd = subTasks.some((subTask) => subTask.command === 'git add')

chunkListrTasks.push({
title: `Running tasks for ${task.pattern}`,
Expand Down Expand Up @@ -184,7 +184,7 @@ const runAll = async (
// Skip if the first step (backup) failed
if (ctx.gitError) return MESSAGES.GIT_ERROR
// Skip chunk when no every task is skipped (due to no matches)
if (chunkListrTasks.every(task => task.skip())) return 'No tasks to run.'
if (chunkListrTasks.every((task) => task.skip())) return 'No tasks to run.'
return false
}
})
Expand All @@ -199,7 +199,7 @@ const runAll = async (

// If all of the configured tasks should be skipped
// avoid executing any lint-staged logic
if (listrTasks.every(task => task.skip())) {
if (listrTasks.every((task) => task.skip())) {
logger.log('No staged files match any of provided globs.')
return 'No tasks to run.'
}
Expand All @@ -210,37 +210,37 @@ const runAll = async (
[
{
title: 'Preparing...',
task: ctx => git.prepare(ctx, shouldBackup)
task: (ctx) => git.prepare(ctx, shouldBackup)
},
{
title: 'Hiding unstaged changes to partially staged files...',
task: ctx => git.hideUnstagedChanges(ctx),
enabled: ctx => ctx.hasPartiallyStagedFiles
task: (ctx) => git.hideUnstagedChanges(ctx),
enabled: (ctx) => ctx.hasPartiallyStagedFiles
},
...listrTasks,
{
title: 'Applying modifications...',
task: ctx => git.applyModifications(ctx),
task: (ctx) => git.applyModifications(ctx),
// Always apply back unstaged modifications when skipping backup
skip: ctx => shouldBackup && shouldSkipApplyModifications(ctx)
skip: (ctx) => shouldBackup && shouldSkipApplyModifications(ctx)
},
{
title: 'Restoring unstaged changes to partially staged files...',
task: ctx => git.restoreUnstagedChanges(ctx),
enabled: ctx => ctx.hasPartiallyStagedFiles,
task: (ctx) => git.restoreUnstagedChanges(ctx),
enabled: (ctx) => ctx.hasPartiallyStagedFiles,
skip: shouldSkipApplyModifications
},
{
title: 'Reverting to original state because of errors...',
task: ctx => git.restoreOriginalState(ctx),
enabled: ctx =>
task: (ctx) => git.restoreOriginalState(ctx),
enabled: (ctx) =>
shouldBackup &&
(ctx.taskError || ctx.gitApplyEmptyCommitError || ctx.gitRestoreUnstagedChangesError),
skip: shouldSkipRevert
},
{
title: 'Cleaning up...',
task: ctx => git.cleanup(ctx),
task: (ctx) => git.cleanup(ctx),
enabled: () => shouldBackup,
skip: shouldSkipCleanup
}
Expand Down
20 changes: 10 additions & 10 deletions lib/validateConfig.js
Expand Up @@ -8,17 +8,17 @@ const format = require('stringify-object')
const debug = require('debug')('lint-staged:cfg')

const TEST_DEPRECATED_KEYS = new Map([
['concurrent', key => typeof key === 'boolean'],
['chunkSize', key => typeof key === 'number'],
['globOptions', key => typeof key === 'object'],
['linters', key => typeof key === 'object'],
['ignore', key => Array.isArray(key)],
['subTaskConcurrency', key => typeof key === 'number'],
['renderer', key => typeof key === 'string'],
['relative', key => typeof key === 'boolean']
['concurrent', (key) => typeof key === 'boolean'],
['chunkSize', (key) => typeof key === 'number'],
['globOptions', (key) => typeof key === 'object'],
['linters', (key) => typeof key === 'object'],
['ignore', (key) => Array.isArray(key)],
['subTaskConcurrency', (key) => typeof key === 'number'],
['renderer', (key) => typeof key === 'string'],
['relative', (key) => typeof key === 'boolean']
])

const formatError = helpMsg => `● Validation Error:
const formatError = (helpMsg) => `● Validation Error:
${helpMsg}
Expand Down Expand Up @@ -68,7 +68,7 @@ module.exports = function validateConfig(config) {

if (
(!Array.isArray(task) ||
task.some(item => typeof item !== 'string' && typeof item !== 'function')) &&
task.some((item) => typeof item !== 'string' && typeof item !== 'function')) &&
typeof task !== 'string' &&
typeof task !== 'function'
) {
Expand Down
40 changes: 20 additions & 20 deletions package.json
Expand Up @@ -34,12 +34,12 @@
}
},
"dependencies": {
"chalk": "^3.0.0",
"commander": "^4.0.1",
"chalk": "^4.0.0",
"commander": "^5.0.0",
"cosmiconfig": "^6.0.0",
"debug": "^4.1.1",
"dedent": "^0.7.0",
"execa": "^3.4.0",
"execa": "^4.0.0",
"listr": "^0.14.3",
"log-symbols": "^3.0.0",
"micromatch": "^4.0.2",
Expand All @@ -49,27 +49,27 @@
"stringify-object": "^3.3.0"
},
"devDependencies": {
"@babel/core": "^7.7.4",
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-object-rest-spread": "^7.9.5",
"@babel/preset-env": "^7.9.5",
"babel-eslint": "^10.1.0",
"babel-jest": "^25.3.0",
"consolemock": "^1.1.0",
"eslint": "^6.7.2",
"eslint": "^6.8.0",
"eslint-config-okonet": "^7.0.2",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-flowtype": "^4.5.2",
"eslint-plugin-import": "^2.18.2",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-flowtype": "^4.7.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.17.0",
"fs-extra": "^8.1.0",
"husky": "^3.1.0",
"jest": "^24.9.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.19.0",
"fs-extra": "^9.0.0",
"husky": "^4.2.5",
"jest": "^25.3.0",
"jest-snapshot-serializer-ansi": "^1.0.0",
"nanoid": "^2.1.7",
"prettier": "^1.19.1"
"nanoid": "^3.1.3",
"prettier": "^2.0.4"
},
"config": {
"commitizen": {
Expand Down
4 changes: 2 additions & 2 deletions test/__mocks__/advanced-config.js
@@ -1,4 +1,4 @@
module.exports = {
'*.css': filenames => `echo ${filenames.join(' ')}`,
'*.js': filenames => filenames.map(filename => `echo ${filename}`)
'*.css': (filenames) => `echo ${filenames.join(' ')}`,
'*.js': (filenames) => filenames.map((filename) => `echo ${filename}`)
}
2 changes: 1 addition & 1 deletion test/__mocks__/npm-which.js
@@ -1,4 +1,4 @@
const mockFn = jest.fn(path => {
const mockFn = jest.fn((path) => {
if (path.includes('missing')) {
throw new Error(`not found: ${path}`)
}
Expand Down
2 changes: 1 addition & 1 deletion test/chunkFiles.spec.js
Expand Up @@ -16,7 +16,7 @@ describe('chunkFiles', () => {

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

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

0 comments on commit e093b1d

Please sign in to comment.