0.0.3 ā€¢ Published 7 months ago

eslint-plugin-istanbul-ignore-preserve v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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.

NameDescriptionšŸ”§
preserve-keywordMake sure istanbul ignore hint include a @preserve keyword.šŸ”§

LICENSE

MIT