forked from graphql/graphql-js
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop "eslint-plugin-istanbul" and implement as internal ESLint rule
It blocks us from using ESLint8, see: istanbuljs/eslint-plugin-istanbul#17
- Loading branch information
1 parent
82ff653
commit 2c8d151
Showing
5 changed files
with
27 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
resources/eslint-internal-rules/require-coverage-ignore-reason.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
module.exports = function requireCoverageIgnoreReason(context) { | ||
const istanbulRegExp = /^\s*istanbul\s+ignore\s+(if|else|next|file)\s+/; | ||
return { | ||
Program() { | ||
const sourceCode = context.getSourceCode(); | ||
|
||
for (const node of sourceCode.getAllComments()) { | ||
const comment = node.value; | ||
|
||
if (comment.match(istanbulRegExp)) { | ||
const reason = comment.replace(istanbulRegExp, ''); | ||
if (!reason.match(/\(.+\)$/)) { | ||
context.report({ | ||
message: 'Add a reason why code coverage should be ignored', | ||
node, | ||
}); | ||
} | ||
} | ||
} | ||
}, | ||
}; | ||
}; |