Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(linter): use CompactStr in no-console #6399

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions crates/oxc_linter/src/rules/eslint/no_console.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use oxc_ast::{ast::Expression, AstKind};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use oxc_span::{CompactStr, Span};

use crate::{context::LintContext, rule::Rule, AstNode};

Expand All @@ -21,7 +21,7 @@ pub struct NoConsoleConfig {
/// console.log('foo'); // will error
/// console.info('bar'); // will not error
/// ```
pub allow: Vec<String>,
pub allow: Vec<CompactStr>,
}

impl std::ops::Deref for NoConsole {
Expand Down Expand Up @@ -58,10 +58,7 @@ impl Rule for NoConsole {
.and_then(|v| v.get("allow"))
.and_then(serde_json::Value::as_array)
.map(|v| {
v.iter()
.filter_map(serde_json::Value::as_str)
.map(ToString::to_string)
.collect()
v.iter().filter_map(serde_json::Value::as_str).map(CompactStr::from).collect()
})
.unwrap_or_default(),
}))
Expand Down