attw-report.cjs 1.1 KB

123456789101112131415161718192021222324
  1. const fs = require('fs');
  2. const problems = Object.values(JSON.parse(fs.readFileSync('.attw.json', 'utf-8')).problems)
  3. .flat()
  4. .filter(
  5. (problem) =>
  6. !(
  7. // This is intentional, if the user specifies .mjs they get ESM.
  8. (
  9. (problem.kind === 'CJSResolvesToESM' && problem.entrypoint.endsWith('.mjs')) ||
  10. // This is intentional for backwards compat reasons.
  11. (problem.kind === 'MissingExportEquals' && problem.implementationFileName.endsWith('/index.js')) ||
  12. // this is intentional, we deliberately attempt to import types that may not exist from parent node_modules
  13. // folders to better support various runtimes without triggering automatic type acquisition.
  14. (problem.kind === 'InternalResolutionError' && problem.moduleSpecifier.includes('node_modules'))
  15. )
  16. ),
  17. );
  18. fs.unlinkSync('.attw.json');
  19. if (problems.length) {
  20. process.stdout.write('The types are wrong!\n' + JSON.stringify(problems, null, 2) + '\n');
  21. process.exitCode = 1;
  22. } else {
  23. process.stdout.write('Types ok!\n');
  24. }