Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
lint doc and removing dbg
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Aug 2, 2022
1 parent 799d137 commit c07b191
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ declare_rule! {
/// ```
///
/// ```js,expect_diagnostic
/// function foo(myVar) {
/// console.log('foo');
/// function foo() {
/// };
/// ```
///
Expand All @@ -40,8 +39,7 @@ declare_rule! {
/// ```
///
/// ```js,expect_diagnostic
/// const foo = (b) => {
/// console.log('foo');
/// const foo = () => {
/// };
/// ```
///
Expand All @@ -61,7 +59,7 @@ declare_rule! {
/// # Valid
///
/// ```js
/// function foo(, b) {
/// function foo(b) {
/// console.log(b)
/// };
/// foo();
Expand Down
4 changes: 2 additions & 2 deletions crates/rome_js_analyze/src/utils/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ impl JsBatchMutation for BatchMutation<JsLanguage, JsAnyRoot> {

// if it is the last parameter of the list
// removes the comma before this element
if dbg!(elements.next().is_none()) {
if let Some(element) = dbg!(previous_element) {
if elements.next().is_none() {
if let Some(element) = previous_element {
if let Some(comma) = element.trailing_separator().ok().flatten() {
self.remove_token(comma.clone());
}
Expand Down
8 changes: 8 additions & 0 deletions website/src/docs/lint/rules/index.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

177 changes: 177 additions & 0 deletions website/src/docs/lint/rules/noUnusedVariables.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions xtask/lintdoc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ fn assert_lint(
let mut write = HTML(content);
let mut diagnostic_count = 0;

let mut write_diagnostic = |diag: Diagnostic| {
let mut write_diagnostic = |code: &str, diag: Diagnostic| {
// Fail the test if the analysis returns more diagnostics than expected
if test.expect_diagnostic {
ensure!(
Expand All @@ -400,8 +400,9 @@ fn assert_lint(
);
} else {
bail!(format!(
"analysis returned an unexpected diagnostic, code snippet:\n\n{:?}",
diag.code.unwrap_or_default()
"analysis returned an unexpected diagnostic, code snippet:\n\n{:?}\n\n{}",
diag.code.unwrap_or_default(),
code
));
}

Expand All @@ -417,7 +418,7 @@ fn assert_lint(

if parse.has_errors() {
for diag in parse.into_diagnostics() {
write_diagnostic(diag)?;
write_diagnostic(code, diag)?;
}
} else {
let root = parse.tree();
Expand All @@ -434,7 +435,7 @@ fn assert_lint(
diag.suggestions.push(action.into());
}

let res = write_diagnostic(diag);
let res = write_diagnostic(code, diag);

// Abort the analysis on error
if let Err(err) = res {
Expand Down

0 comments on commit c07b191

Please sign in to comment.