mirror of
https://github.com/danbulant/oxc
synced 2026-05-22 05:38:54 +00:00
chore: fix some nightly clippy warnings
This commit is contained in:
parent
051ceb6539
commit
4e9d8a5585
8 changed files with 10 additions and 14 deletions
|
|
@ -22,7 +22,7 @@ non_ascii_idents = "warn"
|
|||
unit-bindings = "warn"
|
||||
|
||||
[workspace.lints.clippy]
|
||||
all = { level = "warn" }
|
||||
all = { level = "warn", priority = -1 }
|
||||
empty_docs = { level = "allow", priority = 1 } # from `Tsify`
|
||||
# restriction
|
||||
dbg_macro = "warn"
|
||||
|
|
|
|||
|
|
@ -80,8 +80,7 @@ fn format_raw(raw: &str) -> Option<(String, bool)> {
|
|||
let dot_and_fractions = after_parts.next()?;
|
||||
let after = after_parts.next().unwrap_or("");
|
||||
|
||||
let fixed_dot_and_fractions =
|
||||
dot_and_fractions.trim_end_matches(|c: char| c == '0' || c == '.' || c == '_');
|
||||
let fixed_dot_and_fractions = dot_and_fractions.trim_end_matches(['0', '.', '_']);
|
||||
let formatted = format!(
|
||||
"{}{}{}{}",
|
||||
if before.is_empty() && fixed_dot_and_fractions.is_empty() { "0" } else { before },
|
||||
|
|
|
|||
|
|
@ -1334,8 +1334,7 @@ impl<'a> Format<'a> for NumericLiteral<'a> {
|
|||
// Remove unnecessary plus and zeroes from scientific notation.
|
||||
if let Some((head, tail)) = string.split_once('e') {
|
||||
let negative = if tail.starts_with('-') { "-" } else { "" };
|
||||
let trimmed =
|
||||
tail.trim_start_matches(|c| c == '+' || c == '-').trim_start_matches('0');
|
||||
let trimmed = tail.trim_start_matches(['+', '-']).trim_start_matches('0');
|
||||
if trimmed.starts_with(|c: char| c.is_ascii_digit()) {
|
||||
string = Cow::Owned(std::format!("{head}e{negative}{trimmed}"));
|
||||
}
|
||||
|
|
@ -1343,11 +1342,7 @@ impl<'a> Format<'a> for NumericLiteral<'a> {
|
|||
|
||||
// Remove unnecessary scientific notation (1e0).
|
||||
if let Some((head, tail)) = string.split_once('e') {
|
||||
if tail
|
||||
.trim_start_matches(|c| c == '+' || c == '-')
|
||||
.trim_start_matches('0')
|
||||
.is_empty()
|
||||
{
|
||||
if tail.trim_start_matches(['+', '-']).trim_start_matches('0').is_empty() {
|
||||
string = Cow::Owned(head.to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,8 +47,10 @@ pub struct PrettierOptions {
|
|||
pub trailing_comma: TrailingComma,
|
||||
|
||||
/// Print spaces between brackets in object literals.
|
||||
///
|
||||
/// * true - Example: `{ foo: bar }`.
|
||||
/// * false - Example: `{foo: bar}`.
|
||||
///
|
||||
/// Default: true
|
||||
pub bracket_spacing: bool,
|
||||
|
||||
|
|
|
|||
|
|
@ -63,8 +63,7 @@ impl<'a> JSDocCommentPart<'a> {
|
|||
|
||||
let start_trimmed = self.raw.trim_start();
|
||||
let trimmed_start_offset = base_len - start_trimmed.len();
|
||||
let trimmed_end_offset =
|
||||
trimmed_start_offset + start_trimmed.find(|c| c == '\n').unwrap_or(0);
|
||||
let trimmed_end_offset = trimmed_start_offset + start_trimmed.find('\n').unwrap_or(0);
|
||||
Span::new(
|
||||
self.span.start + u32::try_from(trimmed_start_offset).unwrap_or_default(),
|
||||
self.span.start + u32::try_from(trimmed_end_offset).unwrap_or_default(),
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
use std::cell::Cell;
|
||||
|
||||
use memoffset::offset_of;
|
||||
|
||||
use oxc_allocator::{Box, Vec};
|
||||
#[allow(clippy::wildcard_imports)]
|
||||
use oxc_ast::ast::*;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ pub trait Suite<T: Case> {
|
|||
|
||||
let path = path.strip_prefix(test_root).unwrap().to_owned();
|
||||
// remove the Byte Order Mark in some of the TypeScript files
|
||||
let code = code.trim_start_matches(|c| c == '\u{feff}').to_string();
|
||||
let code = code.trim_start_matches('\u{feff}').to_string();
|
||||
T::new(path, code)
|
||||
})
|
||||
.filter(|case| !case.skip_test_case())
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ impl ExecTestCase {
|
|||
fn write_to_test_files(&self, content: &str) -> PathBuf {
|
||||
let allocator = Allocator::default();
|
||||
let new_file_name: String =
|
||||
normalize_path(self.path.strip_prefix(&packages_root()).unwrap())
|
||||
normalize_path(self.path.strip_prefix(packages_root()).unwrap())
|
||||
.split('/')
|
||||
.collect::<Vec<&str>>()
|
||||
.join("-");
|
||||
|
|
|
|||
Loading…
Reference in a new issue