Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier and deps update #710

Merged
merged 3 commits into from Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/run.js
Expand Up @@ -14,7 +14,7 @@ pleaseUpgradeNode(pkg, {
')' +
", can't run Git hook."
)
}
},
})

// Node version is supported, continue
Expand Down
5,269 changes: 2,324 additions & 2,945 deletions package-lock.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions package.json
Expand Up @@ -49,9 +49,9 @@
},
"homepage": "https://github.com/typicode/husky#readme",
"dependencies": {
"chalk": "^3.0.0",
"chalk": "^4.0.0",
"ci-info": "^2.0.0",
"compare-versions": "^3.5.1",
"compare-versions": "^3.6.0",
"cosmiconfig": "^6.0.0",
"find-versions": "^3.2.0",
"opencollective-postinstall": "^2.0.2",
Expand All @@ -63,29 +63,29 @@
"devDependencies": {
"@types/ci-info": "^2.0.0",
"@types/cosmiconfig": "^6.0.0",
"@types/jest": "^24.0.25",
"@types/mkdirp": "^0.5.2",
"@types/node": "^13.1.4",
"@typescript-eslint/eslint-plugin": "^2.15.0",
"@typescript-eslint/parser": "^2.15.0",
"cross-env": "^6.0.3",
"@types/jest": "^25.2.1",
"@types/mkdirp": "^1.0.0",
"@types/node": "^13.11.1",
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"cross-env": "^7.0.2",
"del": "^5.1.0",
"del-cli": "^3.0.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.9.0",
"eslint-config-xo-space": "^0.22.0",
"eslint-config-prettier": "^6.10.1",
"eslint-config-xo-space": "^0.24.0",
"eslint-plugin-prettier": "^3.1.2",
"formatree": "^1.0.2",
"jest": "^24.9.0",
"jest": "^25.3.0",
"markdown-toc": "^1.2.0",
"mkdirp": "^0.5.1",
"mkdirp": "^1.0.4",
"pinst": "^2.0.0",
"pkg-ok": "^2.3.1",
"prettier": "^1.19.1",
"tempy": "^0.3.0",
"ts-jest": "^24.2.0",
"type-fest": "^0.8.1",
"typescript": "^3.7.4"
"prettier": "^2.0.4",
"tempy": "^0.5.0",
"ts-jest": "^25.3.1",
"type-fest": "^0.13.1",
"typescript": "^3.8.3"
},
"jest": {
"transform": {
Expand Down
12 changes: 6 additions & 6 deletions scripts/docs-util.js
Expand Up @@ -10,9 +10,9 @@ console.log(
packages: {
A: { 'package.json': 0 },
B: { 'package.json': 0 },
C: { 'package.json': 0 }
}
}
C: { 'package.json': 0 },
},
},
})
)

Expand All @@ -22,8 +22,8 @@ console.log(
'.git': 0,
'package.json 🐶 # add husky here': 0,
'sub-directory': {
'package.json': 0
}
}
'package.json': 0,
},
},
})
)
2 changes: 1 addition & 1 deletion scripts/oc.js
Expand Up @@ -18,7 +18,7 @@ function render() {
return [
['Gold', 60],
['Silver', 45],
['Bronze', 30]
['Bronze', 30],
]
.map(([tier, height]) => renderTier(tier, height))
.join('\n\n')
Expand Down
2 changes: 1 addition & 1 deletion src/getConf.ts
Expand Up @@ -10,7 +10,7 @@ export function getConf(dir: string): Conf {
const { config = {} } = explorer.search(dir) || {}

const defaults: Conf = {
skipCI: true
skipCI: true,
}

return { ...defaults, ...config }
Expand Down
2 changes: 1 addition & 1 deletion src/installer/__tests__/__env__.ts
Expand Up @@ -10,7 +10,7 @@ process.env = {
// eslint-disable-next-line @typescript-eslint/camelcase
npm_package_homepage: 'https://github.com/foo/foo-package',
// eslint-disable-next-line @typescript-eslint/camelcase
npm_package_name: 'foo-package'
npm_package_name: 'foo-package',
}

// Mock Date.toLocaleString
Expand Down
4 changes: 2 additions & 2 deletions src/installer/__tests__/checkGitVersion.ts
Expand Up @@ -9,7 +9,7 @@ describe('checkGitVersion', (): void => {
// @ts-ignore
cp.spawnSync.mockReturnValue({
status: 0,
stdout: Buffer.from('git version 2.12.0')
stdout: Buffer.from('git version 2.12.0'),
})
expect(() => checkGitVersion()).toThrowError()
})
Expand All @@ -19,7 +19,7 @@ describe('checkGitVersion', (): void => {
// @ts-ignore
cp.spawnSync.mockReturnValue({
status: 0,
stdout: Buffer.from('git version 2.14.0')
stdout: Buffer.from('git version 2.14.0'),
})
expect(() => checkGitVersion()).not.toThrowError()
})
Expand Down
4 changes: 2 additions & 2 deletions src/installer/__tests__/gitRevParse.ts
Expand Up @@ -6,7 +6,7 @@ describe('gitRevParse', (): void => {
// Git rev-parse uses a different separator on Linux/MacOS and Windows
// slash is used to normalized the returned value for tests
gitCommonDir: '.git',
prefix: ''
prefix: '',
})
})

