Skip to content

Commit

Permalink
chore: remove tests and address clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Oct 16, 2023
1 parent cd7fbd4 commit 1638fd0
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 223 deletions.
43 changes: 0 additions & 43 deletions crates/biome_cli/tests/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2491,49 +2491,6 @@ array.map((sentence) => sentence.split(" ")).flat();
));
}

#[test]
fn should_not_enable_nursery_rules() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let configuration = r#" {
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"nursery": {
"noAccumulatingSpread": "error"
}
}
}
}"#;

let configuration_path = Path::new("biome.json");
fs.insert(configuration_path.into(), configuration.as_bytes());

let file_path = Path::new("fix.ts");
fs.insert(file_path.into(), r#"let confusingVoidType: void;"#);

let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()),
);

assert!(result.is_err(), "run_cli returned {result:?}");

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"should_not_enable_nursery_rules",
fs,
console,
result,
));
}

#[test]
fn apply_bogus_argument() {
let mut fs = MemoryFileSystem::default();
Expand Down
43 changes: 0 additions & 43 deletions crates/biome_cli/tests/commands/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2101,49 +2101,6 @@ array.map((sentence) => sentence.split(" ")).flat();
));
}

#[test]
fn should_not_enable_nursery_rules() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let configuration = r#" {
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"nursery": {
"noAccumulatingSpread": "error"
}
}
}
}"#;

let configuration_path = Path::new("biome.json");
fs.insert(configuration_path.into(), configuration.as_bytes());

let file_path = Path::new("fix.ts");
fs.insert(file_path.into(), r#"let confusingVoidType: void;"#);

let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()),
);

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"should_not_enable_nursery_rules",
fs,
console,
result,
));
}

#[test]
fn apply_bogus_argument() {
let mut fs = MemoryFileSystem::default();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ biome.json:6:13 deserialize ━━━━━━━━━━━━━━━━━
- noUnusedVariables
- noVoidElementsWithChildren
- noVoidTypeReturn
- useExhaustiveDependencies
- useHookAtTopLevel
- useIsNan
- useValidForDirection
- useYield
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,38 @@
source: crates/biome_service/tests/spec_tests.rs
expression: hooks_incorrect_options.json
---
hooks_incorrect_options.json:9:7 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
hooks_incorrect_options.json:6:5 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Found an unknown key `hooksTYPO`.
× Found an unknown key `useExhaustiveDependencies`.

7 "level": "error",
8 "options": {
> 9 "hooksTYPO": {}
^^^^^^^^^^^
10}
11}
4 "rules": {
5 "nursery": {
> 6"useExhaustiveDependencies": {
^^^^^^^^^^^^^^^^^^^^^^^^^^^
7"level": "error",
8 "options": {

i Accepted keys

- hooks
- recommended
- all
- noApproximativeNumericConstant
- noDuplicateJsonKeys
- noEmptyCharacterClassInRegex
- noGlobalIsFinite
- noInteractiveElementToNoninteractiveRole
- noInvalidNewBuiltin
- noMisleadingInstantiator
- noMisrefactoredShorthandAssign
- noUnusedImports
- noUselessElse
- noUselessLoneBlockStatements
- useAriaActivedescendantWithTabindex
- useArrowFunction
- useAsConstAssertion
- useGroupedTypeImport
- useImportRestrictions
- useShorthandAssign



42 changes: 30 additions & 12 deletions crates/biome_service/tests/invalid/hooks_missing_name.json.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,38 @@
source: crates/biome_service/tests/spec_tests.rs
expression: hooks_missing_name.json
---
hooks_missing_name.json:10:8 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
hooks_missing_name.json:6:5 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× The field name is mandatory
× Found an unknown key `useExhaustiveDependencies`.

8"options": {
9"hooks": [
> 10 │ {
│ ^
> 11 │ "closureIndex": 0,
> 12 │ "dependenciesIndex": 1
> 13 │ }
^
14 │ ]
15 │ }
4"rules": {
5"nursery": {
> 6"useExhaustiveDependencies": {
^^^^^^^^^^^^^^^^^^^^^^^^^^^
7"level": "error",
8"options": {

i Accepted keys

- recommended
- all
- noApproximativeNumericConstant
- noDuplicateJsonKeys
- noEmptyCharacterClassInRegex
- noGlobalIsFinite
- noInteractiveElementToNoninteractiveRole
- noInvalidNewBuiltin
- noMisleadingInstantiator
- noMisrefactoredShorthandAssign
- noUnusedImports
- noUselessElse
- noUselessLoneBlockStatements
- useAriaActivedescendantWithTabindex
- useArrowFunction
- useAsConstAssertion
- useGroupedTypeImport
- useImportRestrictions
- useShorthandAssign



12 changes: 7 additions & 5 deletions xtask/codegen/src/promote_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ pub fn promote_rule(rule_name: &str, new_group: &str) {
new_rule_path.clone(),
&file::CopyOptions::default(),
)
.expect(&format!(
"To copy {} to {}",
rule_path.display(),
new_rule_path.display()
));
.unwrap_or_else(|_| {
panic!(
"To copy {} to {}",
rule_path.display(),
new_rule_path.display()
)
});
std::fs::write(categories_path, categories).unwrap();

let old_test_path = current_dir
Expand Down
12 changes: 4 additions & 8 deletions xtask/lintdoc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,10 +722,8 @@ fn assert_lint(
}
}

if test.expect_diagnostic {
if rule_has_code_action && !has_fix_kind {
bail!("The rule '{}' emitted code actions via `action` function, but you didn't mark rule with `fix_kind`.", rule)
}
if test.expect_diagnostic && rule_has_code_action && !has_fix_kind {
bail!("The rule '{}' emitted code actions via `action` function, but you didn't mark rule with `fix_kind`.", rule)
}

if test.expect_diagnostic {
Expand Down Expand Up @@ -798,10 +796,8 @@ fn assert_lint(
write_diagnostic(code, diagnostic)?;
}

if test.expect_diagnostic {
if rule_has_code_action && !has_fix_kind {
bail!("The rule '{}' emitted code actions via `action` function, but you didn't mark rule with `fix_kind`.", rule)
}
if test.expect_diagnostic && rule_has_code_action && !has_fix_kind {
bail!("The rule '{}' emitted code actions via `action` function, but you didn't mark rule with `fix_kind`.", rule)
}
}
}
Expand Down

0 comments on commit 1638fd0

Please sign in to comment.