Skip to content

Commit

Permalink
feat: Report correct errors for missing use client in global-errors…
Browse files Browse the repository at this point in the history
….ts (vercel#69583)

### What?

Adjust regex for file name which is used for linting.


### Why?

We should apply same validation as `error.ts` to `global-error.ts`

### How?

Closes PACK-2977
Fixes vercel#64452
  • Loading branch information
kdy1 committed Sep 3, 2024
1 parent d67e020 commit adc94b4
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{collections::HashMap, path::PathBuf, rc::Rc, sync::Arc};

use once_cell::sync::Lazy;
use regex::Regex;
use serde::Deserialize;
use swc_core::{
Expand Down Expand Up @@ -617,9 +618,10 @@ impl ReactServerComponentValidator {
if self.is_from_node_modules(&self.filepath) {
return;
}
let is_error_file = Regex::new(r"[\\/]error\.(ts|js)x?$")
.unwrap()
.is_match(&self.filepath);
static RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"[\\/]((global-)?error)\.(ts|js)x?$").unwrap());

let is_error_file = RE.is_match(&self.filepath);

if is_error_file {
if let Some(app_dir) = &self.app_dir {
Expand Down

0 comments on commit adc94b4

Please sign in to comment.