diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-09-14 22:27:44 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-14 14:27:44 +0200 |
commit | a6f34d47222ad7cc40519bd95a58ae773d1fe656 (patch) | |
tree | 462618f8013501abcc231ea1316783e173db7ba0 /cli/lint.rs | |
parent | e688a701e20cbed8908b4fb3629a554dc75b4e5b (diff) |
refactor: use ParsedModule and improve MediaTypes enum (#7456)
Diffstat (limited to 'cli/lint.rs')
-rw-r--r-- | cli/lint.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/cli/lint.rs b/cli/lint.rs index c52aff408..3ff13f020 100644 --- a/cli/lint.rs +++ b/cli/lint.rs @@ -6,13 +6,12 @@ //! At the moment it is only consumed using CLI but in //! the future it can be easily extended to provide //! the same functions as ops available in JS runtime. +use crate::ast; use crate::colors; -use crate::file_fetcher::map_file_extension; use crate::fmt::collect_files; use crate::fmt::run_parallelized; use crate::fmt_errors; use crate::msg; -use crate::swc_util; use deno_core::ErrBox; use deno_lint::diagnostic::LintDiagnostic; use deno_lint::linter::Linter; @@ -131,8 +130,8 @@ fn lint_file( ) -> Result<(Vec<LintDiagnostic>, String), ErrBox> { let file_name = file_path.to_string_lossy().to_string(); let source_code = fs::read_to_string(&file_path)?; - let media_type = map_file_extension(&file_path); - let syntax = swc_util::get_syntax_for_media_type(media_type); + let media_type = msg::MediaType::from(&file_path); + let syntax = ast::get_syntax(&media_type); let lint_rules = rules::get_recommended_rules(); let mut linter = create_linter(syntax, lint_rules); @@ -158,7 +157,7 @@ fn lint_stdin(json: bool) -> Result<(), ErrBox> { }; let mut reporter = create_reporter(reporter_kind); let lint_rules = rules::get_recommended_rules(); - let syntax = swc_util::get_syntax_for_media_type(msg::MediaType::TypeScript); + let syntax = ast::get_syntax(&msg::MediaType::TypeScript); let mut linter = create_linter(syntax, lint_rules); let mut has_error = false; let pseudo_file_name = "_stdin.ts"; |