Skip to content

Commit

Permalink
Merge pull request #41 from tidal-music/feature/major-updates
Browse files Browse the repository at this point in the history
Updates for Eslint 9

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 authored Jun 24, 2024
2 parents 8e4e555 + 291004e commit 5c04699
Show file tree
Hide file tree
Showing 5 changed files with 927 additions and 544 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -16,7 +16,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: npm install and test
run: |
npm ci
npm ci --force
npm test
env:
CI: true
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 5c04699

Please sign in to comment.