Skip to content

Instantly share code, notes, and snippets.

@EvgenyOrekhov
Last active January 4, 2022 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvgenyOrekhov/c4d5c713927828ef61e122321c0f7381 to your computer and use it in GitHub Desktop.
Save EvgenyOrekhov/c4d5c713927828ef61e122321c0f7381 to your computer and use it in GitHub Desktop.
ESLint formatter that outputs an "overrides" array with rules turned off
npx eslint --format ./eslint-overrides-formatter.js .
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