planning
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions

5
node_modules/vfile/changelog.md generated vendored Normal file
View File

@@ -0,0 +1,5 @@
# Changelog
See [GitHub Releases][releases] for the changelog.
[releases]: https://github.com/vfile/vfile/releases

3
node_modules/vfile/core.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict'
module.exports = require('./lib/core')

3
node_modules/vfile/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict'
module.exports = require('./lib')

173
node_modules/vfile/lib/core.js generated vendored Normal file
View File

@@ -0,0 +1,173 @@
'use strict'
var p = require('./minpath')
var proc = require('./minproc')
var buffer = require('is-buffer')
module.exports = VFile
var own = {}.hasOwnProperty
// Order of setting (least specific to most), we need this because otherwise
// `{stem: 'a', path: '~/b.js'}` would throw, as a path is needed before a
// stem can be set.
var order = ['history', 'path', 'basename', 'stem', 'extname', 'dirname']
VFile.prototype.toString = toString
// Access full path (`~/index.min.js`).
Object.defineProperty(VFile.prototype, 'path', {get: getPath, set: setPath})
// Access parent path (`~`).
Object.defineProperty(VFile.prototype, 'dirname', {
get: getDirname,
set: setDirname
})
// Access basename (`index.min.js`).
Object.defineProperty(VFile.prototype, 'basename', {
get: getBasename,
set: setBasename
})
// Access extname (`.js`).
Object.defineProperty(VFile.prototype, 'extname', {
get: getExtname,
set: setExtname
})
// Access stem (`index.min`).
Object.defineProperty(VFile.prototype, 'stem', {get: getStem, set: setStem})
// Construct a new file.
function VFile(options) {
var prop
var index
if (!options) {
options = {}
} else if (typeof options === 'string' || buffer(options)) {
options = {contents: options}
} else if ('message' in options && 'messages' in options) {
return options
}
if (!(this instanceof VFile)) {
return new VFile(options)
}
this.data = {}
this.messages = []
this.history = []
this.cwd = proc.cwd()
// Set path related properties in the correct order.
index = -1
while (++index < order.length) {
prop = order[index]
if (own.call(options, prop)) {
this[prop] = options[prop]
}
}
// Set non-path related properties.
for (prop in options) {
if (order.indexOf(prop) < 0) {
this[prop] = options[prop]
}
}
}
function getPath() {
return this.history[this.history.length - 1]
}
function setPath(path) {
assertNonEmpty(path, 'path')
if (this.path !== path) {
this.history.push(path)
}
}
function getDirname() {
return typeof this.path === 'string' ? p.dirname(this.path) : undefined
}
function setDirname(dirname) {
assertPath(this.path, 'dirname')
this.path = p.join(dirname || '', this.basename)
}
function getBasename() {
return typeof this.path === 'string' ? p.basename(this.path) : undefined
}
function setBasename(basename) {
assertNonEmpty(basename, 'basename')
assertPart(basename, 'basename')
this.path = p.join(this.dirname || '', basename)
}
function getExtname() {
return typeof this.path === 'string' ? p.extname(this.path) : undefined
}
function setExtname(extname) {
assertPart(extname, 'extname')
assertPath(this.path, 'extname')
if (extname) {
if (extname.charCodeAt(0) !== 46 /* `.` */) {
throw new Error('`extname` must start with `.`')
}
if (extname.indexOf('.', 1) > -1) {
throw new Error('`extname` cannot contain multiple dots')
}
}
this.path = p.join(this.dirname, this.stem + (extname || ''))
}
function getStem() {
return typeof this.path === 'string'
? p.basename(this.path, this.extname)
: undefined
}
function setStem(stem) {
assertNonEmpty(stem, 'stem')
assertPart(stem, 'stem')
this.path = p.join(this.dirname || '', stem + (this.extname || ''))
}
// Get the value of the file.
function toString(encoding) {
return (this.contents || '').toString(encoding)
}
// Assert that `part` is not a path (i.e., does not contain `p.sep`).
function assertPart(part, name) {
if (part && part.indexOf(p.sep) > -1) {
throw new Error(
'`' + name + '` cannot be a path: did not expect `' + p.sep + '`'
)
}
}
// Assert that `part` is not empty.
function assertNonEmpty(part, name) {
if (!part) {
throw new Error('`' + name + '` cannot be empty')
}
}
// Assert `path` exists.
function assertPath(path, name) {
if (!path) {
throw new Error('Setting `' + name + '` requires `path` to be set too')
}
}

