mirror of
https://github.com/Foundry376/Mailspring.git
synced 2026-01-21 08:19:44 +08:00
- 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>
57 lines
1.2 KiB
JavaScript
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;
|
|
});
|
|
};
|