mirror of
https://github.com/swc-project/swc.git
synced 2024-12-28 08:04:43 +03:00
chore(repo): Fix lints (#4519)
This commit is contained in:
parent
1d105ae76b
commit
33f58faa0b
@ -1,3 +1,4 @@
|
|||||||
|
#![deny(warnings)]
|
||||||
#![allow(clippy::needless_update)]
|
#![allow(clippy::needless_update)]
|
||||||
|
|
||||||
use std::{fs, mem::take, path::PathBuf};
|
use std::{fs, mem::take, path::PathBuf};
|
||||||
@ -260,14 +261,10 @@ fn unescape(s: &str) -> Option<String> {
|
|||||||
fn html5lib_test_tokenizer(input: PathBuf) {
|
fn html5lib_test_tokenizer(input: PathBuf) {
|
||||||
let filename = input.to_str().expect("failed to parse path");
|
let filename = input.to_str().expect("failed to parse path");
|
||||||
let contents = fs::read_to_string(filename).expect("Something went wrong reading the file");
|
let contents = fs::read_to_string(filename).expect("Something went wrong reading the file");
|
||||||
let obj: Value = serde_json::from_str(&contents)
|
let obj: Value = serde_json::from_str(&contents).expect("json parse error");
|
||||||
.ok()
|
|
||||||
.expect("json parse error");
|
|
||||||
let tests = match obj.get(&"tests".to_string()) {
|
let tests = match obj.get(&"tests".to_string()) {
|
||||||
Some(&Value::Array(ref tests)) => tests,
|
Some(&Value::Array(ref tests)) => tests,
|
||||||
_ => {
|
_ => return,
|
||||||
return ();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for test in tests.iter() {
|
for test in tests.iter() {
|
||||||
@ -447,7 +444,7 @@ fn html5lib_test_tokenizer(input: PathBuf) {
|
|||||||
|
|
||||||
let mut expected_tokens: Vec<Token> = vec![];
|
let mut expected_tokens: Vec<Token> = vec![];
|
||||||
|
|
||||||
for output_tokens in json_output.as_array() {
|
if let Some(output_tokens) = json_output.as_array() {
|
||||||
for output_token in output_tokens {
|
for output_token in output_tokens {
|
||||||
match output_token {
|
match output_token {
|
||||||
Value::Array(token_parts) => {
|
Value::Array(token_parts) => {
|
||||||
@ -485,7 +482,7 @@ fn html5lib_test_tokenizer(input: PathBuf) {
|
|||||||
.expect("failed to deserialize");
|
.expect("failed to deserialize");
|
||||||
let mut attributes = vec![];
|
let mut attributes = vec![];
|
||||||
|
|
||||||
if let Some(json_attributes) = token_parts.get(2).clone() {
|
if let Some(json_attributes) = token_parts.get(2) {
|
||||||
let obj_attributes: Value =
|
let obj_attributes: Value =
|
||||||
serde_json::from_value(json_attributes.clone())
|
serde_json::from_value(json_attributes.clone())
|
||||||
.expect("failed to deserialize");
|
.expect("failed to deserialize");
|
||||||
@ -516,7 +513,7 @@ fn html5lib_test_tokenizer(input: PathBuf) {
|
|||||||
|
|
||||||
let mut self_closing = false;
|
let mut self_closing = false;
|
||||||
|
|
||||||
if let Some(json_self_closing) = token_parts.get(3).clone() {
|
if let Some(json_self_closing) = token_parts.get(3) {
|
||||||
let value: bool =
|
let value: bool =
|
||||||
serde_json::from_value(json_self_closing.clone())
|
serde_json::from_value(json_self_closing.clone())
|
||||||
.expect("failed to deserialize");
|
.expect("failed to deserialize");
|
||||||
@ -741,14 +738,9 @@ fn html5lib_test_tokenizer(input: PathBuf) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO validate error positions
|
// TODO validate error positions
|
||||||
assert_eq!(
|
assert!(actual_errors
|
||||||
!actual_errors
|
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|&error| *error.kind() == expected_code)
|
.any(|error| *error.kind() == expected_code));
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.is_empty(),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let errors = lexer.take_errors();
|
let errors = lexer.take_errors();
|
||||||
|
Loading…
Reference in New Issue
Block a user