Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhrznr committed Nov 6, 2024
1 parent 9612dd3 commit 0f760b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 8 additions & 6 deletions api/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,12 +808,13 @@ fn check_for_banned_extensions(
) -> Result<(), PublishError> {
match parsed_source.media_type() {
deno_ast::MediaType::Cjs | deno_ast::MediaType::Cts => {
return Err(PublishError::BannedCommonJsExtension { specifier: parsed_source.specifier().to_string() } );
},
_ => {
Ok(())
return Err(PublishError::BannedCommonJsExtension {
specifier: parsed_source.specifier().to_string(),
});
}
}}
_ => Ok(()),
}
}

fn check_for_banned_syntax(
parsed_source: &ParsedSource,
Expand Down Expand Up @@ -992,7 +993,8 @@ mod tests {

#[test]
fn banned_extensions() {
let x = parse_with_media_type("let x = 1;", deno_ast::MediaType::TypeScript);
let x =
parse_with_media_type("let x = 1;", deno_ast::MediaType::TypeScript);
assert!(super::check_for_banned_extensions(&x).is_ok());

let x = parse_with_media_type("let x = 1;", deno_ast::MediaType::Cjs);
Expand Down
6 changes: 2 additions & 4 deletions api/src/tarball.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,7 @@ pub enum PublishError {
},

#[error("CommonJS is not allowed {specifier}")]
BannedCommonJsExtension {
specifier: String,
},
BannedCommonJsExtension { specifier: String },

#[error("triple slash directives that modify globals (for example, '/// <reference no-default-lib=\"true\" />' or '/// <reference lib=\"dom\" />') are not allowed. Instead instruct the user of your package to specify these directives. {specifier}:{line}:{column}")]
BannedTripleSlashDirectives {
Expand Down Expand Up @@ -649,7 +647,7 @@ impl PublishError {
PublishError::CommonJs { .. } => Some("commonJs"),
PublishError::BannedCommonJsExtension { .. } => {
Some("bannedCommonJsExtension")
},
}
PublishError::BannedTripleSlashDirectives { .. } => {
Some("bannedTripleSlashDirectives")
}
Expand Down

0 comments on commit 0f760b8

Please sign in to comment.