Skip to content

Commit

Permalink
chore: Update README
Browse files Browse the repository at this point in the history
- Add Russian README
  • Loading branch information
nikolay-borzov committed Dec 17, 2023
1 parent 5d27375 commit e6f25c3
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 42 deletions.
65 changes: 23 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
[![ru](https://img.shields.io/badge/lang-ru-%23d52b1e)](./README.ru.md)

[![NPM version][npm-image]][npm-url] [![install size](https://packagephobia.com/badge?p=rollup-plugin-eslint-bundle)](https://packagephobia.com/result?p=rollup-plugin-eslint-bundle) ![build](https://github.com/nikolay-borzov/rollup-plugin-eslint-bundle/workflows/CI/badge.svg) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) ![npm type definitions](https://img.shields.io/npm/types/rollup-plugin-eslint-bundle)

# rollup-plugin-eslint-bundle

[npm-image]: https://img.shields.io/npm/v/rollup-plugin-eslint-bundle.svg
[npm-url]: https://npmjs.org/package/rollup-plugin-eslint-bundle
[rollup]: https://github.com/rollup/rollup
[eslint]: https://github.com/eslint/eslint
[eslint-config]: https://eslint.org/docs/developer-guide/nodejs-api#parameters

🍣 A [Rollup] plugin to lint and fix bundled code with ESLint.
🍣 A [Rollup] plugin to lint and fix bundled code with [ESLint].

## Requirements

This plugin requires an Node.js v18.x, Rollup v3.x and ESLint v8.x
This plugin requires an Node.js v20.x, Rollup v4.x and ESLint v8.x

## Install

Expand All @@ -23,8 +26,8 @@ npm i -D rollup-plugin-eslint-bundle

```js
// rollup.config.js ESM
import { rollup } from 'rollup';
import { eslintBundle } from 'rollup-plugin-eslint-bundle';
import { rollup } from 'rollup'
import { eslintBundle } from 'rollup-plugin-eslint-bundle'

const root = path.dirname(url.fileURLToPath(import.meta.url))

Expand All @@ -38,22 +41,21 @@ export default {
},
throwOnWarning: true,
throwOnError: true,
formatter: 'compact'
formatter: 'compact',
}),
],

output: {
file: path.resolve(root, './dist/bundle.js'),
format: 'es',
},
};

}
```
```js
// Rollup JavaScript API
import { rollup } from 'rollup';
import { eslintBundle } from 'rollup-plugin-eslint-bundle';
import { rollup } from 'rollup'
import { eslintBundle } from 'rollup-plugin-eslint-bundle'

// ...

Expand All @@ -66,48 +68,27 @@ const bundle = await rollup.rollup({
},
throwOnWarning: true,
throwOnError: true,
formatter: 'compact'
})
]
});
formatter: 'compact',
}),
],
})

await bundle.write({
file: 'dist/bundle.js',
format: 'es',
});
})

await bundle.close();
await bundle.close()
```
## Options
### `eslintOptions`
[ESLint class options object](https://eslint.org/docs/developer-guide/nodejs-api#parameters).
### `throwOnWarning`
Type: `boolean`
Default: `false`
If true, will throw an error if any warnings were found.
### `throwOnError`
Type: `boolean`
Default: `false`
If true, will throw an error if any errors were found.
### `formatter`
Type: `string`
Default: `undefined`
[Value](https://eslint.org/docs/developer-guide/nodejs-api#-eslintloadformatternameorpath) to be passed to `eslint.loadFormatter()`
| | Description |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `eslintOptions` | [ESLint class options object](https://eslint.org/docs/developer-guide/nodejs-api#parameters) |
| `throwOnWarning` | `boolean` (Default: `false`)<br>If true, will throw an error if any ESLint warnings were found. |
| `throwOnError` | `boolean` (Default: `false`)<br>If true, will throw an error if any ESLint errors were found. |
| `formatter` | `string` (Default: `undefined`)<br>[Value](https://eslint.org/docs/developer-guide/nodejs-api#-eslintloadformatternameorpath) to be passed to `eslint.loadFormatter()` |
## License
Expand Down
99 changes: 99 additions & 0 deletions README.ru.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[![en](https://img.shields.io/badge/lang-en-%233c3b6e)](./)

[![NPM version][npm-image]][npm-url] [![install size](https://packagephobia.com/badge?p=rollup-plugin-eslint-bundle)](https://packagephobia.com/result?p=rollup-plugin-eslint-bundle) ![build](https://github.com/nikolay-borzov/rollup-plugin-eslint-bundle/workflows/CI/badge.svg) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) ![npm type definitions](https://img.shields.io/npm/types/rollup-plugin-eslint-bundle)

# rollup-plugin-eslint-bundle

[npm-image]: https://img.shields.io/npm/v/rollup-plugin-eslint-bundle.svg
[npm-url]: https://npmjs.org/package/rollup-plugin-eslint-bundle
[rollup]: https://github.com/rollup/rollup
[eslint]: https://github.com/eslint/eslint
[eslint-config]: https://eslint.org/docs/developer-guide/nodejs-api#parameters

🍣 Плагин для [Rollup] для проверки и исправления собранного кода с помощью [ESLint].

## Требования

Плагин требует Node.js v20.x, Rollup v4.x и ESLint v8.x

## Установка

```sh
npm i -D rollup-plugin-eslint-bundle
```

## Использование

```js
// rollup.config.js ESM
import { rollup } from 'rollup'
import { eslintBundle } from 'rollup-plugin-eslint-bundle'

const root = path.dirname(url.fileURLToPath(import.meta.url))

export default {
input: path.resolve(root, './main.js'),

plugins: [
eslintBundle({
eslintOptions: {
fix: true,
},
throwOnWarning: true,
throwOnError: true,
formatter: 'compact',
}),
],

output: {
file: path.resolve(root, './dist/bundle.js'),
format: 'es',
},
}
```
```js
// Rollup JavaScript API
import { rollup } from 'rollup'
import { eslintBundle } from 'rollup-plugin-eslint-bundle'

// ...

const bundle = await rollup.rollup({
input: 'main.js',
plugins: [
eslintBundle({
eslintOptions: {
fix: true,
},
throwOnWarning: true,
throwOnError: true,
formatter: 'compact',
}),
],
})

await bundle.write({
file: 'dist/bundle.js',
format: 'es',
})

await bundle.close()
```
## Опции
| | Описание |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `eslintOptions` | [Параметры класса ESLint](https://eslint.org/docs/developer-guide/nodejs-api#parameters). |
| `throwOnWarning` | `boolean` (по умолчанию: `false`)<br>Выбрасывать исключение при наличии ошибок ESLint с уровнем `warn`. |
| `throwOnError` | `boolean` (по умолчанию: `false`)<br>Выбрасывать исключение при наличии ошибок ESLint с уровнем `error`. |
| `formatter` | `string` (по умолчанию: `undefined`)<br>[Значение](https://eslint.org/docs/developer-guide/nodejs-api#-eslintloadformatternameorpath) будет передано в `eslint.loadFormatter()` |
## Лицензия
MIT License (MIT)
## Поучаствовать
Предложения улучшений (PR) и сообщения о найденных дефектов (Issues) приветствуются. Вопросы можно обсудить в рамках Обсуждений.

0 comments on commit e6f25c3

Please sign in to comment.