repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_allocator/src/allocators/mod.rs
crates/swc_allocator/src/allocators/mod.rs
//! Various flavors of allocators pub use self::{arena::Arena, global::Global, scoped::Scoped}; mod arena; mod global; mod scoped;
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_allocator/src/api/mod.rs
crates/swc_allocator/src/api/mod.rs
//! Various flavors of allocator. /// Re-export for convenience. #[cfg(feature = "hashbrown")] pub extern crate hashbrown; /// Types for arena allocator pub mod arena { #[allow(unused_imports)] use crate::allocators::Arena; /// See [`hashbrown::HashMap`]. #[cfg(feature = "hashbrown")] pub type Ha...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_allocator/src/types/mod.rs
crates/swc_allocator/src/types/mod.rs
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_allocator/tests/alloction.rs
crates/swc_allocator/tests/alloction.rs
#![cfg(feature = "nightly")] use criterion::black_box; use swc_allocator::{boxed::Box, Allocator, FastAlloc}; #[test] fn direct_alloc_std() { let mut buf = std::vec::Vec::new(); for i in 0..1000 { let item: std::boxed::Box<usize> = black_box(std::boxed::Box::new(black_box(i))); buf.push(item);...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_allocator/benches/bench.rs
crates/swc_allocator/benches/bench.rs
extern crate swc_malloc; use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion}; use swc_allocator::{boxed::Box as SwcBox, vec::Vec as SwcVec, Allocator, FastAlloc}; fn bench_alloc(c: &mut Criterion) { fn direct_alloc_std(b: &mut Bencher, times: usize) { b.iter(|| ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_timer/src/lib.rs
crates/swc_timer/src/lib.rs
#[doc(hidden)] pub extern crate tracing; use tracing::{info, span::EnteredSpan}; /// Prints time elapsed since `start` when dropped. /// /// See [timer] for usages. pub struct Timer { #[cfg(not(target_arch = "wasm32"))] _span: EnteredSpan, #[cfg(not(target_arch = "wasm32"))] start: std::time::Instant,...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_timer/tests/timer.rs
crates/swc_timer/tests/timer.rs
use swc_timer::timer; #[test] fn logging() { testing::run_test(false, |_, _| { let _timer = timer!("operation"); Ok(()) }) .unwrap(); }
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2017/src/lib.rs
crates/swc_ecma_compat_es2017/src/lib.rs
use serde::Deserialize; use swc_common::Mark; use swc_ecma_ast::Pass; pub use self::async_to_generator::async_to_generator; pub mod async_to_generator; pub fn es2017(c: Config, unresolved_mark: Mark) -> impl Pass { async_to_generator(c.async_to_generator, unresolved_mark) } #[derive(Debug, Clone, Copy, Default,...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2017/src/async_to_generator.rs
crates/swc_ecma_compat_es2017/src/async_to_generator.rs
use serde::Deserialize; use swc_common::{Mark, SyntaxContext}; use swc_ecma_ast::*; /// `@babel/plugin-transform-async-to-generator` /// /// ## In /// /// ```js /// async function foo() { /// await bar(); /// } /// ``` /// /// ## Out /// /// ```js /// var _async_to_generator = function (fn) { /// ... /// }; /// va...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_visit/src/lib.rs
crates/swc_visit/src/lib.rs
//! Visitor generator for the rust language. //! //! //! There are three variants of visitor in swc. Those are `Fold`, `VisitMut`, //! `Visit`. //! //! # Comparisons //! //! ## `Fold` vs `VisitMut` //! //! `Fold` and `VisitMut` do almost identical tasks, but `Fold` is easier to use //! while being slower and weak to st...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_visit/src/util/map.rs
crates/swc_visit/src/util/map.rs
use std::ptr; /// Copied from `syntax::ptr::P` of rustc. pub trait Map<T> { /// Transform the inner value, consuming `self` and producing a new `P<T>`. /// /// # Memory leak /// /// This will leak `self` if the given closure panics. fn map<F>(self, f: F) -> Self where F: FnOnce(T) -...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_visit/src/util/mod.rs
crates/swc_visit/src/util/mod.rs
//! Some utilities for generated visitors. pub mod map; pub mod move_map;
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_visit/src/util/move_map.rs
crates/swc_visit/src/util/move_map.rs
use std::{iter, ptr}; /// Modifiers vector in-place. pub trait MoveMap<T>: Sized { /// Map in place. fn move_map<F>(self, mut f: F) -> Self where F: FnMut(T) -> T, { self.move_flat_map(|e| iter::once(f(e))) } /// This will be very slow if you try to extend vector using this met...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_plugin_backend_wasmtime/src/lib.rs
crates/swc_plugin_backend_wasmtime/src/lib.rs
use std::path::Path; use anyhow::Context; use swc_common::sync::OnceCell; use swc_plugin_runner::runtime; /// Identifier for bytecode cache stored in local filesystem. /// /// This MUST be updated when bump up wasmtime. const MODULE_SERIALIZATION_IDENTIFIER: &str = concat!("wasmtime", "-", "v35"); static ENGINE: Onc...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/config.rs
crates/swc_css_lints/src/config.rs
use std::fmt::Debug; use serde::{Deserialize, Serialize}; use crate::rules::{ at_rule_no_unknown::AtRuleNoUnknownConfig, color_hex_alpha::ColorHexAlphaConfig, color_hex_length::ColorHexLengthConfig, font_family_no_duplicate_names::FontFamilyNoDuplicateNamesConfig, no_invalid_position_at_import_rule::N...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/lib.rs
crates/swc_css_lints/src/lib.rs
#![deny(clippy::all)] mod config; mod dataset; mod error; mod pattern; mod rule; mod rules; pub use config::LintConfig; pub(crate) use error::ConfigError; pub use rule::LintRule; pub use rules::{get_rules, LintParams};
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/pattern.rs
crates/swc_css_lints/src/pattern.rs
use swc_config::regex::CachedRegex; #[derive(Debug)] pub(crate) enum NamePattern { Str(String), Regex(CachedRegex), } impl NamePattern { pub(crate) fn is_match<S>(&self, name: S) -> bool where S: AsRef<str>, { let name = name.as_ref(); match self { Self::Str(s) ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/dataset.rs
crates/swc_css_lints/src/dataset.rs
pub(crate) fn is_generic_font_keyword<S: AsRef<str>>(name: S) -> bool { let name = name.as_ref(); name.eq_ignore_ascii_case("serif") || name.eq_ignore_ascii_case("sans-serif") || name.eq_ignore_ascii_case("cursive") || name.eq_ignore_ascii_case("fantasy") || name.eq_ignore_ascii_...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/error.rs
crates/swc_css_lints/src/error.rs
use thiserror::Error; #[derive(Error, Debug)] pub enum ConfigError { #[error("invalid regex")] Regex(#[from] anyhow::Error), }
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rule.rs
crates/swc_css_lints/src/rule.rs
use std::{fmt::Debug, sync::Arc}; use auto_impl::auto_impl; use par_iter::prelude::*; use parking_lot::Mutex; use serde::Serialize; use swc_common::{ errors::{Diagnostic, DiagnosticBuilder, Emitter, Handler, HANDLER}, Spanned, }; use swc_css_ast::Stylesheet; use swc_css_visit::{Visit, VisitWith}; use super::c...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/font_family_no_duplicate_names.rs
crates/swc_css_lints/src/rules/font_family_no_duplicate_names.rs
use rustc_hash::FxHashSet; use serde::{Deserialize, Serialize}; use swc_common::Span; use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::{ dataset::is_generic_font_keyword, pattern::NamePattern, rule::{visitor_rule, LintRule, LintRuleContext}, ConfigError, }; #[derive(Debug, Clone, ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/selector_max_class.rs
crates/swc_css_lints/src/rules/selector_max_class.rs
use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::rule::{visitor_rule, LintRule, LintRuleContext}; pub(crate) type SelectorMaxClassConfig = Option<usize>; pub fn selector_max_class(ctx: LintRuleContext<SelectorMaxClassConfig>) -> Box<dyn LintRule> { let max = ctx.config().unwrap_or(3); vi...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/color_hex_alpha.rs
crates/swc_css_lints/src/rules/color_hex_alpha.rs
use serde::{Deserialize, Serialize}; use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::rule::{visitor_rule, LintRule, LintRuleContext}; pub type ColorHexAlphaConfig = Option<Preference>; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum Preference { A...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/no_empty_source.rs
crates/swc_css_lints/src/rules/no_empty_source.rs
use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::rule::{visitor_rule, LintRule, LintRuleContext}; pub fn no_empty_source(ctx: LintRuleContext<()>) -> Box<dyn LintRule> { visitor_rule(ctx.reaction(), NoEmptySource { ctx }) } const MESSAGE: &str = "Unexpected empty source."; #[derive(Debug, D...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/no_duplicate_at_import_rules.rs
crates/swc_css_lints/src/rules/no_duplicate_at_import_rules.rs
use std::fmt::Display; use rustc_hash::FxHashSet; use swc_atoms::Atom; use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::rule::{visitor_rule, LintRule, LintRuleContext}; pub fn no_duplicate_at_import_rules(ctx: LintRuleContext<()>) -> Box<dyn LintRule> { visitor_rule( ctx.reaction(), ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/custom_property_no_missing_var_function.rs
crates/swc_css_lints/src/rules/custom_property_no_missing_var_function.rs
use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::rule::{visitor_rule, LintRule, LintRuleContext}; pub fn custom_property_no_missing_var_function(ctx: LintRuleContext<()>) -> Box<dyn LintRule> { visitor_rule( ctx.reaction(), CustomPropertyNoMissingVarFunction { ctx,...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/color_no_invalid_hex.rs
crates/swc_css_lints/src/rules/color_no_invalid_hex.rs
use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::rule::{visitor_rule, LintRule, LintRuleContext}; pub fn color_no_invalid_hex(ctx: LintRuleContext<()>) -> Box<dyn LintRule> { visitor_rule(ctx.reaction(), ColorNoInvalidHex { ctx }) } #[derive(Debug, Default)] struct ColorNoInvalidHex { ct...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/no_invalid_position_at_import_rule.rs
crates/swc_css_lints/src/rules/no_invalid_position_at_import_rule.rs
use serde::{Deserialize, Serialize}; use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::{ pattern::NamePattern, rule::{visitor_rule, LintRule, LintRuleContext}, ConfigError, }; const MESSAGE: &str = "Unexpected invalid position '@import' rule."; #[derive(Debug, Clone, Default, Serializ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/mod.rs
crates/swc_css_lints/src/rules/mod.rs
use crate::{ config::LintConfig, error::ConfigError, rule::LintRule, rules::{ at_rule_no_unknown::at_rule_no_unknown, block_no_empty::block_no_empty, color_hex_alpha::color_hex_alpha, color_hex_length::color_hex_length, color_no_invalid_hex::color_no_invalid_hex, custom_p...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/color_hex_length.rs
crates/swc_css_lints/src/rules/color_hex_length.rs
use serde::{Deserialize, Serialize}; use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::rule::{visitor_rule, LintRule, LintRuleContext}; pub type ColorHexLengthConfig = Option<HexForm>; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum HexForm { Long, ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/unit_no_unknown.rs
crates/swc_css_lints/src/rules/unit_no_unknown.rs
use serde::{Deserialize, Serialize}; use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::{ pattern::NamePattern, rule::{visitor_rule, LintRule, LintRuleContext}, ConfigError, }; #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct UnitNoU...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/keyframe_declaration_no_important.rs
crates/swc_css_lints/src/rules/keyframe_declaration_no_important.rs
use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::rule::{visitor_rule, LintRule, LintRuleContext}; pub fn keyframe_declaration_no_important(ctx: LintRuleContext<()>) -> Box<dyn LintRule> { visitor_rule( ctx.reaction(), KeyframeDeclarationNoImportant { ctx, ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/at_rule_no_unknown.rs
crates/swc_css_lints/src/rules/at_rule_no_unknown.rs
use serde::{Deserialize, Serialize}; use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::{ pattern::NamePattern, rule::{visitor_rule, LintRule, LintRuleContext}, ConfigError, }; #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct AtRuleN...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/declaration_no_important.rs
crates/swc_css_lints/src/rules/declaration_no_important.rs
use swc_common::Span; use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::rule::{visitor_rule, LintRule, LintRuleContext}; pub fn declaration_no_important(ctx: LintRuleContext<()>) -> Box<dyn LintRule> { visitor_rule( ctx.reaction(), DeclarationNoImportant { ctx, ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/selector_max_combinators.rs
crates/swc_css_lints/src/rules/selector_max_combinators.rs
use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::rule::{visitor_rule, LintRule, LintRuleContext}; pub type SelectorMaxCombinatorsConfig = Option<usize>; pub fn selector_max_combinators( ctx: LintRuleContext<SelectorMaxCombinatorsConfig>, ) -> Box<dyn LintRule> { let max = ctx.config().un...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/src/rules/block_no_empty.rs
crates/swc_css_lints/src/rules/block_no_empty.rs
use swc_css_ast::*; use swc_css_visit::{Visit, VisitWith}; use crate::rule::{visitor_rule, LintRule, LintRuleContext}; pub fn block_no_empty(ctx: LintRuleContext<()>) -> Box<dyn LintRule> { visitor_rule(ctx.reaction(), BlockNoEmpty { ctx }) } const MESSAGE: &str = "Unexpected empty block."; #[derive(Debug, Defa...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_css_lints/tests/lints.rs
crates/swc_css_lints/tests/lints.rs
#![allow(clippy::needless_update)] use std::{fs, path::PathBuf}; use swc_common::{errors::HANDLER, input::SourceFileInput}; use swc_css_lints::{get_rules, LintConfig, LintParams, LintRule}; use swc_css_parser::{lexer::Lexer, parser::Parser}; #[testing::fixture("tests/rules/pass/**/input.css")] fn pass(input: PathBuf...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/ast_node/src/lib.rs
crates/ast_node/src/lib.rs
#![deny(clippy::all)] #![recursion_limit = "1024"] extern crate proc_macro; use quote::quote; use swc_macros_common::prelude::*; use syn::{visit_mut::VisitMut, *}; mod ast_node_macro; mod encoding; mod enum_deserialize; mod spanned; /// Derives [`swc_common::Spanned`]. See [`swc_common::Spanned`] for /// documentat...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/ast_node/src/ast_node_macro.rs
crates/ast_node/src/ast_node_macro.rs
use swc_macros_common::prelude::*; use syn::{ parse::{Parse, ParseStream}, *, }; #[derive(Clone)] pub struct Args { pub ty: Literal, } impl Parse for Args { fn parse(i: ParseStream<'_>) -> syn::Result<Self> { Ok(Args { ty: i.parse()? }) } } pub fn expand_struct(args: Args, i: DeriveInput)...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/ast_node/src/spanned.rs
crates/ast_node/src/spanned.rs
#![allow(dead_code)] use swc_macros_common::prelude::*; use syn::{parse::Parse, spanned::Spanned, *}; struct MyField { /// Name of the field. pub ident: Option<Ident>, /// Type of the field. pub ty: Type, /// `#[span(lo)]` pub lo: bool, /// `#[span(hi)]` pub hi: bool, } struct InputF...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/ast_node/src/enum_deserialize.rs
crates/ast_node/src/enum_deserialize.rs
use swc_macros_common::prelude::*; use syn::{ parse::{Parse, ParseStream}, *, }; struct VariantAttr { tags: Punctuated<Lit, Token![,]>, } impl Parse for VariantAttr { fn parse(input: ParseStream<'_>) -> syn::Result<Self> { Ok(VariantAttr { tags: input.call(Punctuated::parse_termina...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/ast_node/src/encoding/encode.rs
crates/ast_node/src/encoding/encode.rs
use syn::{spanned::Spanned, Data, DeriveInput}; use super::{is_ignore, is_unknown, is_with, EnumType}; pub fn expand(DeriveInput { ident, data, .. }: DeriveInput) -> syn::ItemImpl { match data { Data::Struct(data) => { let fields = data .fields .iter() ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/ast_node/src/encoding/decode.rs
crates/ast_node/src/encoding/decode.rs
use syn::{spanned::Spanned, Data, DeriveInput}; use super::{is_ignore, is_unknown, is_with, EnumType}; pub fn expand(DeriveInput { ident, data, .. }: DeriveInput) -> syn::ItemImpl { match data { Data::Struct(data) => { let is_named = data.fields.iter().any(|field| field.ident.is_some()); ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/ast_node/src/encoding/mod.rs
crates/ast_node/src/encoding/mod.rs
pub(crate) mod decode; pub(crate) mod encode; #[derive(Clone, Copy, PartialEq, Eq, Debug)] enum EnumType { Unit, One, Struct, } pub(crate) fn is_unknown(attrs: &[syn::Attribute]) -> bool { attrs .iter() .filter(|attr| attr.path().is_ident("encoding")) .any(|attr| { ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_macros_common/src/prelude.rs
crates/swc_macros_common/src/prelude.rs
pub use proc_macro2::{Delimiter, Group, Literal, Punct, Span, TokenStream, TokenTree}; pub use quote::ToTokens; pub use syn::punctuated::{Pair as Element, Punctuated}; pub use super::{ binder::{BindedField, Binder, VariantBinder}, call_site, def_site, derive::Derive, doc_str, is_attr_name, print, s...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_macros_common/src/lib.rs
crates/swc_macros_common/src/lib.rs
//! Internal crate for the swc project. extern crate proc_macro; use proc_macro2::{Span, TokenStream}; use quote::ToTokens; use syn::{punctuated::Pair, *}; pub mod binder; pub mod derive; pub mod prelude; mod syn_ext; pub fn call_site() -> Span { Span::call_site() } pub fn def_site() -> Span { call_site() ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_macros_common/src/derive.rs
crates/swc_macros_common/src/derive.rs
use std::iter; use proc_macro2::TokenStream; use quote::ToTokens; use syn::{punctuated::Pair, *}; use crate::def_site; mod generics; /// Generics of derived impl item. #[derive(Debug, Clone)] pub struct Derive<'a> { input: &'a DeriveInput, out: ItemImpl, } impl<'a> Derive<'a> { pub fn new(input: &'a De...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_macros_common/src/syn_ext.rs
crates/swc_macros_common/src/syn_ext.rs
use quote::quote; use syn::{punctuated::Pair, *}; use crate::def_site; /// Extension trait for `ItemImpl` (impl block). pub trait ItemImplExt { /// Instead of /// /// ```rust,ignore /// let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); /// /// let item: Item = Q...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_macros_common/src/binder.rs
crates/swc_macros_common/src/binder.rs
//! # Example //! //! `_binded_a`, `_binded_b` and `_binded_0` in below example are //! `BindedField`. //! //! ```rust //! struct S { //! a: u8, //! b: u16, //! } //! let s = S { a: 0, b: 0 }; //! match s { //! S { //! a: _binded_a, //! b: _binded_b, //! } => {} //! } //! enum E { //! ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_macros_common/src/derive/generics.rs
crates/swc_macros_common/src/derive/generics.rs
use std::collections::BTreeSet; use quote::quote; use syn::visit::Visit; use super::*; impl<'a> Derive<'a> { pub fn all_generic_fields(&self) -> Vec<&'a Field> { struct TypeVisitor<'a> { params: &'a BTreeSet<Ident>, is_generic: bool, } impl Visit<'_> for TypeVisit...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_malloc/src/lib.rs
crates/swc_malloc/src/lib.rs
//! This crate configures memory allocator. //! //! The swc crates related to the node binding should depend on this crate. //! //! # Memory Allocator Selection Strategy //! //! This crate configures the global memory allocator based on the target //! platform: //! //! - **mimalloc**: Used for most platforms (Windows, ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/testing/src/lib.rs
crates/testing/src/lib.rs
use std::{ env, fmt::{self, Debug, Display, Formatter}, fs::{create_dir_all, rename, File}, io::Write, path::{Component, Path, PathBuf}, process::Command, str::FromStr, sync::RwLock, thread, }; use difference::Changeset; use once_cell::sync::Lazy; pub use pretty_assertions::{assert_...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/testing/src/diag_errors.rs
crates/testing/src/diag_errors.rs
use std::sync::RwLock; use swc_common::{ errors::{Diagnostic, DiagnosticBuilder, Emitter, Handler, HandlerFlags, SourceMapperDyn}, sync::Lrc, }; /// Creates a new handler for testing. pub(crate) fn new_handler( _: Lrc<SourceMapperDyn>, treat_err_as_bug: bool, ) -> (Handler, BufferedError) { let e ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/testing/src/paths.rs
crates/testing/src/paths.rs
use std::{env, path::PathBuf, sync::Arc}; use once_cell::sync::Lazy; pub fn manifest_dir() -> PathBuf { env::var("CARGO_MANIFEST_DIR") .map(PathBuf::from) .map(|p| { p.canonicalize() .expect("failed to canonicalize `CARGO_MANIFEST_DIR`") }) .unwrap_or_el...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/testing/src/json.rs
crates/testing/src/json.rs
use serde_json::Value; fn normalize_value_recursively(v: &mut Value, normalize: &mut dyn FnMut(&str, &mut Value)) { match v { Value::Array(arr) => { for v in arr { normalize_value_recursively(v, normalize); } } Value::Object(obj) => { for...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/testing/src/macros.rs
crates/testing/src/macros.rs
#[allow(unused_macros)] macro_rules! try_panic { ($e:expr) => {{ $e.unwrap_or_else(|err| { panic!("{} failed with {}", stringify!($e), err); }) }}; }
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/testing/src/string_errors.rs
crates/testing/src/string_errors.rs
use std::{ fmt, io::{self, Write}, sync::{Arc, RwLock}, }; use swc_common::{ errors::{Emitter, Handler, HandlerFlags}, sync::Lrc, SourceMap, }; use swc_error_reporters::{GraphicalReportHandler, GraphicalTheme, ToPrettyDiagnostic}; use super::StdErr; use crate::errors::{multi_emitter, stderr::s...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/testing/src/output.rs
crates/testing/src/output.rs
use std::{ env, fmt, fs::{self, create_dir_all, File}, io::Read, ops::Deref, path::Path, }; use serde::Serialize; use tracing::debug; use crate::paths; #[must_use] pub struct TestOutput<R> { /// Errors produced by `swc_common::error::Handler`. pub errors: StdErr, pub result: R, } pub...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/testing/src/errors/stderr.rs
crates/testing/src/errors/stderr.rs
use swc_common::{ errors::{DiagnosticBuilder, Emitter}, sync::Lrc, SourceMap, }; use swc_error_reporters::{GraphicalReportHandler, ToPrettyDiagnostic}; use tracing::{info, metadata::LevelFilter, Level}; /// This emitter is controlled by the env var `RUST_LOG`. /// /// This emitter will print to stderr if t...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/testing/src/errors/mod.rs
crates/testing/src/errors/mod.rs
use swc_common::errors::{DiagnosticBuilder, Emitter}; pub(crate) mod stderr; pub(crate) fn multi_emitter(a: Box<dyn Emitter>, b: Box<dyn Emitter>) -> Box<dyn Emitter> { Box::new(MultiEmitter { a, b }) } struct MultiEmitter { a: Box<dyn Emitter>, b: Box<dyn Emitter>, } impl Emitter for MultiEmitter { ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/src/wasm_analysis.rs
crates/swc/src/wasm_analysis.rs
#![cfg(feature = "plugin")] use std::sync::Arc; use anyhow::{Context, Result}; use common::{ comments::SingleThreadedComments, errors::Handler, plugin::{metadata::TransformPluginMetadataContext, serialized::PluginSerializedBytes}, Mark, SourceFile, GLOBALS, }; use rustc_hash::FxHashMap; use serde::Des...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/src/builder.rs
crates/swc/src/builder.rs
use swc_common::{comments::Comments, sync::Lrc, util::take::Take, Mark, SourceMap}; use swc_ecma_ast::{Module, Script}; use swc_ecma_minifier::option::{terser::TerserTopLevelOptions, MinifyOptions}; use swc_ecma_transforms::{hygiene::hygiene_with_config, resolver}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, Vi...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/src/lib.rs
crates/swc/src/lib.rs
//! The main crate of the swc project. //! //! //! //! # Customizing //! //! //! This is documentation for building custom build tools on top of swc. //! //! ## Dependency version management //! //! `swc` has [swc_css](https://docs.rs/swc_css), which re-exports required modules. //! //! ## Testing //! //! See [testing]...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
true
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/src/dropped_comments_preserver.rs
crates/swc/src/dropped_comments_preserver.rs
use swc_common::{ comments::{Comment, Comments, SingleThreadedComments}, BytePos, Span, DUMMY_SP, }; use swc_ecma_ast::{Module, Pass, Script}; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; /// Preserves comments that would otherwise be dropped. /// /// If during compilation...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/src/plugin.rs
crates/swc/src/plugin.rs
//! This module always exists because cfg attributes are not stabilized in //! expressions at the moment. #![cfg_attr( any(not(any(feature = "plugin")), target_arch = "wasm32"), allow(unused) )] use std::{path::PathBuf, sync::Arc}; use anyhow::{Context, Result}; use atoms::Atom; use common::FileName; #[cfg(a...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/src/config/tests.rs
crates/swc/src/config/tests.rs
use crate::parse_swcrc; #[test] fn object() { let rc = parse_swcrc(include_str!("object.json")).expect("failed to parse"); dbg!(&rc); } #[test] fn array() { let rc = parse_swcrc(include_str!("array.json")).expect("failed to parse"); dbg!(&rc); } #[test] fn issue_4390() { let rc = parse_swcrc(inc...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/src/config/mod.rs
crates/swc/src/config/mod.rs
use std::{ collections::HashMap, env, path::{Path, PathBuf}, sync::Arc, }; use anyhow::{bail, Context, Error}; use bytes_str::BytesStr; use dashmap::DashMap; use either::Either; use indexmap::IndexMap; use once_cell::sync::Lazy; use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet}; use serde::{Deseria...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
true
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/tests/source_map.rs
crates/swc/tests/source_map.rs
#![allow(unused)] use std::{ env::temp_dir, fs::{self, canonicalize, create_dir_all, File}, io::Write, path::{Path, PathBuf}, process::{Command, Output}, sync::Arc, }; use anyhow::{Context, Error}; use swc::{ config::{ Config, InputSourceMap, IsModule, JscConfig, ModuleConfig, Opti...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/tests/serde.rs
crates/swc/tests/serde.rs
use std::path::Path; use swc_ecma_ast::Module; use swc_ecma_parser::{lexer::Lexer, PResult, Parser, Syntax}; use testing::NormalizedOutput; fn with_parser<F, Ret>(file_name: &str, f: F) -> Result<Ret, NormalizedOutput> where F: FnOnce(&mut Parser<Lexer>) -> PResult<Ret>, { ::testing::run_test(false, |cm, hand...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/tests/simple.rs
crates/swc/tests/simple.rs
use swc::{ config::{Config, IsModule, JscConfig, Options}, Compiler, }; use swc_common::FileName; use swc_ecma_ast::EsVersion; use swc_ecma_parser::{Syntax, TsSyntax}; use testing::Tester; fn compile(src: &str, options: Options) -> String { Tester::new() .print_errors(|cm, handler| { le...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/tests/projects.rs
crates/swc/tests/projects.rs
use std::{ env::current_dir, fs::create_dir_all, path::{Path, PathBuf}, }; use anyhow::Context; use par_iter::prelude::*; use swc::{ config::{ Config, FileMatcher, JsMinifyOptions, JscConfig, ModuleConfig, Options, Paths, SourceMapsConfig, TransformConfig, }, try_with_handler, B...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
true
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/tests/rust_api.rs
crates/swc/tests/rust_api.rs
use swc::{ config::{Config, InputSourceMap, JscConfig, ModuleConfig, Options, SourceMapsConfig}, Compiler, }; use swc_common::{comments::SingleThreadedComments, FileName}; use swc_ecma_ast::*; use swc_ecma_parser::{EsSyntax, Syntax, TsSyntax}; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut};...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/tests/error_msg.rs
crates/swc/tests/error_msg.rs
use std::path::{Path, PathBuf}; use swc::{ config::{Config, IsModule, JscConfig, JscExperimental, Options}, try_with_handler, Compiler, HandlerOpts, }; use swc_common::{errors::ColorConfig, sync::Lrc, FilePathMapping, SourceMap, GLOBALS}; use testing::{NormalizedOutput, Tester}; fn file(f: impl AsRef<Path>) -...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/tests/tsc.rs
crates/swc/tests/tsc.rs
use std::{ borrow::Cow, ffi::OsStr, fmt::Write, fs::create_dir_all, mem, panic::{catch_unwind, resume_unwind, AssertUnwindSafe}, path::{Path, PathBuf}, sync::Arc, }; use once_cell::sync::Lazy; use regex::Regex; use rustc_hash::FxHashSet; use serde::de::DeserializeOwned; use serde_json::...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/tests/exec.rs
crates/swc/tests/exec.rs
use std::{ env, fs, path::{Path, PathBuf}, process::Command, sync::Arc, }; use anyhow::{Context, Error}; use once_cell::sync::Lazy; use swc::{ config::{ Config, JsMinifyOptions, JscConfig, ModuleConfig, Options, SourceMapsConfig, TransformConfig, }, try_with_handler, BoolOrD...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/benches/isolated_declarations.rs
crates/swc/benches/isolated_declarations.rs
use std::{path::Path, sync::Arc}; use criterion::{criterion_group, criterion_main, Criterion}; use swc_common::{comments::SingleThreadedComments, FilePathMapping, Mark, SourceMap, GLOBALS}; use swc_ecma_parser::{parse_file_as_program, Syntax}; use swc_ecma_transforms::{fixer::paren_remover, resolver}; use swc_typescri...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/benches/oxc.rs
crates/swc/benches/oxc.rs
extern crate swc_malloc; use std::{fs, io::stderr, sync::Arc}; use bytes_str::BytesStr; use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion}; use swc::config::{Config, JscConfig, Options, TransformConfig}; use swc_common::{errors::Handler, FileName, FilePathMapping, SourceMa...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/benches/typescript.rs
crates/swc/benches/typescript.rs
extern crate swc_malloc; use std::{ io::{self, stderr}, sync::Arc, }; use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion}; use swc::config::{Config, IsModule, JscConfig, Options}; use swc_common::{ errors::Handler, FileName, FilePathMapping, Mark, SourceFile, So...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/benches/bugs.rs
crates/swc/benches/bugs.rs
extern crate swc_malloc; use std::{io::stderr, path::Path}; use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion}; use swc_common::{errors::Handler, sync::Lrc, FilePathMapping, SourceMap}; use swc_ecma_utils::swc_common::GLOBALS; fn mk() -> swc::Compiler { let cm = Lrc::...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/benches/minify.rs
crates/swc/benches/minify.rs
/// Explicit extern crate to use allocator. extern crate swc_malloc; use std::{path::PathBuf, sync::Arc}; use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion}; use swc::{config::JsMinifyOptions, try_with_handler, BoolOrDataConfig}; use swc_common::{FilePathMapping, SourceMap...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/examples/transform_error.rs
crates/swc/examples/transform_error.rs
use std::sync::Arc; use anyhow::Context; use swc::try_with_handler; use swc_common::{errors::ColorConfig, FileName, SourceMap, GLOBALS}; fn main() { let cm = Arc::<SourceMap>::default(); let c = swc::Compiler::new(cm.clone()); let output = GLOBALS .set(&Default::default(), || { try_wi...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/examples/transform.rs
crates/swc/examples/transform.rs
use std::{path::Path, sync::Arc}; use anyhow::Context; use swc::try_with_handler; use swc_common::{SourceMap, GLOBALS}; fn main() { let cm = Arc::<SourceMap>::default(); let c = swc::Compiler::new(cm.clone()); let output = GLOBALS .set(&Default::default(), || { try_with_handler(cm.clo...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/examples/hygiene_visualizer.rs
crates/swc/examples/hygiene_visualizer.rs
use std::io::{stderr, Write}; use swc_common::{sync::Lrc, Mark, SourceMap, SyntaxContext, GLOBALS}; use swc_ecma_ast::{Ident, Program}; use swc_ecma_codegen::{text_writer::JsWriter, Emitter}; use swc_ecma_transforms_base::resolver; use swc_ecma_visit::{noop_fold_type, Fold, FoldWith, VisitMutWith}; fn print_hygiene(c...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc/examples/minify.rs
crates/swc/examples/minify.rs
use std::{path::Path, sync::Arc}; use anyhow::Context; use swc::{config::JsMinifyOptions, try_with_handler, BoolOrDataConfig, JsMinifyExtras}; use swc_common::{SourceMap, GLOBALS}; use swc_ecma_minifier::option::SimpleMangleCache; fn main() { let cm = Arc::<SourceMap>::default(); let c = swc::Compiler::new(c...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/shorthand_property.rs
crates/swc_ecma_compat_es2015/src/shorthand_property.rs
use swc_common::util::take::Take; use swc_ecma_ast::*; use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; use swc_trace_macro::swc_trace; /// Compile ES2015 shorthand properties to ES5 /// ///# Example /// ///## In /// /// ```js /// var o = ...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/typeof_symbol.rs
crates/swc_ecma_compat_es2015/src/typeof_symbol.rs
use serde::Deserialize; use swc_common::{util::take::Take, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_transforms_base::{helper, perf::Parallel}; use swc_ecma_utils::{quote_str, ExprFactory}; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; use swc_trace_macro::swc_trace; pub fn type...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/parameters.rs
crates/swc_ecma_compat_es2015/src/parameters.rs
use std::mem; use arrayvec::ArrayVec; use serde::Deserialize; use swc_atoms::atom; use swc_common::{util::take::Take, Mark, Spanned, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; // use swc_ecma_transforms_base::perf::Parallel; // use swc_ecma_transforms_macros::parallel; use swc_ecma_utils::{ function::{init_thi...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/lib.rs
crates/swc_ecma_compat_es2015/src/lib.rs
#![allow(clippy::vec_box)] #![allow(clippy::boxed_local)] use serde::Deserialize; use swc_common::{comments::Comments, Mark}; use swc_ecma_ast::Pass; use swc_ecma_compat_common::regexp::{self, regexp}; pub use self::{ arrow::arrow, block_scoped_fn::block_scoped_functions, block_scoping::block_scoping, classes...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/arrow.rs
crates/swc_ecma_compat_es2015/src/arrow.rs
use std::mem; use swc_common::{util::take::Take, Mark, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_utils::{ function::{init_this, FnEnvHoister}, prepend_stmt, }; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, InjectVars, VisitMut, VisitMutWith}; use swc_trace_macro::swc_trace; /// C...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/function_name.rs
crates/swc_ecma_compat_es2015/src/function_name.rs
use swc_common::{util::take::Take, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_utils::{private_ident, IdentUsageFinder}; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; use swc_trace_macro::swc_trace; /// `@babel/plugin-transform-functio...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/instanceof.rs
crates/swc_ecma_compat_es2015/src/instanceof.rs
use swc_common::{util::take::Take, Span, Spanned}; use swc_ecma_ast::*; use swc_ecma_transforms_base::{helper, perf::Parallel}; use swc_ecma_utils::ExprFactory; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; use swc_trace_macro::swc_trace; /// `@babel/plugin-transform-instanceof` //...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/destructuring.rs
crates/swc_ecma_compat_es2015/src/destructuring.rs
use std::{iter, mem}; use serde::Deserialize; use swc_common::{util::take::Take, Span, Spanned, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_compat_common::impl_visit_mut_fn; use swc_ecma_transforms_base::{helper, helper_expr, perf::Check}; use swc_ecma_transforms_macros::fast_path; use swc_ecma_utils::...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
true
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/block_scoped_fn.rs
crates/swc_ecma_compat_es2015/src/block_scoped_fn.rs
use swc_common::{util::take::Take, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_utils::IdentUsageFinder; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; use swc_trace_macro::swc_trace; pub fn block_scoped_functions() -> impl Pass { visit_mut_pass(BlockScopedFns) } #[derive(Clone...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/generator.rs
crates/swc_ecma_compat_es2015/src/generator.rs
use std::{ cell::{RefCell, RefMut}, iter::once, mem::take, rc::Rc, }; use is_macro::Is; use swc_atoms::Atom; use swc_common::{ comments::Comments, util::take::Take, BytePos, EqIgnoreSpan, Mark, Span, Spanned, SyntaxContext, DUMMY_SP, }; use swc_ecma_ast::*; use swc_ecma_transforms_base::helper;...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
true
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/spread.rs
crates/swc_ecma_compat_es2015/src/spread.rs
use std::mem; use serde::Deserialize; use swc_atoms::atom; use swc_common::{util::take::Take, Mark, Span, Spanned, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_transforms_base::{ext::ExprRefExt, helper, perf::Check}; use swc_ecma_transforms_macros::fast_path; use swc_ecma_utils::{ alias_ident_for, m...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/new_target.rs
crates/swc_ecma_compat_es2015/src/new_target.rs
use std::{borrow::Cow, mem}; use swc_common::{pass::CompilerPass, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_transforms_base::perf::{should_work, Check}; use swc_ecma_utils::{private_ident, quote_ident, ExprFactory}; use swc_ecma_visit::{ noop_visit_mut_type, noop_visit_type, visit_mut_pass, Visit, VisitMut, Vis...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/sticky_regex.rs
crates/swc_ecma_compat_es2015/src/sticky_regex.rs
use swc_ecma_ast::*; use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_utils::{quote_ident, ExprFactory}; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; use swc_trace_macro::swc_trace; /// Compile ES2015 sticky regex to an ES5 RegExp constructor /// ///# Example ///## In //...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/duplicate_keys.rs
crates/swc_ecma_compat_es2015/src/duplicate_keys.rs
use rustc_hash::FxHashSet; use swc_atoms::{Atom, Wtf8Atom}; use swc_common::Spanned; use swc_ecma_ast::*; use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_utils::quote_str; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; use swc_trace_macro::swc_trace; pub fn duplicate_keys...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/template_literal.rs
crates/swc_ecma_compat_es2015/src/template_literal.rs
use std::{iter, mem}; use serde_derive::Deserialize; use swc_atoms::{atom, wtf8::Wtf8Buf}; use swc_common::{util::take::Take, BytePos, Spanned, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_transforms_base::{helper, perf::Parallel}; use swc_ecma_utils::{is_literal, prepend_stmts, private_ident, quote_ident, ExprFactory...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false
swc-project/swc
https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_compat_es2015/src/computed_props.rs
crates/swc_ecma_compat_es2015/src/computed_props.rs
use serde::Deserialize; use swc_common::{Mark, Spanned, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_transforms_base::helper; use swc_ecma_utils::{quote_ident, ExprFactory, StmtLike}; use swc_ecma_visit::{ noop_visit_mut_type, noop_visit_type, visit_mut_pass, Visit, VisitMut, VisitMutWith, VisitWith,...
rust
Apache-2.0
1faa4a57454ef3932c75a1aca7dd36e37bb215d3
2026-01-04T15:32:21.773776Z
false