@types/vfile
Advanced tools
Comparing version 2.2.0 to 2.2.1
// Type definitions for VFile 2.2 | ||
// Project: https://github.com/vfile/vfile | ||
// Definitions by: bizen241 <https://github.com/bizen241> | ||
// Junyoung Choi <https://github.com/rokt33r> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
@@ -11,143 +12,165 @@ // TypeScript Version: 2.2 | ||
export = VFile; | ||
declare namespace vfile { | ||
type Contents = string | Buffer; | ||
/** | ||
* Create a new virtual file. | ||
* Path related properties are set in the following order (least specific to most specific): `history`, `path`, `basename`, `stem`, `extname`, `dirname`. | ||
* It’s not possible to set either `dirname` or `extname` without setting either `history`, `path`, `basename`, or `stem` as well. | ||
* @param options If `options` is `string` or `Buffer`, treats it as `{contents: options}`. If `options` is a `VFile`, returns it. All other options are set on the newly created `vfile`. | ||
*/ | ||
declare function VFile(options?: string | Buffer | Partial<VFile.VFile>): VFile.VFile; | ||
interface NodeWithPosition extends Unist.Node { | ||
position: Unist.Position; | ||
[key: string]: any; | ||
} | ||
declare namespace VFile { | ||
interface VFile { | ||
[key: string]: any; | ||
/** | ||
* Raw value. | ||
*/ | ||
contents: string | Buffer | null; | ||
/** | ||
* Base of `path`. | ||
* Defaults to `process.cwd()`. | ||
*/ | ||
cwd: string; | ||
/** | ||
* Path of `vfile`. | ||
* Cannot be nullified. | ||
*/ | ||
interface VFileParamsBase<D> { | ||
data?: D; | ||
contents?: Contents; | ||
path?: string; | ||
/** | ||
* Current name (including extension) of `vfile`. | ||
* Cannot contain path separators. | ||
* Cannot be nullified either (use `file.path = file.dirname` instead). | ||
*/ | ||
basename?: string; | ||
/** | ||
* Name (without extension) of `vfile`. | ||
* Cannot be nullified, and cannot contain path separators. | ||
*/ | ||
stem?: string; | ||
/** | ||
* Extension (with dot) of `vfile`. | ||
* Cannot be set if there's no `path` yet and cannot contain path separators. | ||
*/ | ||
extname?: string; | ||
dirname?: string; | ||
cwd?: string; | ||
} | ||
type VFileParams<C extends {data?: {}}> = VFileParamsBase<C['data']> & C; | ||
/** | ||
* File-related message describing something at certain position. | ||
*/ | ||
interface VFileMessage { | ||
/** | ||
* Path to parent directory of `vfile`. | ||
* Cannot be set if there's no `path` yet. | ||
* File-path, when the message was triggered. | ||
*/ | ||
dirname?: string; | ||
file: string; | ||
/** | ||
* List of file-paths the file moved between. | ||
* Category of message. | ||
*/ | ||
history: string[]; | ||
ruleId: string | null; | ||
/** | ||
* List of messages associated with the file. | ||
* Reason for message. | ||
*/ | ||
messages: VFileMessage[]; | ||
reason: string; | ||
/** | ||
* Place to store custom information. | ||
* It's OK to store custom data directly on the `vfile`, moving it to `data` gives a little more privacy. | ||
* Starting line of error. | ||
*/ | ||
data: object; | ||
line: number | null; | ||
/** | ||
* Convert contents of `vfile` to string. | ||
* @param encoding If `contents` is a buffer, `encoding` is used to stringify buffers (default: `'utf8'`). | ||
* Starting column of error. | ||
*/ | ||
toString(encoding?: string): string; | ||
column: number | null; | ||
/** | ||
* Associates a message with the file for `reason` at `position`. | ||
* When an error is passed in as `reason`, copies the stack. | ||
* Each message has a `fatal` property which by default is set to `false` (ie. `warning`). | ||
* @param reason Reason for message. Uses the stack and message of the error if given. | ||
* @param position Place at which the message occurred in `vfile`. | ||
* @param ruleId Category of message. | ||
* Full range information, when available. | ||
* Has start and end properties, both set to an object with line and column, set to number?. | ||
*/ | ||
message(reason: string | Error, position?: Unist.Node | Unist.Point | Unist.Position, ruleId?: string): VFileMessage; | ||
location: Unist.Position; | ||
/** | ||
* Associates an informational message with the file, where `fatal` is set to `null`. | ||
* Calls `message()` internally. | ||
* @param reason Reason for message. Uses the stack and message of the error if given. | ||
* @param position Place at which the message occurred in `vfile`. | ||
* @param ruleId Category of message. | ||
* Namespace of warning. | ||
*/ | ||
info(reason: string | Error, position?: Unist.Node | Unist.Point | Unist.Position, ruleId?: string): VFileMessage; | ||
source: string | null; | ||
/** | ||
* Associates a fatal message with the file, then immediately throws it. | ||
* Note: fatal errors mean a file is no longer processable. | ||
* Calls `message()` internally. | ||
* @param reason Reason for message. Uses the stack and message of the error if given. | ||
* @param position Place at which the message occurred in `vfile`. | ||
* @param ruleId Category of message. | ||
* If true, marks associated file as no longer processable. | ||
*/ | ||
fail(reason: string | Error, position?: Unist.Node | Unist.Point | Unist.Position, ruleId?: string): VFileMessage; | ||
fatal?: boolean | null; | ||
} | ||
/** | ||
* File-related message describing something at certain position. | ||
* Associates a message with the file for `reason` at `position`. | ||
* When an error is passed in as `reason`, copies the stack. | ||
* Each message has a `fatal` property which by default is set to `false` (ie. `warning`). | ||
* @param reason Reason for message. Uses the stack and message of the error if given. | ||
* @param position Place at which the message occurred in `vfile`. | ||
* @param ruleId Category of message. | ||
*/ | ||
interface VFileMessage extends Error { | ||
type Message = (reason: string, position?: Unist.Point | Unist.Position | NodeWithPosition, ruleId?: string) => VFileMessage; | ||
/** | ||
* Associates a fatal message with the file, then immediately throws it. | ||
* Note: fatal errors mean a file is no longer processable. | ||
* Calls `message()` internally. | ||
* @param reason Reason for message. Uses the stack and message of the error if given. | ||
* @param position Place at which the message occurred in `vfile`. | ||
* @param ruleId Category of message. | ||
*/ | ||
type Fail = (reason: string, position?: Unist.Point | Unist.Position | NodeWithPosition, ruleId?: string) => never; | ||
/** | ||
* Associates an informational message with the file, where `fatal` is set to `null`. | ||
* Calls `message()` internally. | ||
* @param reason Reason for message. Uses the stack and message of the error if given. | ||
* @param position Place at which the message occurred in `vfile`. | ||
* @param ruleId Category of message. | ||
*/ | ||
type Info = (reason: string, position?: Unist.Point | Unist.Position | NodeWithPosition, ruleId?: string) => void; | ||
/** | ||
* Convert contents of `vfile` to string. | ||
* @param encoding If `contents` is a buffer, `encoding` is used to stringify buffers (default: `'utf8'`). | ||
*/ | ||
type ToString = (encoding?: BufferEncoding) => string; | ||
interface VFileBase<C extends {data?: {}}> { | ||
/** | ||
* File-path, when the message was triggered. | ||
* @param options If `options` is `string` or `Buffer`, treats it as `{contents: options}`. If `options` is a `VFile`, returns it. All other options are set on the newly created `vfile`. | ||
*/ | ||
file: string; | ||
(input?: Contents): VFile<C>; | ||
<C>(input?: VFile<C> | VFileParams<C>): VFile<C>; | ||
message: Message; | ||
fail: Fail; | ||
info: Info; | ||
/** | ||
* Reason for message. | ||
* List of file-paths the file moved between. | ||
*/ | ||
reason: string; | ||
history: string[]; | ||
/** | ||
* Category of message. | ||
* Place to store custom information. | ||
* It's OK to store custom data directly on the `vfile`, moving it to `data` gives a little more privacy. | ||
*/ | ||
ruleId: string | null; | ||
data: C['data']; | ||
/** | ||
* Namespace of warning. | ||
* List of messages associated with the file. | ||
*/ | ||
source: string | null; | ||
messages: VFileMessage[]; | ||
/** | ||
* If true, marks associated file as no longer processable. | ||
* Raw value. | ||
*/ | ||
fatal: boolean | null; | ||
contents: Contents; | ||
/** | ||
* Starting line of error. | ||
* Path of `vfile`. | ||
* Cannot be nullified. | ||
*/ | ||
line: number | null; | ||
path?: string; | ||
/** | ||
* Starting column of error. | ||
* Path to parent directory of `vfile`. | ||
* Cannot be set if there's no `path` yet. | ||
*/ | ||
column: number | null; | ||
dirname?: string; | ||
/** | ||
* Full range information, when available. | ||
* Has start and end properties, both set to an object with line and column, set to number?. | ||
* Current name (including extension) of `vfile`. | ||
* Cannot contain path separators. | ||
* Cannot be nullified either (use `file.path = file.dirname` instead). | ||
*/ | ||
location: { | ||
start: { | ||
line: number | null; | ||
column: number | null; | ||
}; | ||
end: { | ||
line: number | null; | ||
column: number | null; | ||
}; | ||
}; | ||
basename?: string; | ||
/** | ||
* Name (without extension) of `vfile`. | ||
* Cannot be nullified, and cannot contain path separators. | ||
*/ | ||
stem?: string; | ||
/** | ||
* Extension (with dot) of `vfile`. | ||
* Cannot be set if there's no `path` yet and cannot contain path separators. | ||
*/ | ||
extname?: string; | ||
/** | ||
* Base of `path`. | ||
* Defaults to `process.cwd()`. | ||
*/ | ||
cwd: string; | ||
toString: ToString; | ||
} | ||
type VFile<C> = VFileBase<C> & C; | ||
} | ||
/** | ||
* Create a new virtual file. | ||
* Path related properties are set in the following order (least specific to most specific): `history`, `path`, `basename`, `stem`, `extname`, `dirname`. | ||
* It’s not possible to set either `dirname` or `extname` without setting either `history`, `path`, `basename`, or `stem` as well. | ||
*/ | ||
declare const vfile: vfile.VFile<{}>; | ||
export = vfile; |
{ | ||
"name": "@types/vfile", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "TypeScript definitions for VFile", | ||
@@ -11,2 +11,7 @@ "license": "MIT", | ||
"githubUsername": "bizen241" | ||
}, | ||
{ | ||
"name": "Junyoung Choi", | ||
"url": "https://github.com/rokt33r", | ||
"githubUsername": "rokt33r" | ||
} | ||
@@ -24,4 +29,4 @@ ], | ||
}, | ||
"typesPublisherContentHash": "1287ef584fb54df64afb9831ce314153f062daf79efcf1ac3b112cba315356cc", | ||
"typesPublisherContentHash": "6a607885636596958286efa3634e2e4e20e986ef0fada22d877972c2fe747f3e", | ||
"typeScriptVersion": "2.2" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
Additional Details | ||
* Last updated: Wed, 06 Sep 2017 21:47:41 GMT | ||
* Last updated: Thu, 07 Sep 2017 22:03:13 GMT | ||
* Dependencies: unist, node | ||
@@ -17,2 +17,2 @@ * Global values: none | ||
# Credits | ||
These definitions were written by bizen241 <https://github.com/bizen241>. | ||
These definitions were written by bizen241 <https://github.com/bizen241>, Junyoung Choi <https://github.com/rokt33r>. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8489
162