46
node_modules/vfile/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
'use strict'
var VMessage = require('vfile-message')
var VFile = require('./core.js')
module.exports = VFile
VFile.prototype.message = message
VFile.prototype.info = info
VFile.prototype.fail = fail
// Create a message with `reason` at `position`.
// When an error is passed in as `reason`, copies the stack.
function message(reason, position, origin) {
var message = new VMessage(reason, position, origin)
if (this.path) {
message.name = this.path + ':' + message.name
message.file = this.path
}
message.fatal = false
this.messages.push(message)
return message
}
// Fail: creates a vmessage, associates it with the file, and throws it.
function fail() {
var message = this.message.apply(this, arguments)
message.fatal = true
throw message
}
// Info: creates a vmessage, associates it with the file, and marks the fatality
// as null.
function info() {
var message = this.message.apply(this, arguments)
message.fatal = null
return message
}

374
node_modules/vfile/lib/minpath.browser.js generated vendored Normal file
View File

@@ -0,0 +1,374 @@
'use strict'
// A derivative work based on:
// <https://github.com/browserify/path-browserify>.
// Which is licensed:
//
// MIT License
//
// Copyright (c) 2013 James Halliday
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// A derivative work based on:
//
// Parts of that are extracted from Nodes internal `path` module:
// <https://github.com/nodejs/node/blob/master/lib/path.js>.
// Which is licensed:
//
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
exports.basename = basename
exports.dirname = dirname
exports.extname = extname
exports.join = join
exports.sep = '/'
function basename(path, ext) {
var start = 0
var end = -1
var index
var firstNonSlashEnd
var seenNonSlash
var extIndex
if (ext !== undefined && typeof ext !== 'string') {
throw new TypeError('"ext" argument must be a string')
}
assertPath(path)
index = path.length
if (ext === undefined || !ext.length || ext.length > path.length) {
while (index--) {
if (path.charCodeAt(index) === 47 /* `/` */) {
// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now.
if (seenNonSlash) {
start = index + 1
break
}
} else if (end < 0) {
// We saw the first non-path separator, mark this as the end of our
// path component.
seenNonSlash = true
end = index + 1
}
}
return end < 0 ? '' : path.slice(start, end)
}
if (ext === path) {
return ''
}
firstNonSlashEnd = -1
extIndex = ext.length - 1
while (index--) {
if (path.charCodeAt(index) === 47 /* `/` */) {
// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now.
if (seenNonSlash) {
start = index + 1
break
}
} else {
if (firstNonSlashEnd < 0) {
// We saw the first non-path separator, remember this index in case
// we need it if the extension ends up not matching.
seenNonSlash = true
firstNonSlashEnd = index + 1
}
if (extIndex > -1) {
// Try to match the explicit extension.
if (path.charCodeAt(index) === ext.charCodeAt(extIndex--)) {
if (extIndex < 0) {
// We matched the extension, so mark this as the end of our path
// component
end = index
}
} else {
// Extension does not match, so our result is the entire path
// component
extIndex = -1
end = firstNonSlashEnd
}
}
}
}
if (start === end) {
end = firstNonSlashEnd
} else if (end < 0) {
end = path.length
}
return path.slice(start, end)
}
function dirname(path) {
var end
var unmatchedSlash
var index
assertPath(path)
if (!path.length) {
return '.'
}
end = -1
index = path.length
// Prefix `--` is important to not run on `0`.
while (--index) {
if (path.charCodeAt(index) === 47 /* `/` */) {
if (unmatchedSlash) {
end = index
break
}
} else if (!unmatchedSlash) {
// We saw the first non-path separator
unmatchedSlash = true
}
}
return end < 0
? path.charCodeAt(0) === 47 /* `/` */
? '/'
: '.'
: end === 1 && path.charCodeAt(0) === 47 /* `/` */
? '//'
: path.slice(0, end)
}
function extname(path) {
var startDot = -1
var startPart = 0
var end = -1
// Track the state of characters (if any) we see before our first dot and
// after any path separator we find.
var preDotState = 0
var unmatchedSlash
var code
var index
assertPath(path)
index = path.length
while (index--) {
code = path.charCodeAt(index)
if (code === 47 /* `/` */) {
// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now.
if (unmatchedSlash) {
startPart = index + 1
break
}
continue
}
if (end < 0) {
// We saw the first non-path separator, mark this as the end of our
// extension.
unmatchedSlash = true
end = index + 1
}
if (code === 46 /* `.` */) {
// If this is our first dot, mark it as the start of our extension.
if (startDot < 0) {
startDot = index
} else if (preDotState !== 1) {
preDotState = 1
}
} else if (startDot > -1) {
// We saw a non-dot and non-path separator before our dot, so we should
// have a good chance at having a non-empty extension.
preDotState = -1
}
}
if (
startDot < 0 ||
end < 0 ||
// We saw a non-dot character immediately before the dot.
preDotState === 0 ||
// The (right-most) trimmed path component is exactly `..`.
(preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
) {
return ''
}
return path.slice(startDot, end)
}
function join() {
var index = -1
var joined
while (++index < arguments.length) {
assertPath(arguments[index])
if (arguments[index]) {
joined =
joined === undefined
? arguments[index]
: joined + '/' + arguments[index]
}
}
return joined === undefined ? '.' : normalize(joined)
}
// Note: `normalize` is not exposed as `path.normalize`, so some code is
// manually removed from it.
function normalize(path) {
var absolute
var value
assertPath(path)
absolute = path.charCodeAt(0) === 47 /* `/` */
// Normalize the path according to POSIX rules.
value = normalizeString(path, !absolute)
if (!value.length && !absolute) {
value = '.'
}
if (value.length && path.charCodeAt(path.length - 1) === 47 /* / */) {
value += '/'
}
return absolute ? '/' + value : value
}
// Resolve `.` and `..` elements in a path with directory names.
function normalizeString(path, allowAboveRoot) {
var result = ''
var lastSegmentLength = 0
var lastSlash = -1
var dots = 0
var index = -1
var code
var lastSlashIndex
while (++index <= path.length) {
if (index < path.length) {
code = path.charCodeAt(index)
} else if (code === 47 /* `/` */) {
break
} else {
code = 47 /* `/` */
}
if (code === 47 /* `/` */) {
if (lastSlash === index - 1 || dots === 1) {
// Empty.
} else if (lastSlash !== index - 1 && dots === 2) {
if (
result.length < 2 ||
lastSegmentLength !== 2 ||
result.charCodeAt(result.length - 1) !== 46 /* `.` */ ||
result.charCodeAt(result.length - 2) !== 46 /* `.` */
) {
if (result.length > 2) {
lastSlashIndex = result.lastIndexOf('/')
/* istanbul ignore else - No clue how to cover it. */
if (lastSlashIndex !== result.length - 1) {
if (lastSlashIndex < 0) {
result = ''
lastSegmentLength = 0
} else {
result = result.slice(0, lastSlashIndex)
lastSegmentLength = result.length - 1 - result.lastIndexOf('/')
}
lastSlash = index
dots = 0
continue
}
} else if (result.length) {
result = ''
lastSegmentLength = 0
lastSlash = index
dots = 0
continue
}
}
if (allowAboveRoot) {
result = result.length ? result + '/..' : '..'
lastSegmentLength = 2
}
} else {
if (result.length) {
result += '/' + path.slice(lastSlash + 1, index)
} else {
result = path.slice(lastSlash + 1, index)
}
lastSegmentLength = index - lastSlash - 1
}
lastSlash = index
dots = 0
} else if (code === 46 /* `.` */ && dots > -1) {
dots++
} else {
dots = -1
}
}
return result
}
function assertPath(path) {
if (typeof path !== 'string') {
throw new TypeError(
'Path must be a string. Received ' + JSON.stringify(path)
)
}
}

3
node_modules/vfile/lib/minpath.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict'
module.exports = require('path')

10
node_modules/vfile/lib/minproc.browser.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
'use strict'
// Somewhat based on:
// <https://github.com/defunctzombie/node-process/blob/master/browser.js>.
// But I dont think one tiny line of code can be copyrighted. 😅
exports.cwd = cwd
function cwd() {
return '/'
}

3
node_modules/vfile/lib/minproc.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict'
module.exports = process

21
node_modules/vfile/license generated vendored Normal file
View File

@@ -0,0 +1,21 @@
(The MIT License)
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

115
node_modules/vfile/package.json generated vendored Normal file
View File

@@ -0,0 +1,115 @@
{
"name": "vfile",
"version": "4.2.1",
"description": "Virtual file format for text processing",
"license": "MIT",
"keywords": [
"vfile",
"virtual",
"file",
"text",
"processing",
"message",
"warning",
"error",
"remark",
"retext",
"rehype"
],
"repository": "vfile/vfile",
"bugs": "https://github.com/vfile/vfile/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"Brendan Abbott <brendan.abbott@temando.com>",
"Denys Dovhan <email@denysdovhan.com>",
"Kyle Mathews <mathews.kyle@gmail.com>",
"Shinnosuke Watanabe <snnskwtnb@gmail.com>",
"Sindre Sorhus <sindresorhus@gmail.com>"
],
"types": "types/index.d.ts",
"browser": {
"./lib/minpath.js": "./lib/minpath.browser.js",
"./lib/minproc.js": "./lib/minproc.browser.js"
},
"react-native": {
"./lib/minpath.js": "./lib/minpath.browser.js",
"./lib/minproc.js": "./lib/minproc.browser.js"
},
"files": [
"lib/",
"types/index.d.ts",
"index.js",
"core.js"
],
"dependencies": {
"@types/unist": "^2.0.0",
"is-buffer": "^2.0.0",
"unist-util-stringify-position": "^2.0.0",
"vfile-message": "^2.0.0"
},
"devDependencies": {
"browserify": "^17.0.0",
"dtslint": "^4.0.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"tape": "^5.0.0",
"tinyify": "^3.0.0",
"xo": "^0.35.0"
},
"scripts": {
"format": "remark . -qfo && prettier . --write && xo --fix",
"build-bundle": "browserify . -s VFile -o vfile.js",
"build-mangle": "browserify . -s VFile -o vfile.min.js -p tinyify",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test-types": "dtslint types",
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"prettier": true,
"esnext": false,
"ignores": [
"types",
"vfile.js"
],
"rules": {
"unicorn/explicit-length-check": "off",
"unicorn/prefer-includes": "off",
"unicorn/prefer-reflect-apply": "off",
"unicorn/prefer-number-properties": "off",
"max-depth": "off",
"complexity": "off"
}
},
"remarkConfig": {
"plugins": [
"preset-wooorm",
[
"lint-no-html",
false
]
]
}
}

