Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yyz945947732/eslint-plugin-istanbul-ignore-preserve
Eslint Plugin aims to make sure istanbul include a @preserve keyword in the ignore hint
https://github.com/yyz945947732/eslint-plugin-istanbul-ignore-preserve
coverage eslint eslint-plugin eslintplugin istanbul istanbul-coverage istanbul-ignore
Last synced: 1 day ago
JSON representation
Eslint Plugin aims to make sure istanbul include a @preserve keyword in the ignore hint
- Host: GitHub
- URL: https://github.com/yyz945947732/eslint-plugin-istanbul-ignore-preserve
- Owner: yyz945947732
- License: mit
- Created: 2023-10-11T12:23:59.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-13T06:17:54.000Z (about 1 year ago)
- Last Synced: 2024-10-12T17:21:55.193Z (about 1 month ago)
- Topics: coverage, eslint, eslint-plugin, eslintplugin, istanbul, istanbul-coverage, istanbul-ignore
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/eslint-plugin-istanbul-ignore-preserve
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-istanbul-ignore-preserve
ESLint plugin to make sure ignore hint include a `@preserve` keyword. This is useful when your project is using istanbul and esbuild together.
## Why use
If your project source codes are transpiled using [esbuild](https://esbuild.github.io/), which strips all comments from the source codes ([esbuild#516](https://github.com/evanw/esbuild/issues/516)). So the following ignore hint will not work.
```js
/* istanbul ignore if */
if (condition) {
```For istanbul coverage you need include a `@preserve` keyword in the ignore hint to make this work. Comments which are considered as legal comments are preserved.
```js
/* istanbul ignore if -- @preserve */
if (condition) {
```## Installation
You'll first need to install [ESLint](https://eslint.org/):
```sh
npm i eslint --save-dev
```Next, install `eslint-plugin-istanbul-ignore-preserve`:
```sh
npm install eslint-plugin-istanbul-ignore-preserve --save-dev
```## Usage
On your `.eslintrc.json` file extend the plugin's recommended configuration:
```json
{
"extends": ["plugin:istanbul-ignore-preserve/recommended"]
}
```If you want to use your own configuration, you can do so by adding the plugin to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
```json
{
"plugins": ["istanbul-ignore-preserve"]
}
```Then configure the rules you want to use under the rules section.
```json
{
"rules": {
"istanbul-ignore-preserve/preserve-keyword": "warn"
}
}
```## Rules
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
| Name | Description | 🔧 |
| :------------------------------------------------- | :---------------------------------------------------------- | :-- |
| [preserve-keyword](docs/rules/preserve-keyword.md) | Make sure istanbul ignore hint include a @preserve keyword. | 🔧 |## LICENSE
[MIT](https://github.com/yyz945947732/eslint-plugin-istanbul-ignore-preserve/blob/master/LICENSE)