-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
4,853 additions
and
5,197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"pretty-quick": major | ||
--- | ||
|
||
feat!: support prettier v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,6 @@ jobs: | |
strategy: | ||
matrix: | ||
node: | ||
- 10 | ||
- 12 | ||
- 14 | ||
- 16 | ||
- 18 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
dist | ||
lib | ||
node_modules | ||
*.log | ||
/.yarn/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
coverage | ||
dist | ||
lib | ||
/.yarn |
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
/* eslint-disable @typescript-eslint/require-await */ | ||
|
||
import path from 'path' | ||
|
||
export = { | ||
format: jest.fn((input: string) => 'formatted:' + input), | ||
resolveConfig: { | ||
sync: jest.fn((file: string) => ({ file })), | ||
}, | ||
getFileInfo: { | ||
sync: jest.fn((file: string) => { | ||
const ext = path.extname(file) | ||
if (ext === '.js' || ext === '.md') { | ||
return { ignored: false, inferredParser: 'babel' } | ||
} | ||
return { ignored: false, inferredParser: null } | ||
}), | ||
}, | ||
} | ||
export const format = jest.fn(async (input: string) => 'formatted:' + input) | ||
|
||
export const resolveConfig = jest.fn(async (file: string) => ({ file })) | ||
|
||
export const getFileInfo = jest.fn(async (file: string) => { | ||
const ext = path.extname(file) | ||
return { | ||
ignored: false, | ||
inferredParser: ext === '.js' || ext === '.md' ? 'babel' : null, | ||
} | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,18 +8,27 @@ | |
"JounQin (https://www.1stG.me) <[email protected]>" | ||
], | ||
"license": "MIT", | ||
"packageManager": "yarn@2.4.3", | ||
"packageManager": "yarn@3.6.4", | ||
"engines": { | ||
"node": ">=10.13" | ||
"node": ">=14" | ||
}, | ||
"bin": "dist/cli.js", | ||
"main": "dist/index.js", | ||
"module": "dist/index.esm.mjs", | ||
"types": "dist/index.d.ts", | ||
"bin": "lib/cli.mjs", | ||
"main": "lib/index.js", | ||
"module": "lib/index.esm.mjs", | ||
"exports": { | ||
".": { | ||
"types": "./lib/index.d.ts", | ||
"require": "./lib/index.js", | ||
"default": "./lib/index.esm.mjs" | ||
}, | ||
"./*": "./lib/*.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"types": "lib/index.d.ts", | ||
"files": [ | ||
"bin", | ||
"dist", | ||
"img", | ||
"lib", | ||
"!**/*.tsbuildinfo" | ||
], | ||
"keywords": [ | ||
|
@@ -35,7 +44,7 @@ | |
], | ||
"scripts": { | ||
"build": "run-p 'build:*'", | ||
"build:r": "r -f esm -o dist || exit 0", | ||
"build:r": "r -f esm", | ||
"build:tsc": "tsc -b", | ||
"lint": "run-p 'lint:*'", | ||
"lint:es": "eslint . --cache", | ||
|
@@ -45,49 +54,48 @@ | |
"test": "jest" | ||
}, | ||
"peerDependencies": { | ||
"prettier": "^2.0.0" | ||
"prettier": "^3.0.0" | ||
}, | ||
"dependencies": { | ||
"execa": "^4.1.0", | ||
"find-up": "^4.1.0", | ||
"execa": "^5.1.1", | ||
"find-up": "^5.0.0", | ||
"ignore": "^5.3.0", | ||
"mri": "^1.2.0", | ||
"picocolors": "^1.0.0", | ||
"picomatch": "^3.0.1", | ||
"tslib": "^2.6.2" | ||
}, | ||
"devDependencies": { | ||
"@1stg/lib-config": "^12.0.0", | ||
"@1stg/lib-config": "^12.0.1", | ||
"@changesets/changelog-github": "^0.5.0", | ||
"@changesets/cli": "^2.27.1", | ||
"@commitlint/cli": "^17.8.1", | ||
"@pkgr/rollup": "^4.1.1", | ||
"@pkgr/rollup": "^4.1.3", | ||
"@total-typescript/ts-reset": "^0.5.1", | ||
"@types/jest": "^29.5.11", | ||
"@types/mock-fs": "^4.13.4", | ||
"@types/picomatch": "^2.3.3", | ||
"@unts/patch-package": "^8.0.0", | ||
"clean-pkg-json": "^1.2.0", | ||
"eslint": "^8.56.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-jest": "^27.6.3", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^13.2.2", | ||
"jest": "^29.7.0", | ||
"lint-staged": "^13.3.0", | ||
"mock-fs": "^4.14.0", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.8.8", | ||
"prettier": "^3.2.3", | ||
"pretty-quick": "link:.", | ||
"simple-git-hooks": "^2.9.0", | ||
"size-limit": "^11.0.1", | ||
"size-limit": "^11.0.2", | ||
"size-limit-preset-node-lib": "^0.3.0", | ||
"ts-jest": "^26.5.6", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.9.2", | ||
"typescript": "~4.4.4" | ||
"typescript": "^5.3.3" | ||
}, | ||
"resolutions": { | ||
"typescript": "~4.4.4", | ||
"yaml": "^1.10.2" | ||
"@1stg/prettier-config": "^4.0.1", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"prettier": "^3.2.3" | ||
}, | ||
"commitlint": { | ||
"extends": "@1stg" | ||
|
@@ -108,7 +116,7 @@ | |
}, | ||
"eslintIgnore": [ | ||
"coverage", | ||
"dist", | ||
"lib", | ||
"!/.*.js" | ||
], | ||
"jest": { | ||
|
@@ -118,6 +126,7 @@ | |
], | ||
"collectCoverage": true, | ||
"moduleNameMapper": { | ||
"^(\\.{1,2}/.*)\\.js$": "$1", | ||
"^pretty-quick$": "<rootDir>/src", | ||
"^pretty-quick/(.+)$": "<rootDir>/src/$1" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env node | ||
|
||
import mri from 'mri' | ||
import picocolors from 'picocolors' | ||
|
||
import prettyQuick from './index.js' | ||
|
||
const args = mri(process.argv.slice(2), { | ||
alias: { | ||
'resolve-config': 'resolveConfig', | ||
'ignore-path': 'ignorePath', | ||
}, | ||
}) | ||
|
||
const main = async () => { | ||
const prettyQuickResult = await prettyQuick(process.cwd(), { | ||
...args, | ||
onFoundSinceRevision: (scm, revision) => { | ||
console.log( | ||
`🔍 Finding changed files since ${picocolors.bold( | ||
scm, | ||
)} revision ${picocolors.bold(revision)}.`, | ||
) | ||
}, | ||
|
||
onFoundChangedFiles: changedFiles => { | ||
console.log( | ||
`🎯 Found ${picocolors.bold(changedFiles.length)} changed ${ | ||
changedFiles.length === 1 ? 'file' : 'files' | ||
}.`, | ||
) | ||
}, | ||
|
||
onPartiallyStagedFile: file => { | ||
console.log( | ||
`✗ Found ${picocolors.bold('partially')} staged file ${file}.`, | ||
) | ||
}, | ||
|
||
onWriteFile: file => { | ||
console.log(`✍️ Fixing up ${picocolors.bold(file)}.`) | ||
}, | ||
|
||
onCheckFile: (file, isFormatted) => { | ||
if (!isFormatted) { | ||
console.log(`⛔️ Check failed: ${picocolors.bold(file)}`) | ||
} | ||
}, | ||
|
||
onExamineFile: file => { | ||
console.log(`🔍 Examining ${picocolors.bold(file)}.`) | ||
}, | ||
}) | ||
|
||
if (prettyQuickResult.success) { | ||
console.log('✅ Everything is awesome!') | ||
} else { | ||
if (prettyQuickResult.errors.includes('PARTIALLY_STAGED_FILE')) { | ||
console.log( | ||
'✗ Partially staged files were fixed up.' + | ||
` ${picocolors.bold('Please update stage before committing')}.`, | ||
) | ||
} | ||
if (prettyQuickResult.errors.includes('BAIL_ON_WRITE')) { | ||
console.log( | ||
'✗ File had to be prettified and prettyQuick was set to bail mode.', | ||
) | ||
} | ||
if (prettyQuickResult.errors.includes('CHECK_FAILED')) { | ||
console.log( | ||
'✗ Code style issues found in the above file(s). Forgot to run Prettier?', | ||
) | ||
} | ||
// eslint-disable-next-line n/no-process-exit | ||
process.exit(1) // ensure git hooks abort | ||
} | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
main() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.