npx eslint --format ./eslint-overrides-formatter.js .
Last active
January 4, 2022 11:05
-
-
Save EvgenyOrekhov/c4d5c713927828ef61e122321c0f7381 to your computer and use it in GitHub Desktop.
ESLint formatter that outputs an "overrides" array with rules turned off
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
module.exports = (results) => { | |
const result = Object.entries( | |
results.reduce((accumulator, { filePath, messages }) => { | |
messages.forEach(({ ruleId }) => { | |
accumulator[ruleId] = [...(accumulator[ruleId] || []), filePath]; | |
}); | |
return accumulator; | |
}, {}) | |
).map(([ruleId, files]) => ({ | |
files: Array.from(new Set(files)), | |
rules: { [ruleId]: "off" }, | |
})); | |
return JSON.stringify(result, null, 2); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment