mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat(pretty-quick): new type definition (#43867)
- definition file - tests https://www.npmjs.com/package/pretty-quick Thanks!
This commit is contained in:
parent
1b16fc8837
commit
8d4301f28e
48
types/pretty-quick/index.d.ts
vendored
Normal file
48
types/pretty-quick/index.d.ts
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
// Type definitions for pretty-quick 2.0
|
||||
// Project: https://github.com/azz/pretty-quick#readme
|
||||
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { ResolveConfigOptions } from 'prettier';
|
||||
|
||||
declare namespace prettyQuick {
|
||||
interface Options {
|
||||
config?: ResolveConfigOptions;
|
||||
since?: string;
|
||||
/** @default false */
|
||||
staged?: boolean;
|
||||
pattern?: string | string[];
|
||||
/** @default true */
|
||||
restage?: boolean;
|
||||
/**
|
||||
* @default 'master' | 'default'
|
||||
*/
|
||||
branch?: string;
|
||||
bail?: boolean;
|
||||
check?: boolean;
|
||||
verbose?: boolean;
|
||||
onFoundSinceRevision?: (name: string, revision: string) => void;
|
||||
onFoundChangedFiles?: (changedFiles: string[]) => void;
|
||||
onPartiallyStagedFile?: (file: string) => void;
|
||||
onExamineFile?: (file: string) => void;
|
||||
onCheckFile?: (file: string, isFormatted: boolean) => void;
|
||||
onWriteFile?: (file: string) => void;
|
||||
// ...args support
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface Results {
|
||||
readonly success: boolean;
|
||||
readonly errors: string[];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs Prettier on your changed files.
|
||||
* Supported source control managers:
|
||||
* * Git
|
||||
* * Mercurial
|
||||
*/
|
||||
declare function prettyQuick(currentDirectory: string, options?: prettyQuick.Options): prettyQuick.Results;
|
||||
|
||||
export = prettyQuick;
|
||||
44
types/pretty-quick/pretty-quick-tests.ts
Normal file
44
types/pretty-quick/pretty-quick-tests.ts
Normal file
@ -0,0 +1,44 @@
|
||||
/// <reference types="node" />
|
||||
import mri = require('mri');
|
||||
|
||||
import prettyQuick = require('pretty-quick');
|
||||
const args = mri(process.argv.slice(2));
|
||||
|
||||
const prettyQuickResult = prettyQuick(process.cwd(), {
|
||||
...args,
|
||||
onFoundSinceRevision: (scm, revision) => {
|
||||
scm; // $ExpectType string
|
||||
revision; // $ExpectType string
|
||||
},
|
||||
|
||||
onFoundChangedFiles: changedFiles => {
|
||||
changedFiles; // $ExpectType string[]
|
||||
},
|
||||
|
||||
onPartiallyStagedFile: file => {
|
||||
file; // $ExpectType string
|
||||
},
|
||||
|
||||
onWriteFile: file => {
|
||||
file; // $ExpectType string
|
||||
},
|
||||
|
||||
onCheckFile: (file, isFormatted) => {
|
||||
file; // $ExpectType string
|
||||
isFormatted; // $ExpectedType boolean
|
||||
},
|
||||
|
||||
onExamineFile: file => {
|
||||
file; // $ExpectType string
|
||||
},
|
||||
});
|
||||
|
||||
prettyQuickResult.success; // $ExpectType boolean
|
||||
prettyQuickResult.errors; // $ExpectType string[]
|
||||
|
||||
if (prettyQuickResult.success) {
|
||||
prettyQuickResult.success; // $ExpectType true
|
||||
} else {
|
||||
prettyQuickResult.success; // $ExpectType false
|
||||
process.exit(1);
|
||||
}
|
||||
23
types/pretty-quick/tsconfig.json
Normal file
23
types/pretty-quick/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"pretty-quick-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/pretty-quick/tslint.json
Normal file
1
types/pretty-quick/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user