lint-clippy.mjs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env zx
  2. import 'zx/globals';
  3. import {
  4. cliArguments,
  5. getToolchainArgument,
  6. popArgument,
  7. workingDirectory,
  8. } from '../utils.mjs';
  9. // Configure additional arguments here, e.g.:
  10. // ['--arg1', '--arg2', ...cliArguments()]
  11. const lintArgs = ['--all-targets', '--all-features', ...cliArguments()];
  12. // Check whether a '--' was already used.
  13. if (lintArgs.indexOf('--') === -1) {
  14. lintArgs.push('--');
  15. }
  16. // Add additional arguments.
  17. lintArgs.push(
  18. '--deny=warnings',
  19. '--deny=clippy::default_trait_access',
  20. '--deny=clippy::arithmetic_side_effects',
  21. '--deny=clippy::manual_let_else',
  22. '--deny=clippy::used_underscore_binding'
  23. );
  24. const fix = popArgument(lintArgs, '--fix');
  25. // Note: need to use nightly clippy as frozen-abi proc-macro generates
  26. // a lot of code (frozen-abi is enabled only under nightly due to the
  27. // use of unstable rust feature). Likewise, frozen-abi(-macro) crates'
  28. // unit tests are only compiled under nightly.
  29. const toolchain = getToolchainArgument('lint');
  30. const manifestPath = path.join(workingDirectory, 'interface', 'Cargo.toml');
  31. // Lint the interface.
  32. await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} ${fix ? '--fix' : ''} ${lintArgs}`;