index.ts 827 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import type { CAC } from 'cac';
  2. import { $ } from '@vben/node-utils';
  3. interface LintCommandOptions {
  4. /**
  5. * Format lint problem.
  6. */
  7. format?: boolean;
  8. }
  9. async function runLint({ format }: LintCommandOptions) {
  10. process.env.FORCE_COLOR = '3';
  11. if (format) {
  12. await $`stylelint "**/*.{vue,css,less.scss}" --cache --fix`;
  13. await $`eslint . --cache --fix`;
  14. await $`prettier . --write --cache`;
  15. return;
  16. }
  17. await Promise.all([
  18. $`eslint . --cache`,
  19. // $`ls-lint`,
  20. $`prettier . --ignore-unknown --check --cache`,
  21. $`stylelint "**/*.{vue,css,less.scss}" --cache`,
  22. ]);
  23. }
  24. function defineLintCommand(cac: CAC) {
  25. cac
  26. .command('lint')
  27. .usage('Batch execute project lint check.')
  28. .option('--format', 'Format lint problem.')
  29. .action(runLint);
  30. }
  31. export { defineLintCommand };