https://github.com/vfile/vfile-to-eslint
utility to convert to ESLint formatter compatible output
https://github.com/vfile/vfile-to-eslint
convert eslint file vfile vfile-util virtual
Last synced: about 1 year ago
JSON representation
utility to convert to ESLint formatter compatible output
- Host: GitHub
- URL: https://github.com/vfile/vfile-to-eslint
- Owner: vfile
- License: mit
- Created: 2016-08-04T22:30:58.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2023-06-14T10:48:03.000Z (about 3 years ago)
- Last Synced: 2024-12-17T04:03:25.248Z (over 1 year ago)
- Topics: convert, eslint, file, vfile, vfile-util, virtual
- Language: JavaScript
- Homepage: https://unifiedjs.com
- Size: 137 KB
- Stars: 17
- Watchers: 10
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# vfile-to-eslint
[![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]
Convert [VFiles][vfile] to [ESLint][] formatter compatible output.
![][screenshot]
## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`toESLint(files)`](#toeslintfiles)
* [Types](#types)
* [Compatibility](#compatibility)
* [Contribute](#contribute)
* [License](#license)
## What is this?
This package turns a file into the `LintResult` schema that ESLint uses for its
formatters
## When should I use this?
While vfile and ESLint results are different, they do overlap in some places.
This package can be used to integrate with ESLint in those cases.
In other cases, a custom vfile utility might be a better solution.
## Install
This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:
```sh
npm install vfile-to-eslint
```
In Deno with [`esm.sh`][esmsh]:
```js
import {toESLint} from 'https://esm.sh/vfile-to-eslint@4'
```
In browsers with [`esm.sh`][esmsh]:
```html
import {toESLint} from 'https://esm.sh/vfile-to-eslint@4?bundle'
```
## Use
```js
import {remark} from 'remark'
import remarkPresetLintRecommended from 'remark-preset-lint-recommended'
import eslintFormatterPretty from 'eslint-formatter-pretty'
import {toESLint} from 'vfile-to-eslint'
const file = await remark()
.use(remarkPresetLintRecommended)
.process('## Hello world!')
console.log(eslintFormatterPretty(toESLint([file])))
```
## API
This package exports the identifier [`toESLint`][api-to-eslint].
There is no default export.
### `toESLint(files)`
Turn virtual files into a ESLint results that can be passed directly to an
[ESLint formatter][eslint-formatter].
###### Parameters
* `files` ([`Array`][vfile])
— list of files
###### Returns
Lint results ([`Array`][lintresult])
## Types
This package is fully typed with [TypeScript][].
It exports the additional type [`LintResult`][lintresult].
## Compatibility
Projects maintained by the unified collective are compatible with maintained
versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, `vfile-to-eslint@^4`,
compatible with Node.js 16.
## Contribute
See [`contributing.md`][contributing] in [`vfile/.github`][health] for ways to
get started.
See [`support.md`][support] for ways to get help.
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
## License
[MIT][license] © [Sindre Sorhus][author]
[build-badge]: https://github.com/vfile/vfile-to-eslint/workflows/main/badge.svg
[build]: https://github.com/vfile/vfile-to-eslint/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/vfile/vfile-to-eslint.svg
[coverage]: https://codecov.io/github/vfile/vfile-to-eslint
[downloads-badge]: https://img.shields.io/npm/dm/vfile-to-eslint.svg
[downloads]: https://www.npmjs.com/package/vfile-to-eslint
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=vfile-to-eslint
[size]: https://bundlejs.com/?q=vfile-to-eslint
[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
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esmsh]: https://esm.sh
[typescript]: https://www.typescriptlang.org
[contributing]: https://github.com/vfile/.github/blob/main/contributing.md
[support]: https://github.com/vfile/.github/blob/main/support.md
[health]: https://github.com/vfile/.github
[coc]: https://github.com/vfile/.github/blob/main/code-of-conduct.md
[license]: license
[author]: https://sindresorhus.com
[screenshot]: screenshot.png
[vfile]: https://github.com/vfile/vfile
[eslint]: https://eslint.org
[eslint-formatter]: https://npms.io/search?term=eslint-formatter
[lintresult]: https://eslint.org/docs/latest/integrate/nodejs-api#-lintresult-type
[api-to-eslint]: #toeslintfiles