Skip to content

Instantly share code, notes, and snippets.

@pastak
Last active May 31, 2023 02:47
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 pastak/77e82d35a7129cc9c0ccb8e1397f9b08 to your computer and use it in GitHub Desktop.
Save pastak/77e82d35a7129cc9c0ccb8e1397f9b08 to your computer and use it in GitHub Desktop.
const { ESLint, Linter } = require('eslint');
const path = require('path');
const eslint = new ESLint();
const fixable = new Map();
new Linter().getRules().forEach((val, key) => {
if (val.meta.fixable) {
fixable.set(key, true);
}
});
(async function main() {
const results = await eslint.lintFiles(['.']);
results.forEach((r) => {
const filepath = path.relative(process.cwd(), r.filePath);
r.messages.forEach((message) => {
console.log(
[
filepath,
message.line,
message.column,
message.endLine,
message.endColumn,
message.ruleId,
message.message,
fixable.get(message.ruleId) ? 'true' : 'false',
].join('\t')
);
});
});
})().catch((error) => {
process.exitCode = 1;
console.error(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment