Mailspring/app/build/tasks/eslint-task.js
Ben Gotow 2ed09fbd41
Remove unused Grunt tasks and clean up eslint task (#2569)
- Remove docs-build, docs-render, and setup-mac-keychain tasks that are
  no longer used in CI/CD pipelines
- Fix eslint task bug where format option was undefined, add explicit
  'stylish' formatter
- Remove unused eslint task options (outputFile, quiet, maxWarnings)
- Remove related npm scripts (build-docs, ci-setup-mac-keychain)
- Remove unused dependencies (handlebars, joanna, meta-marked)
- Clean up package-task.js comment referencing removed task

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-19 22:12:33 -06:00

57 lines
1.2 KiB
JavaScript

const chalk = require('chalk');
const eslint = require('eslint');
module.exports = grunt => {
grunt.config.merge({
eslint: {
options: {
configFile: '../.eslintrc',
parserOptions: {
project: './tsconfig.json',
},
format: 'stylish',
},
target: grunt.config('source:es6'),
},
});
grunt.registerMultiTask('eslint', 'Validate files with ESLint', function task() {
const opts = this.options({
format: 'stylish',
});
if (this.filesSrc.length === 0) {
grunt.log.writeln(chalk.magenta('Could not find any files to validate.'));
return true;
}
const formatter = eslint.CLIEngine.getFormatter(opts.format);
if (!formatter) {
grunt.warn(`Could not find formatter ${opts.format}.`);
return false;
}
const engine = new eslint.CLIEngine(opts);
let report = null;
try {
report = engine.executeOnFiles(this.filesSrc);
} catch (err) {
grunt.warn(err);
return false;
}
if (opts.fix) {
eslint.CLIEngine.outputFixes(report);
}
const output = formatter(report.results);
if (output) {
console.log(output);
}
return report.errorCount === 0;
});
};