Skip to content

Commit

Permalink
prisma-fmt: Add file name into lint errors (#4855)
Browse files Browse the repository at this point in the history
Needed for `language-tools` multiple schemas
  • Loading branch information
SevInf committed May 7, 2024
1 parent f77c9dd commit 56ca112
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions prisma-fmt/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::schema_file_input::SchemaFileInput;

#[derive(serde::Serialize)]
pub struct MiniError {
file_name: String,
start: usize,
end: usize,
text: String,
Expand All @@ -21,6 +22,7 @@ pub(crate) fn run(schema: SchemaFileInput) -> String {
.errors()
.iter()
.map(|err: &DatamodelError| MiniError {
file_name: schema.db.file_name(err.span().file_id).to_owned(),
start: err.span().start,
end: err.span().end,
text: err.message().to_string(),
Expand All @@ -32,6 +34,7 @@ pub(crate) fn run(schema: SchemaFileInput) -> String {
.warnings()
.iter()
.map(|warn: &DatamodelWarning| MiniError {
file_name: schema.db.file_name(warn.span().file_id).to_owned(),
start: warn.span().start,
end: warn.span().end,
text: warn.message().to_owned(),
Expand Down Expand Up @@ -83,6 +86,7 @@ mod tests {
let expected = expect![[r#"
[
{
"file_name": "schema.prisma",
"start": 149,
"end": 163,
"text": "Preview feature \"createMany\" is deprecated. The functionality can be used without specifying it as a preview feature.",
Expand Down Expand Up @@ -121,6 +125,7 @@ mod tests {
let expected = expect![[r#"
[
{
"file_name": "schema1.prisma",
"start": 149,
"end": 163,
"text": "Preview feature \"createMany\" is deprecated. The functionality can be used without specifying it as a preview feature.",
Expand Down

0 comments on commit 56ca112

Please sign in to comment.