perf(linter): run rules which require typescript syntax only when source type is actually typescript (#8166)

This commit is contained in:
Alexander S. 2024-12-28 18:03:11 +01:00 committed by GitHub
parent 9d62284202
commit d8d2ec6257
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 0 deletions

View file

@ -118,6 +118,10 @@ impl Rule for ConsistentGenericConstructors {
.unwrap_or_default(),
}))
}
fn should_run(&self, ctx: &crate::rules::ContextHost) -> bool {
ctx.source_type().is_typescript()
}
}
impl ConsistentGenericConstructors {

View file

@ -140,6 +140,10 @@ impl Rule for NoEmptyObjectType {
_ => {}
}
}
fn should_run(&self, ctx: &crate::rules::ContextHost) -> bool {
ctx.source_type().is_typescript()
}
}
fn check_interface_declaration(

View file

@ -113,6 +113,10 @@ impl Rule for NoMisusedNew {
_ => {}
}
}
fn should_run(&self, ctx: &crate::rules::ContextHost) -> bool {
ctx.source_type().is_typescript()
}
}
#[test]

View file

@ -76,6 +76,10 @@ impl Rule for NoUnsafeFunctionType {
_ => {}
}
}
fn should_run(&self, ctx: &crate::rules::ContextHost) -> bool {
ctx.source_type().is_typescript()
}
}
fn handle_function_type<'a>(identifier: &'a IdentifierReference<'a>, ctx: &LintContext<'a>) {

View file

@ -99,6 +99,10 @@ impl Rule for NoWrapperObjectTypes {
}
}
}
fn should_run(&self, ctx: &crate::rules::ContextHost) -> bool {
ctx.source_type().is_typescript()
}
}
#[test]