Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ iter_on_single_items = "warn"
unused_peekable = "warn"
too_long_first_doc_paragraph = "warn"
suspicious_operation_groupings = "warn"
redundant_clone = "warn"
# cargo
cargo = { level = "warn", priority = -1 }
multiple_crate_versions = "allow"
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/src/output_formatter/junit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ mod test {
reporter.render_error(warning);

let output = reporter.finish(&DiagnosticResult::default()).unwrap();
assert_eq!(output.to_string(), EXPECTED_REPORT);
assert_eq!(output, EXPECTED_REPORT);
}
}
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/config/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl JsonSchema for OxlintCategories {
properties.insert(RuleCategory::Perf.as_str().to_string(), severity.clone());
properties.insert(RuleCategory::Style.as_str().to_string(), severity.clone());
properties.insert(RuleCategory::Restriction.as_str().to_string(), severity.clone());
properties.insert(RuleCategory::Nursery.as_str().to_string(), severity.clone());
properties.insert(RuleCategory::Nursery.as_str().to_string(), severity);
}

{
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_linter/src/rules/eslint/func_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ fn test() {
("class C { public foo = function() {} }", always.clone()), // { "ecmaVersion": 2022 },
("class C { [foo] = function() {} }", always.clone()), // { "ecmaVersion": 2022 },
("class C { #foo = function() {} }", always.clone()), // { "ecmaVersion": 2022 },
("class C { foo = bar(function() {}) }", as_needed.clone()), // { "ecmaVersion": 2022 },
("class C { foo = bar(function() {}) }", as_needed), // { "ecmaVersion": 2022 },
("class C { foo = function bar() {} }", never.clone()), // { "ecmaVersion": 2022 }
];

Expand Down Expand Up @@ -751,7 +751,7 @@ fn test() {
"Foo.prototype.bar = function () {}",
never.clone(),
),
("class C { foo = function foo() {} }", "class C { foo = function () {} }", never.clone()),
("class C { foo = function foo() {} }", "class C { foo = function () {} }", never),
(
"const restoreGracefully = function <T>(entries: T[]) { }",
"const restoreGracefully = function restoreGracefully<T>(entries: T[]) { }",
Expand Down Expand Up @@ -794,7 +794,7 @@ fn test() {
Component.prototype.setState = function (update, callback) {
return setState.call(this, update, callback);
};",
always.clone(),
always,
),
];

Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_fallthrough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,13 @@ impl NoFallthrough {

if let Some(end) = end {
let range = start..end;
if is_fallthrough_comment_in_range(range.clone()) {
if is_fallthrough_comment_in_range(range) {
return Some(Span::new(start, end));
}
}

let range = start..fall.span.start;
if is_fallthrough_comment_in_range(range.clone()) {
if is_fallthrough_comment_in_range(range) {
Some(Span::new(start, fall.span.start))
} else {
None
Expand Down
14 changes: 7 additions & 7 deletions crates/oxc_linter/src/rules/eslint/no_magic_numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ fn test() {
("const func = (param = 123) => {}", ignore_default_values.clone()), // { "ecmaVersion": 6 },
("const func = ({ param = 123 }) => {}", ignore_default_values.clone()), // { "ecmaVersion": 6 },
("const [one = 1, two = 2] = []", ignore_default_values.clone()), // { "ecmaVersion": 6 },
("var one, two; [one = 1, two = 2] = []", ignore_default_values.clone()), // { "ecmaVersion": 6 },
("var one, two; [one = 1, two = 2] = []", ignore_default_values), // { "ecmaVersion": 6 },
("var x = parseInt?.(y, 10);", None), // { "ecmaVersion": 2020 },
("var x = Number?.parseInt(y, 10);", None), // { "ecmaVersion": 2020 },
("var x = (Number?.parseInt)(y, 10);", None), // { "ecmaVersion": 2020 },
Expand All @@ -588,7 +588,7 @@ fn test() {
("type Foo = 1;", ignore_numeric_literal_types.clone()),
("type Foo = -1;", ignore_numeric_literal_types.clone()),
("type Foo = 1 | 2 | 3;", ignore_numeric_literal_types.clone()),
("type Foo = 1 | -1;", ignore_numeric_literal_types.clone()),
("type Foo = 1 | -1;", ignore_numeric_literal_types),
(
"
enum foo {
Expand Down Expand Up @@ -624,7 +624,7 @@ fn test() {
("type Foo = Bar[1 & number];", ignore_typed_index_arrays.clone()),
("type Foo = Bar[((1 & -2) | 3) | 4];", ignore_typed_index_arrays.clone()),
("type Foo = Parameters<Bar>[2];", ignore_typed_index_arrays.clone()),
("type Foo = Bar['baz'];", ignore_typed_index_arrays.clone()),
("type Foo = Bar['baz'];", ignore_typed_index_arrays),
("type Foo = Bar['baz'];", Some(serde_json::json!([{ "ignoreTypeIndexes": false }]))),
(
"
Expand Down Expand Up @@ -709,8 +709,8 @@ fn test() {
let fail = vec![
("var foo = 42", enforce_const.clone()), // { "ecmaVersion": 6 },
("var foo = 0 + 1;", None),
("var foo = 42n", enforce_const.clone()), // { "ecmaVersion": 2020 },
("var foo = 0n + 1n;", None), // { "ecmaVersion": 2020 },
("var foo = 42n", enforce_const), // { "ecmaVersion": 2020 },
("var foo = 0n + 1n;", None), // { "ecmaVersion": 2020 },
("a = a + 5;", None),
("a += 5;", None),
("var foo = 0 + 1 + -2 + 2;", None),
Expand Down Expand Up @@ -766,7 +766,7 @@ fn test() {
// ("foo[+1n]", ignore_array_indexes.clone()), // { "ecmaVersion": 2020 },
// ("foo[- -1n]", ignore_array_indexes.clone()), // { "ecmaVersion": 2020 },
("100 .toString()", ignore_array_indexes.clone()),
("200[100]", ignore_array_indexes.clone()),
("200[100]", ignore_array_indexes),
("var a = <div arrayProp={[1,2,3]}></div>;", None), // { "parserOptions": { "ecmaFeatures": { "jsx": true } } },
("var min, max, mean; min = 1; max = 10; mean = 4;", Some(serde_json::json!([{}]))),
("f(100n)", Some(serde_json::json!([{ "ignore": [100] }]))), // { "ecmaVersion": 2020 },
Expand Down Expand Up @@ -815,7 +815,7 @@ fn test() {
), // { "ecmaVersion": 2022 },
("class C { foo = 2 + 3; }", ignore_class_field_initial_values.clone()), // { "ecmaVersion": 2022 },
("class C { 2; }", ignore_class_field_initial_values.clone()), // { "ecmaVersion": 2022 },
("class C { [2]; }", ignore_class_field_initial_values.clone()), // { "ecmaVersion": 2022 }
("class C { [2]; }", ignore_class_field_initial_values), // { "ecmaVersion": 2022 }
("type Foo = 1;", Some(serde_json::json!([{ "ignoreNumericLiteralTypes": false }]))),
("type Foo = -1;", Some(serde_json::json!([{ "ignoreNumericLiteralTypes": false }]))),
(
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_linter/src/rules/eslint/no_restricted_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,11 +1012,11 @@ fn test() {
),
(
r#"import { AllowedObject } from "foo";"#,
Some(serde_json::json!(pass_disallowed_object_foo.clone())),
Some(serde_json::json!(pass_disallowed_object_foo)),
),
(
r#"import { 'AllowedObject' as bar } from "foo";"#,
Some(serde_json::json!(pass_disallowed_object_foo.clone())),
Some(serde_json::json!(pass_disallowed_object_foo)),
),
(
r#"import { ' ' as bar } from "foo";"#,
Expand Down Expand Up @@ -1058,7 +1058,7 @@ fn test() {
),
(
r#"import AllowedObject, { AllowedObjectTwo as DisallowedObject } from "foo";"#,
Some(pass_disallowed_object_foo.clone()),
Some(pass_disallowed_object_foo),
),
(
r#"import AllowedObject, { AllowedObjectTwo as DisallowedObject } from "foo";"#,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn shadowed() {
.unwrap();
test_same("(function (undefined) { let x = typeof undefined })()", config.clone());
test_same("(function (NaN) { let x = typeof NaN })()", config.clone());
test_same("(function (process) { let x = process.env.NODE_ENV })()", config.clone());
test_same("(function (process) { let x = process.env.NODE_ENV })()", config);
}

#[test]
Expand All @@ -57,7 +57,7 @@ fn dot() {
test("process", "process", config.clone());

// computed member expression
test("process['env'].NODE_ENV", "production", config.clone());
test("process['env'].NODE_ENV", "production", config);
}

#[test]
Expand All @@ -73,7 +73,7 @@ fn dot_with_overlap() {

test("import.meta.env = 0", "__foo__ = 0", config.clone());
test("import.meta.env.NODE_ENV = 0", "__foo__.NODE_ENV = 0", config.clone());
test("import.meta.env.FOO = 0", "import.meta.env.FOO = 0", config.clone());
test("import.meta.env.FOO = 0", "import.meta.env.FOO = 0", config);
}

#[test]
Expand All @@ -86,7 +86,7 @@ fn dot_define_is_member_expr_postfix() {
test(
"console.log(__OBJ__.process.env.SOMEVAR)",
"console.log({ 'process': { 'env': { 'SOMEVAR': 'foo' } } }.process.env.SOMEVAR);\n",
config.clone(),
config,
);
}

Expand Down Expand Up @@ -133,7 +133,7 @@ fn optional_chain() {

test_same("a[b][c]", config.clone());
test_same("a?.[b][c]", config.clone());
test_same("a[b]?.[c]", config.clone());
test_same("a[b]?.[c]", config);
}

#[test]
Expand All @@ -152,7 +152,7 @@ fn dot_define_with_destruct() {
test(
"const {[any]: alias} = process.env.NODE_ENV",
"const { [any]: alias } = {\n\t'a': 1,\n\tb: 2,\n\tc: true,\n\td: { a: b }\n};",
config.clone(),
config,
);

// should filterout unused key even rhs objectExpr has SpreadElement
Expand All @@ -165,7 +165,7 @@ fn dot_define_with_destruct() {
test(
"const {a} = process.env.NODE_ENV",
"const { a } = {\n\t'a': 1,\n\t...unknown\n};\n",
config.clone(),
config,
);
}

Expand Down Expand Up @@ -233,7 +233,7 @@ console.log(
)
",
"console.log([a = 0,b.c = 0,b['c'] = 0], [ident = 0,ident = 0,ident = 0], [dot.chain = 0,dot.chain = 0,dot.chain = 0\n]);",
config.clone(),
config,
);
}

Expand Down
8 changes: 4 additions & 4 deletions tasks/ast_tools/src/generators/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,18 @@ fn calculate_layout_for_primitive(primitive_def: &PrimitiveDef) -> Layout {
"u128" => {
panic!("Cannot calculate alignment for `u128`. It differs depending on Rust version.")
}
"usize" => usize_layout.clone(),
"usize" => usize_layout,
"i8" => Layout::from_type::<i8>(),
"i16" => Layout::from_type::<i16>(),
"i32" => Layout::from_type::<i32>(),
"i64" => Layout::from_type::<i64>(),
"i128" => {
panic!("Cannot calculate alignment for `i128`. It differs depending on Rust version.")
}
"isize" => usize_layout.clone(),
"isize" => usize_layout,
"f32" => Layout::from_type::<f32>(),
"f64" => Layout::from_type::<f64>(),
"&str" => str_layout.clone(),
"&str" => str_layout,
"Atom" => str_layout,
"NonZeroU8" => Layout::from_type_with_niche_for_zero::<num::NonZeroU8>(),
"NonZeroU16" => Layout::from_type_with_niche_for_zero::<num::NonZeroU16>(),
Expand All @@ -390,7 +390,7 @@ fn calculate_layout_for_primitive(primitive_def: &PrimitiveDef) -> Layout {
"NonZeroU128" => {
panic!("Cannot calculate alignment for `NonZeroU128`. It differs depending on Rust version.")
}
"NonZeroUsize" => non_zero_usize_layout.clone(),
"NonZeroUsize" => non_zero_usize_layout,
"NonZeroI8" => Layout::from_type_with_niche_for_zero::<num::NonZeroI8>(),
"NonZeroI16" => Layout::from_type_with_niche_for_zero::<num::NonZeroI16>(),
"NonZeroI32" => Layout::from_type_with_niche_for_zero::<num::NonZeroI32>(),
Expand Down
4 changes: 2 additions & 2 deletions tasks/coverage/src/misc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ impl<T: Case> MiscSuite<T> {

fn huge_binary_expression() -> T {
let code = String::from("a") + &"+ a".repeat(1000);
T::new(PathBuf::from("huge_binary_expression.js"), code.to_string())
T::new(PathBuf::from("huge_binary_expression.js"), code)
}

fn huge_nested_statements() -> T {
let take = 1000;
let code = "if (true) {".repeat(take) + &"}".repeat(take);
T::new(PathBuf::from("huge_nested_statements.js"), code.to_string())
T::new(PathBuf::from("huge_nested_statements.js"), code)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tasks/prettier_conformance/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ fn main() {
let filter = args.opt_value_from_str("--filter").unwrap();

TestRunner::new(TestRunnerOptions { filter: filter.clone(), language: TestLanguage::Js }).run();
TestRunner::new(TestRunnerOptions { filter: filter.clone(), language: TestLanguage::Ts }).run();
TestRunner::new(TestRunnerOptions { filter, language: TestLanguage::Ts }).run();
}
2 changes: 1 addition & 1 deletion tasks/rulegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fn format_tagged_template_expression(tag_expr: &TaggedTemplateExpression) -> Opt
if tag_expr.tag.is_specific_member_access("String", "raw") {
tag_expr.quasi.quasis.first().map(|quasi| format!("r#\"{}\"#", quasi.value.raw))
} else if tag_expr.tag.is_specific_id("dedent") || tag_expr.tag.is_specific_id("outdent") {
tag_expr.quasi.quasis.first().map(|quasi| util::dedent(&quasi.value.raw).to_string())
tag_expr.quasi.quasis.first().map(|quasi| util::dedent(&quasi.value.raw))
} else {
tag_expr.quasi.quasi().map(|quasi| quasi.to_string())
}
Expand Down
2 changes: 1 addition & 1 deletion tasks/transform_conformance/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ fn main() {
);
}

TestRunner::new(options.clone()).run();
TestRunner::new(options).run();
}
2 changes: 1 addition & 1 deletion tasks/transform_conformance/src/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl TestCase {
if !errors.is_empty() {
let source = NamedSource::new(
path.strip_prefix(project_root).unwrap().to_string_lossy(),
source_text.to_string(),
source_text,
);
return Err(errors
.into_iter()
Expand Down
Loading