1
1

lint.mjs 840 B

123456789101112131415161718192021222324252627282930313233
  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 additional arguments here, e.g.:
  11. // ['--arg1', '--arg2', ...cliArguments()]
  12. const lintArgs = [
  13. '-Zunstable-options',
  14. '--all-targets',
  15. '--all-features',
  16. '--',
  17. '--deny=warnings',
  18. '--deny=clippy::arithmetic_side_effects',
  19. ...args,
  20. ];
  21. const fix = popArgument(lintArgs, '--fix');
  22. const toolchain = getToolchainArgument('lint');
  23. const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
  24. // Check the client using Clippy.
  25. if (fix) {
  26. await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} --fix ${lintArgs}`;
  27. } else {
  28. await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} ${lintArgs}`;
  29. }