Skip to content

Commit

Permalink
0.18.0 (#942)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Oct 19, 2021
1 parent 249c542 commit 2bf0321
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 63 deletions.
58 changes: 33 additions & 25 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deno_lint"
version = "0.17.0"
version = "0.18.0"
edition = "2018"
description = "lint for deno"
authors = ["the Deno authors"]
Expand All @@ -21,7 +21,7 @@ default = []
docs = []

[dependencies]
deno_ast = { version = "0.3.0", features = ["transforms", "utils", "visit", "view"] }
deno_ast = { version = "0.4.0", features = ["transforms", "utils", "visit", "view"] }
log = "0.4.14"
serde = { version = "1.0.125", features = ["derive"] }
serde_json = "1.0.64"
Expand Down
36 changes: 2 additions & 34 deletions src/ast_parser.rs
Original file line number Diff line number Diff line change
@@ -1,45 +1,14 @@
// Copyright 2020-2021 the Deno authors. All rights reserved. MIT license.
use deno_ast::swc::parser::Syntax;
use deno_ast::Diagnostic;
use deno_ast::MediaType;
use deno_ast::ParsedSource;
use std::error::Error;
use std::fmt;

#[derive(Clone, Debug)]
pub struct SwcDiagnostic {
pub filename: String,
pub line_display: usize,
pub column_display: usize,
pub message: String,
}

impl Error for SwcDiagnostic {}

impl fmt::Display for SwcDiagnostic {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&format!(
"{} at {}:{}:{}",
self.message, self.filename, self.line_display, self.column_display
))
}
}

impl SwcDiagnostic {
pub(crate) fn from_diagnostic(diagnostic: &deno_ast::Diagnostic) -> Self {
SwcDiagnostic {
line_display: diagnostic.display_position.line_number,
column_display: diagnostic.display_position.column_number,
filename: diagnostic.specifier.clone(),
message: diagnostic.message.clone(),
}
}
}

pub(crate) fn parse_program(
file_name: &str,
syntax: Syntax,
source_code: String,
) -> Result<ParsedSource, SwcDiagnostic> {
) -> Result<ParsedSource, Diagnostic> {
deno_ast::parse_program(deno_ast::ParseParams {
specifier: file_name.to_string(),
media_type: MediaType::Unknown,
Expand All @@ -48,5 +17,4 @@ pub(crate) fn parse_program(
maybe_syntax: Some(syntax),
scope_analysis: true,
})
.map_err(|diagnostic| SwcDiagnostic::from_diagnostic(&diagnostic))
}
4 changes: 2 additions & 2 deletions src/linter.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2020-2021 the Deno authors. All rights reserved. MIT license.
use crate::ast_parser::parse_program;
use crate::ast_parser::SwcDiagnostic;
use crate::context::Context;
use crate::control_flow::ControlFlow;
use crate::diagnostic::LintDiagnostic;
Expand All @@ -10,6 +9,7 @@ use crate::ignore_directives::{
use crate::rules::LintRule;
use crate::scopes::Scope;
use deno_ast::view::ProgramRef;
use deno_ast::Diagnostic;
use deno_ast::MediaType;
use deno_ast::ParsedSource;
use std::sync::Arc;
Expand Down Expand Up @@ -116,7 +116,7 @@ impl Linter {
mut self,
file_name: String,
source_code: String,
) -> Result<(ParsedSource, Vec<LintDiagnostic>), SwcDiagnostic> {
) -> Result<(ParsedSource, Vec<LintDiagnostic>), Diagnostic> {
let start = Instant::now();

let syntax = deno_ast::get_syntax(self.media_type);
Expand Down

0 comments on commit 2bf0321

Please sign in to comment.