eslint-plugin-istanbul-ignore-preserve

0.0.3 • Public • Published

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, which strips all comments from the source codes (esbuild#516). So the following ignore hint will not work.

/* 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.

/* istanbul ignore if -- @preserve */
if (condition) {

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-istanbul-ignore-preserve:

npm install eslint-plugin-istanbul-ignore-preserve --save-dev

Usage

On your .eslintrc.json file extend the plugin's recommended configuration:

{
  "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:

{
  "plugins": ["istanbul-ignore-preserve"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "istanbul-ignore-preserve/preserve-keyword": "warn"
  }
}

Rules

🔧 Automatically fixable by the --fix CLI option.

Name Description 🔧
preserve-keyword Make sure istanbul ignore hint include a @preserve keyword. 🔧

LICENSE

MIT

Package Sidebar

Install

npm i eslint-plugin-istanbul-ignore-preserve

Weekly Downloads

11

Version

0.0.3

License

MIT

Unpacked Size

8.93 kB

Total Files

8

Last publish

Collaborators

  • yaoyuanzhang