diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2021-10-12 09:58:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-12 09:58:04 -0400 |
commit | 9b1f0c8ba3c8ca7a7207519889b6509bfc10370e (patch) | |
tree | 8660a11544f221e1a295c5e98c5907532523f351 /cli/tools | |
parent | b1e7452cd310ead7e6379f694d660e935641e596 (diff) |
chore: upgrade crates based on deno ast 0.3 (#12403)
Diffstat (limited to 'cli/tools')
-rw-r--r-- | cli/tools/lint.rs | 19 | ||||
-rw-r--r-- | cli/tools/repl.rs | 1 | ||||
-rw-r--r-- | cli/tools/test.rs | 1 |
3 files changed, 10 insertions, 11 deletions
diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs index a565fee1f..6948d2a1f 100644 --- a/cli/tools/lint.rs +++ b/cli/tools/lint.rs @@ -13,7 +13,6 @@ use crate::fmt_errors; use crate::fs_util::{collect_files, is_supported_ext}; use crate::tools::fmt::run_parallelized; use crate::{colors, file_watcher}; -use deno_ast::swc::parser::Syntax; use deno_ast::MediaType; use deno_core::error::{anyhow, generic_error, AnyError, JsStackFrame}; use deno_core::serde_json; @@ -231,27 +230,26 @@ pub fn print_rules_list(json: bool) { } pub fn create_linter( - syntax: Syntax, - rules: Arc<Vec<Box<dyn LintRule>>>, + media_type: MediaType, + rules: Vec<Arc<dyn LintRule>>, ) -> Linter { LinterBuilder::default() .ignore_file_directive("deno-lint-ignore-file") .ignore_diagnostic_directive("deno-lint-ignore") - .syntax(syntax) + .media_type(media_type) .rules(rules) .build() } fn lint_file( file_path: PathBuf, - lint_rules: Arc<Vec<Box<dyn LintRule>>>, + lint_rules: Vec<Arc<dyn LintRule>>, ) -> Result<(Vec<LintDiagnostic>, String), AnyError> { let file_name = file_path.to_string_lossy().to_string(); let source_code = fs::read_to_string(&file_path)?; let media_type = MediaType::from(&file_path); - let syntax = deno_ast::get_syntax(media_type); - let linter = create_linter(syntax, lint_rules); + let linter = create_linter(media_type, lint_rules); let (_, file_diagnostics) = linter.lint(file_name, source_code.clone())?; @@ -262,15 +260,14 @@ fn lint_file( /// Treats input as TypeScript. /// Compatible with `--json` flag. fn lint_stdin( - lint_rules: Arc<Vec<Box<dyn LintRule>>>, + lint_rules: Vec<Arc<dyn LintRule>>, ) -> Result<(Vec<LintDiagnostic>, String), AnyError> { let mut source_code = String::new(); if stdin().read_to_string(&mut source_code).is_err() { return Err(generic_error("Failed to read from stdin")); } - let syntax = deno_ast::get_syntax(MediaType::TypeScript); - let linter = create_linter(syntax, lint_rules); + let linter = create_linter(MediaType::TypeScript, lint_rules); let (_, file_diagnostics) = linter.lint(STDIN_FILE_NAME.to_string(), source_code.clone())?; @@ -489,7 +486,7 @@ pub(crate) fn get_configured_rules( rules_tags: Vec<String>, rules_include: Vec<String>, rules_exclude: Vec<String>, -) -> Result<Arc<Vec<Box<dyn LintRule>>>, AnyError> { +) -> Result<Vec<Arc<dyn LintRule>>, AnyError> { if maybe_lint_config.is_none() && rules_tags.is_empty() && rules_include.is_empty() diff --git a/cli/tools/repl.rs b/cli/tools/repl.rs index 0144db660..7bad940d4 100644 --- a/cli/tools/repl.rs +++ b/cli/tools/repl.rs @@ -655,6 +655,7 @@ impl ReplSession { media_type: deno_ast::MediaType::TypeScript, capture_tokens: false, maybe_syntax: None, + scope_analysis: false, })?; let transpiled_src = transpile( diff --git a/cli/tools/test.rs b/cli/tools/test.rs index aec6e6856..bccd6d731 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -566,6 +566,7 @@ fn extract_files_from_source_comments( media_type, capture_tokens: false, maybe_syntax: None, + scope_analysis: false, })?; let comments = parsed_source.comments().get_vec(); let blocks_regex = Regex::new(r"```([^\n]*)\n([\S\s]*?)```")?; |