Expand All @@ -15,7 +15,7 @@ describe('gitRevParse', (): void => {
// Git rev-parse uses a different separator on Linux/MacOS and Windows
// slash is used to normalized the returned value for tests
gitCommonDir: '../../../.git',
prefix: `src/installer/__tests__/`
prefix: `src/installer/__tests__/`,
})
})
})
16 changes: 8 additions & 8 deletions src/installer/__tests__/index.ts
Expand Up @@ -20,7 +20,7 @@ function install({
gitCommonDir = '.git',
relativeUserPkgDir = '.',
userPkgDir = '.',
isCI = false
isCI = false,
}: {
gitCommonDir?: string
relativeUserPkgDir?: string
Expand All @@ -32,25 +32,25 @@ function install({
relativeUserPkgDir,
userPkgDir: path.join(tempDir, userPkgDir),
pmName: 'npm',
isCI
isCI,
})
}

function uninstall({
gitCommonDir = '.git',
userPkgDir = '.'
userPkgDir = '.',
}: {
gitCommonDir?: string
userPkgDir?: string
} = {}): void {
installer.uninstall({
absoluteGitCommonDir: path.join(tempDir, gitCommonDir),
userPkgDir
userPkgDir,
})
}

function mkdir(dirs: string[]): void {
dirs.forEach((dir): mkdirp.Made => mkdirp.sync(path.join(tempDir, dir)))
dirs.forEach((dir) => mkdirp.sync(path.join(tempDir, dir)))
}

function rmdir(dir: string): void {
Expand Down Expand Up @@ -82,9 +82,9 @@ type HookManager = {
const hooksManagers: HookManager[] = [
{
name: 'ghooks',
hookContent: '// Generated by ghooks. Do not edit this file.'
hookContent: '// Generated by ghooks. Do not edit this file.',
},
{ name: 'pre-commit', hookContent: './node_modules/pre-commit/hook' }
{ name: 'pre-commit', hookContent: './node_modules/pre-commit/hook' },
]

function testMigration({ name, hookContent }: HookManager): void {
Expand Down Expand Up @@ -189,7 +189,7 @@ describe('install', (): void => {

install({
gitCommonDir,
userPkgDir
userPkgDir,
})
const localScript = readFile('.git/modules/A/B/hooks/husky.local.sh')

Expand Down
4 changes: 2 additions & 2 deletions src/installer/bin.ts
Expand Up @@ -59,7 +59,7 @@ function getUserPkgDir(dir: string): string {
throw new Error(
[
`Can't find package.json in ${dir} directory or parents`,
'Please check that your project has a package.json or create one and reinstall husky.'
'Please check that your project has a package.json or create one and reinstall husky.',
].join('\n')
)
}
Expand Down Expand Up @@ -97,7 +97,7 @@ function run(): void {
relativeUserPkgDir,
userPkgDir,
pmName,
isCI
isCI,
})
} else {
uninstall({ absoluteGitCommonDir, userPkgDir })
Expand Down
2 changes: 1 addition & 1 deletion src/installer/gitRevParse.ts
Expand Up @@ -22,7 +22,7 @@ export function gitRevParse(cwd = process.cwd()): GitRevParseResult {
const [prefix, gitCommonDir] = stdout
.toString()
.split('\n')
.map(s => s.trim())
.map((s) => s.trim())
// Normalize for Windows
.map(slash)

Expand Down
6 changes: 2 additions & 4 deletions src/installer/hooks.ts
Expand Up @@ -32,7 +32,7 @@ const hookList = [
'push-to-checkout',
'pre-auto-gc',
'post-rewrite',
'sendemail-validate'
'sendemail-validate',
]

function getHooks(gitHooksDir: string): string[] {
Expand Down Expand Up @@ -98,7 +98,5 @@ function removeHook(filename: string): void {
}

export function removeHooks(gitHooksDir: string): void {
getHooks(gitHooksDir)
.filter(canRemove)
.forEach(removeHook)
getHooks(gitHooksDir).filter(canRemove).forEach(removeHook)
}
4 changes: 2 additions & 2 deletions src/installer/index.ts
Expand Up @@ -21,7 +21,7 @@ export function install({
relativeUserPkgDir,
userPkgDir,
pmName, // package manager name
isCI // running in CI or not
isCI, // running in CI or not
}: {
absoluteGitCommonDir: string
relativeUserPkgDir: string
Expand Down Expand Up @@ -59,7 +59,7 @@ export function install({

export function uninstall({
absoluteGitCommonDir,
userPkgDir
userPkgDir,
}: {
absoluteGitCommonDir: string
userPkgDir: string
Expand Down
32 changes: 16 additions & 16 deletions src/runner/__tests__/index.ts
Expand Up @@ -14,7 +14,7 @@ function expectSpawnSyncToHaveBeenCalledWith(
expect(cp.spawnSync).toHaveBeenCalledWith('sh', ['-c', cmd], {
cwd,
env: { ...process.env, ...env },
stdio: 'inherit'
stdio: 'inherit',
})
}

Expand All @@ -36,9 +36,9 @@ describe('run', (): void => {
JSON.stringify({
husky: {
hooks: {
'pre-commit': 'echo success'
}
}
'pre-commit': 'echo success',
},
},
})
)

Expand All @@ -55,7 +55,7 @@ describe('run', (): void => {
fs.writeFileSync(
path.join(dir, 'package.json'),
JSON.stringify({
husky: {}
husky: {},
})
)

Expand All @@ -74,9 +74,9 @@ describe('run', (): void => {
JSON.stringify({
husky: {
hooks: {
'pre-commit': 'echo fail && exit 2'
}
}
'pre-commit': 'echo fail && exit 2',
},
},
})
)

Expand All @@ -94,8 +94,8 @@ describe('run', (): void => {
path.join(dir, 'package.json'),
JSON.stringify({
scripts: {
precommit: 'echo success'
}
precommit: 'echo success',
},
})
)

Expand All @@ -112,26 +112,26 @@ describe('run', (): void => {
JSON.stringify({
husky: {
hooks: {
'commit-msg': 'echo success'
}
}
'commit-msg': 'echo success',
},
},
})
)

// 'commit-msg' takes one parameter from git
const status = await index(['', '', 'commit-msg', 'git fake param'], {
cwd: dir
cwd: dir,
})
expectSpawnSyncToHaveBeenCalledWith(dir, 'echo success', {
HUSKY_GIT_PARAMS: 'git fake param'
HUSKY_GIT_PARAMS: 'git fake param',
})
expect(status).toBe(0)
})

it("should not throw if there's no package.json", async (): Promise<void> => {
const dir = tempy.directory()
await index(['', '', 'pre-push'], {
cwd: dir
cwd: dir,
})
})
})
4 changes: 2 additions & 2 deletions src/runner/index.ts
Expand Up @@ -42,15 +42,15 @@ function runCommand(
const { status } = spawnSync('sh', ['-c', cmd], {
cwd,
env: { ...process.env, ...env },
stdio: 'inherit'
stdio: 'inherit',
})

if (status !== 0) {
const noVerifyMessage = [
'commit-msg',
'pre-commit',
'pre-rebase',
'pre-push'
'pre-push',
].includes(hookName)
? '(add --no-verify to bypass)'
: '(cannot be bypassed with --no-verify due to Git specs)'
Expand Down