424
node_modules/vfile/readme.md generated vendored Normal file
View File

@@ -0,0 +1,424 @@
<h1>
<img src="https://raw.githubusercontent.com/vfile/vfile/7e1e6a6/logo.svg?sanitize=true" alt="vfile" width="400" />
</h1>
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
**vfile** is a small and browser friendly virtual file format that tracks
metadata (such as a files `path` and `contents`) and [messages][].
It was made specifically for **[unified][]** and generally for the common task
of parsing, transforming, and serializing data, where `vfile` handles everything
about the document being compiled.
This is useful for example when building linters, compilers, static site
generators, or other build tools.
**vfile** is part of the [unified collective][site].
* for updates, see [Twitter][]
* for more about us, see [`unifiedjs.com`][site]
* for questions, see [Discussions][chat]
* to help, see [contribute][] or [sponsor][] below
> **vfile** is different from the excellent [`vinyl`][vinyl] in that it has
> a smaller API, a smaller size, and focuses on [messages][].
## Contents
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`VFile(options?)`](#vfileoptions)
* [`vfile.contents`](#vfilecontents)
* [`vfile.cwd`](#vfilecwd)
* [`vfile.path`](#vfilepath)
* [`vfile.basename`](#vfilebasename)
* [`vfile.stem`](#vfilestem)
* [`vfile.extname`](#vfileextname)
* [`vfile.dirname`](#vfiledirname)
* [`vfile.history`](#vfilehistory)
* [`vfile.messages`](#vfilemessages)
* [`vfile.data`](#vfiledata)
* [`VFile#toString(encoding?)`](#vfiletostringencoding)
* [`VFile#message(reason[, position][, origin])`](#vfilemessagereason-position-origin)
* [`VFile#info(reason[, position][, origin])`](#vfileinforeason-position-origin)
* [`VFile#fail(reason[, position][, origin])`](#vfilefailreason-position-origin)
* [List of utilities](#list-of-utilities)
* [Reporters](#reporters)
* [Contribute](#contribute)
* [Sponsor](#sponsor)
* [Acknowledgments](#acknowledgments)
* [License](#license)
## Install
[npm][]:
```sh
npm install vfile
```
## Use
```js
var vfile = require('vfile')
var file = vfile({path: '~/example.txt', contents: 'Alpha *braavo* charlie.'})
file.path // => '~/example.txt'
file.dirname // => '~'
file.extname = '.md'
file.basename // => 'example.md'
file.basename = 'index.text'
file.history // => ['~/example.txt', '~/example.md', '~/index.text']
file.message('`braavo` is misspelt; did you mean `bravo`?', {
line: 1,
column: 8
})
console.log(file.messages)
```
Yields:
```js
[ { [~/index.text:1:8: `braavo` is misspelt; did you mean `bravo`?]
message: '`braavo` is misspelt; did you mean `bravo`?',
name: '~/index.text:1:8',
file: '~/index.text',
reason: '`braavo` is misspelt; did you mean `bravo`?',
line: 1,
column: 8,
location: { start: [Object], end: [Object] },
ruleId: null,
source: null,
fatal: false } ]
```
## API
### `VFile(options?)`
Create a new virtual file.
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`.
Path related properties are set in the following order (least specific to most
specific): `history`, `path`, `basename`, `stem`, `extname`, `dirname`.
Its not possible to set either `dirname` or `extname` without setting either
`history`, `path`, `basename`, or `stem` as well.
###### Example
```js
vfile()
vfile('console.log("alpha");')
vfile(Buffer.from('exit 1'))
vfile({path: path.join(__dirname, 'readme.md')})
vfile({stem: 'readme', extname: '.md', dirname: __dirname})
vfile({other: 'properties', are: 'copied', ov: {e: 'r'}})
```
### `vfile.contents`
`Buffer`, `string`, `null` — Raw value.
### `vfile.cwd`
`string` — Base of `path`.
Defaults to `process.cwd()`.
### `vfile.path`
`string?` — Path of `vfile`.
Cannot be nullified.
### `vfile.basename`
`string?` — Current name (including extension) of `vfile`.
Cannot contain path separators.
Cannot be nullified either (use `file.path = file.dirname` instead).
### `vfile.stem`
`string?` — Name (without extension) of `vfile`.
Cannot be nullified, and cannot contain path separators.
### `vfile.extname`
`string?` — Extension (with dot) of `vfile`.
Cannot be set if theres no `path` yet and cannot contain path separators.
### `vfile.dirname`
`string?` — Path to parent directory of `vfile`.
Cannot be set if theres no `path` yet.
### `vfile.history`
`Array.<string>` — List of file-paths the file moved between.
### `vfile.messages`
[`Array.<VMessage>`][message] — List of messages associated with the file.
### `vfile.data`
`Object` — Place to store custom information.
Its OK to store custom data directly on the `vfile`, moving it to `data` gives
a *little* more privacy.
### `VFile#toString(encoding?)`
Convert contents of `vfile` to string.
When `contents` is a [`Buffer`][buffer], `encoding` is a
[character encoding][encoding] to understand `doc` as (`string`, default:
`'utf8'`).
### `VFile#message(reason[, position][, origin])`
Associates a message with the file, where `fatal` is set to `false`.
Constructs a new [`VMessage`][vmessage] and adds it to
[`vfile.messages`][messages].
##### Returns
[`VMessage`][vmessage].
### `VFile#info(reason[, position][, origin])`
Associates an informational message with the file, where `fatal` is set to
`null`.
Calls [`#message()`][message] internally.
##### Returns
[`VMessage`][vmessage].
### `VFile#fail(reason[, position][, origin])`
Associates a fatal message with the file, then immediately throws it.
Note: fatal errors mean a file is no longer processable.
Calls [`#message()`][message] internally.
##### Throws
[`VMessage`][vmessage].
<a name="utilities"></a>
## List of utilities
The following list of projects includes tools for working with virtual files.
See **[unist][]** for projects that work with nodes.
* [`convert-vinyl-to-vfile`](https://github.com/dustinspecker/convert-vinyl-to-vfile)
— transform from [Vinyl][] to vfile
* [`to-vfile`](https://github.com/vfile/to-vfile)
— create a vfile from a filepath
* [`vfile-find-down`](https://github.com/vfile/vfile-find-down)
— find files by searching the file system downwards
* [`vfile-find-up`](https://github.com/vfile/vfile-find-up)
— find files by searching the file system upwards
* [`vfile-glob`](https://github.com/shinnn/vfile-glob)
— find files by glob patterns
* [`vfile-is`](https://github.com/vfile/vfile-is)
— check if a vfile passes a test
* [`vfile-location`](https://github.com/vfile/vfile-location)
— convert between positional and offset locations
* [`vfile-matter`](https://github.com/vfile/vfile-matter)
— parse the YAML front matter
* [`vfile-message`](https://github.com/vfile/vfile-message)
— create a vfile message
* [`vfile-messages-to-vscode-diagnostics`](https://github.com/shinnn/vfile-messages-to-vscode-diagnostics)
— transform vfile messages to VS Code diagnostics
* [`vfile-mkdirp`](https://github.com/vfile/vfile-mkdirp)
— make sure the directory of a vfile exists on the file system
* [`vfile-rename`](https://github.com/vfile/vfile-rename)
— rename the path parts of a vfile
* [`vfile-sort`](https://github.com/vfile/vfile-sort)
— sort messages by line/column
* [`vfile-statistics`](https://github.com/vfile/vfile-statistics)
— count messages per category: failures, warnings, etc
* [`vfile-to-eslint`](https://github.com/vfile/vfile-to-eslint)
— convert to ESLint formatter compatible output
## Reporters
The following list of projects show linting results for given virtual files.
Reporters *must* accept `Array.<VFile>` as their first argument, and return
`string`.
Reporters *may* accept other values too, in which case its suggested to stick
to `vfile-reporter`s interface.
* [`vfile-reporter`][reporter]
— create a report
* [`vfile-reporter-json`](https://github.com/vfile/vfile-reporter-json)
— create a JSON report
* [`vfile-reporter-folder-json`](https://github.com/vfile/vfile-reporter-folder-json)
— create a JSON representation of vfiles
* [`vfile-reporter-pretty`](https://github.com/vfile/vfile-reporter-pretty)
— create a pretty report
* [`vfile-reporter-junit`](https://github.com/kellyselden/vfile-reporter-junit)
— create a jUnit report
* [`vfile-reporter-position`](https://github.com/Hocdoc/vfile-reporter-position)
— create a report with content excerpts
## Contribute
See [`contributing.md`][contributing] in [`vfile/.github`][health] for ways to
get started.
See [`support.md`][support] for ways to get help.
Ideas for new utilities and tools can be posted in [`vfile/ideas`][ideas].
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
## Sponsor
Support this effort and give back by sponsoring on [OpenCollective][collective]!
<table>
<tr valign="middle">
<td width="20%" align="center" colspan="2">
<a href="https://www.gatsbyjs.org">Gatsby</a> 🥇<br><br>
<a href="https://www.gatsbyjs.org"><img src="https://avatars1.githubusercontent.com/u/12551863?s=256&v=4" width="128"></a>
</td>
<td width="20%" align="center" colspan="2">
<a href="https://vercel.com">Vercel</a> 🥇<br><br>
<a href="https://vercel.com"><img src="https://avatars1.githubusercontent.com/u/14985020?s=256&v=4" width="128"></a>
</td>
<td width="20%" align="center" colspan="2">
<a href="https://www.netlify.com">Netlify</a><br><br>
<!--OC has a sharper image-->
<a href="https://www.netlify.com"><img src="https://images.opencollective.com/netlify/4087de2/logo/256.png" width="128"></a>
</td>
<td width="10%" align="center">
<a href="https://www.holloway.com">Holloway</a><br><br>
<a href="https://www.holloway.com"><img src="https://avatars1.githubusercontent.com/u/35904294?s=128&v=4" width="64"></a>
</td>
<td width="10%" align="center">
<a href="https://themeisle.com">ThemeIsle</a><br><br>
<a href="https://themeisle.com"><img src="https://avatars1.githubusercontent.com/u/58979018?s=128&v=4" width="64"></a>
</td>
<td width="10%" align="center">
<a href="https://boosthub.io">Boost Hub</a><br><br>
<a href="https://boosthub.io"><img src="https://images.opencollective.com/boosthub/6318083/logo/128.png" width="64"></a>
</td>
<td width="10%" align="center">
<a href="https://expo.io">Expo</a><br><br>
<a href="https://expo.io"><img src="https://avatars1.githubusercontent.com/u/12504344?s=128&v=4" width="64"></a>
</td>
</tr>
<tr valign="middle">
<td width="100%" align="center" colspan="10">
<br>
<a href="https://opencollective.com/unified"><strong>You?</strong></a>
<br><br>
</td>
</tr>
</table>
## Acknowledgments
The initial release of this project was authored by
[**@wooorm**](https://github.com/wooorm).
Thanks to [**@contra**](https://github.com/contra),
[**@phated**](https://github.com/phated), and others for their work on
[Vinyl][], which was a huge inspiration.
Thanks to
[**@brendo**](https://github.com/brendo),
[**@shinnn**](https://github.com/shinnn),
[**@KyleAMathews**](https://github.com/KyleAMathews),
[**@sindresorhus**](https://github.com/sindresorhus), and
[**@denysdovhan**](https://github.com/denysdovhan)
for contributing commits since!
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[build-badge]: https://github.com/vfile/vfile/workflows/main/badge.svg
[build]: https://github.com/vfile/vfile/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/vfile/vfile.svg
[coverage]: https://codecov.io/github/vfile/vfile
[downloads-badge]: https://img.shields.io/npm/dm/vfile.svg
[downloads]: https://www.npmjs.com/package/vfile
[size-badge]: https://img.shields.io/bundlephobia/minzip/vfile.svg
[size]: https://bundlephobia.com/result?p=vfile
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/vfile/vfile/discussions
[npm]: https://docs.npmjs.com/cli/install
[contributing]: https://github.com/vfile/.github/blob/HEAD/contributing.md
[support]: https://github.com/vfile/.github/blob/HEAD/support.md
[health]: https://github.com/vfile/.github
[coc]: https://github.com/vfile/.github/blob/HEAD/code-of-conduct.md
[license]: license
[author]: https://wooorm.com
[unified]: https://github.com/unifiedjs/unified
[vinyl]: https://github.com/gulpjs/vinyl
[site]: https://unifiedjs.com
[twitter]: https://twitter.com/unifiedjs
[contribute]: #contribute
[sponsor]: #sponsor
[unist]: https://github.com/syntax-tree/unist#list-of-utilities
[reporter]: https://github.com/vfile/vfile-reporter
[vmessage]: https://github.com/vfile/vfile-message
[messages]: #vfilemessages
[message]: #vfilemessagereason-position-origin
[ideas]: https://github.com/vfile/ideas
[encoding]: https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
[buffer]: https://nodejs.org/api/buffer.html

161
node_modules/vfile/types/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,161 @@
// TypeScript Version: 3.0
import * as Unist from 'unist'
import * as vfileMessage from 'vfile-message'
declare namespace vfile {
/**
* Encodings supported by the buffer class
*
* @remarks
* This is a copy of the typing from Node, copied to prevent Node globals from being needed.
* Copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/a2bc1d868d81733a8969236655fa600bd3651a7b/types/node/globals.d.ts#L174
*/
type BufferEncoding =
| 'ascii'
| 'utf8'
| 'utf-8'
| 'utf16le'
| 'ucs2'
| 'ucs-2'
| 'base64'
| 'latin1'
| 'binary'
| 'hex'
/**
* VFileContents can either be text, or a Buffer like structure
* @remarks
* This does not directly use type `Buffer, because it can also be used in a browser context.
* Instead this leverages `Uint8Array` which is the base type for `Buffer`, and a native JavaScript construct.
*/
type VFileContents = string | Uint8Array
type VFileCompatible = VFile | VFileOptions | VFileContents
interface Settings {
[key: string]: unknown
}
type VFileReporter<T = Settings> = (files: VFile[], options: T) => string
interface VFileOptions {
contents?: VFileContents
path?: string
basename?: string
stem?: string
extname?: string
dirname?: string
cwd?: string
data?: any
[key: string]: any
}
interface VFile {
/**
* Create a new virtual file. 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`.
*
* Path related properties are set in the following order (least specific to most specific): `history`, `path`, `basename`, `stem`, `extname`, `dirname`.
*
* Its 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`.
*/
<F extends VFile>(input?: VFileContents | F | VFileOptions): F
/**
* List of file-paths the file moved between.
*/
history: 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.
*/
data: unknown
/**
* List of messages associated with the file.
*/
messages: vfileMessage.VFileMessage[]
/**
* Raw value.
*/
contents: VFileContents
/**
* Path of `vfile`.
* Cannot be nullified.
*/
path?: string
/**
* Path to parent directory of `vfile`.
* Cannot be set if there's no `path` yet.
*/
dirname?: 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
/**
* Base of `path`.
* Defaults to `process.cwd()`.
*/
cwd: string
/**
* Convert contents of `vfile` to string.
* @param encoding If `contents` is a buffer, `encoding` is used to stringify buffers (default: `'utf8'`).
*/
toString: (encoding?: BufferEncoding) => string
/**
* 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.
*/
message: (
reason: string,
position?: Unist.Point | Unist.Position | Unist.Node,
ruleId?: string
) => vfileMessage.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.
*/
fail: (
reason: string,
position?: Unist.Point | Unist.Position | Unist.Node,
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.
*/
info: (
reason: string,
position?: Unist.Point | Unist.Position | Unist.Node,
ruleId?: string
) => vfileMessage.VFileMessage
[key: string]: unknown
}
}
declare const vfile: vfile.VFile
export = vfile