deno
5ac9eab4 - fix(publish): catch banned triple slash directives anywhere in file during dry-run (#35010)

Commit
180 days ago
fix(publish): catch banned triple slash directives anywhere in file during dry-run (#35010) During `deno publish --dry-run`, the check for banned triple slash directives only scanned comments that lead the first statement (`get_leading_comments()`). A banned directive such as `/// <reference lib="deno.unstable" />` placed *after* other code (for example after an import) was therefore not reported during a dry run, yet the JSR registry rejects it at publish time: ``` error: Failed to publish @scope/pkg at 1.0.0: Triple slash directives that modify globals [...] are not allowed. ``` This fix scans **all** comments in the file (`comments().get_vec()`) instead of just the leading ones, so the dry-run diagnostics match the registry behaviour wherever the directive appears. Added a regression spec test `tests/specs/publish/banned_triple_slash_directives_not_leading` covering a directive placed after a statement (the existing `banned_triple_slash_directives` test only covers leading directives). Closes #22286 Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
Author
Parents
Loading