Skip to content

Commit

Permalink
Updates for Eslint 9
Browse files Browse the repository at this point in the history
* Use alpha version of `eslint-typescript` 8
* Update our one custom rule
* Add workaround for `eslint-import` incompatibility (also needs to install with `npm install --force`)
  • Loading branch information
osmestad committed Jun 11, 2024
1 parent 8e4e555 commit 3a50e1a
Show file tree
Hide file tree
Showing 4 changed files with 925 additions and 542 deletions.
47 changes: 30 additions & 17 deletions internal-rules/require-coverage-ignore-reason.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,38 @@
// Switched to V8 reporter, with c8 comments.
// Docs: https://github.com/istanbuljs/v8-to-istanbul#ignoring-uncovered-lines

export function requireCoverageIgnoreReason(context) {
const coverageRegExp = /^\s*c8\s+ignore\s+(next|start)\s+/;
return {
Program() {
const sourceCode = context.getSourceCode();
/**
* @type {import("eslint").Rule.RuleModule}
*/
export const requireCoverageIgnoreReason = {
create: function (context) {
const coverageRegExp = /^\s*c8\s+ignore\s+(next|start)\s+/;
return {
Program() {
const sourceCode = context.sourceCode;

for (const node of sourceCode.getAllComments()) {
const comment = node.value;
for (const node of sourceCode.getAllComments()) {
const comment = node.value;

if (comment.match(coverageRegExp)) {
const reason = comment.replace(coverageRegExp, '');
if (reason.length === 0) {
context.report({
message: 'Add a reason why code coverage should be ignored',
node,
});
if (coverageRegExp.exec(comment)) {
const reason = comment.replace(coverageRegExp, '');
if (reason.length === 0) {
context.report({
message: 'Add a reason why code coverage should be ignored',
node,
});
}
}
}
}
},
};
},
meta: {
docs: {
description: 'Ensure that all coverage ignore comments have a reason',
},
};
}
fixable: 'code',
schema: [], // no options
type: 'suggestion',
},
};
Loading

0 comments on commit 3a50e1a

Please sign in to comment.