filterReports not showing errors
benmonro opened this issue · comments
I have a simple filterReports rule but when I run the rule, it doesn't show the errors in the project which definitely has the rule violation. I even went nuclear and tried:
const noNewSnapshotsRule = ruleComposer.filterReports(
jestNoLargeSnapshots, () => true)
)
am i missing something or should it be showing up in the report when i run lint in the project?
Are you sure you're enabling the new rule you've created in your config file? It would be useful to see a bit more information about what happens to noNewSnapshotsRule
after you create it.
@not-an-aardvark yeah, eslint will complain if it's not enabled, and I put console.logs in the rule filter, which i definitely see.
here's the full rule:
const eslint = require('eslint');
const ruleComposer = require('eslint-rule-composer');
const jestNoLargeSnapshots = require('eslint-plugin-jest').rules['no-large-snapshots'];
const allowedSnapshots = require('../extras/allowed-snapshots.json');
const allowedFiles = allowedSnapshots.map(({ filePath }) => filePath);
const noNewSnapshotsRule = ruleComposer.filterReports(
jestNoLargeSnapshots,
(problem, metadata) => {
const whitelistIndex = allowedSnapshots.findIndex(violation => {
const fileIsMatch = metadata.filename.endsWith(violation.filePath);
if (!fileIsMatch) {
return false;
}
const lineIsMatch = (violation.messages.findIndex(
({ line }) => problem.loc.start.line === line
)) !== -1;
return lineIsMatch;
});
if (whitelistIndex === -1) {
console.log(metadata.filename, problem.loc.start.line)
}
return whitelistIndex == -1;
}
);
module.exports = noNewSnapshotsRule;
when i run the eslint
I definitely see console lines... am i missing something?
any insight @not-an-aardvark ? :)
No, not sure what's going on, sorry.
Would it be possible to create a repository demonstrating the issue?