lint.mjs 747 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env zx
  2. import 'zx/globals';
  3. import {
  4. cliArguments,
  5. getToolchainArgument,
  6. popArgument,
  7. workingDirectory,
  8. } from '../utils.mjs';
  9. const [folder, ...args] = cliArguments();
  10. // Configure arguments here.
  11. const lintArgs = [
  12. '-Zunstable-options',
  13. '--all-targets',
  14. '--all-features',
  15. '--',
  16. '--deny=warnings',
  17. '--deny=clippy::arithmetic_side_effects',
  18. ...args,
  19. ];
  20. const fix = popArgument(lintArgs, '--fix');
  21. const toolchain = getToolchainArgument('lint');
  22. const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
  23. if (fix) {
  24. await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} --fix ${lintArgs}`;
  25. } else {
  26. await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} ${lintArgs}`;
  27. }