mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
feat(lint): add no-boolean-literal-for-arguments
rule and enable no-unused-vars
for jsx files (#24034)
* https://github.com/denoland/deno_lint/pull/1271 * https://github.com/denoland/deno_lint/pull/1277 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
13723f267e
commit
e084fe10a9
7 changed files with 103 additions and 13 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1589,9 +1589,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_lint"
|
name = "deno_lint"
|
||||||
version = "0.58.4"
|
version = "0.59.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0622dde23f672fa3bb0788cef3cfc31ea21fc8570cd2b7e862d1e6575a527efe"
|
checksum = "0568595fd7f8ad76ddf66d70c1c5e3e680ad95c3d5abb44556e94d824643d6e2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"deno_ast",
|
"deno_ast",
|
||||||
|
|
|
@ -70,7 +70,7 @@ deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"]
|
||||||
deno_doc = { version = "=0.137.0", features = ["html", "syntect"] }
|
deno_doc = { version = "=0.137.0", features = ["html", "syntect"] }
|
||||||
deno_emit = "=0.41.0"
|
deno_emit = "=0.41.0"
|
||||||
deno_graph = { version = "=0.77.2", features = ["tokio_executor"] }
|
deno_graph = { version = "=0.77.2", features = ["tokio_executor"] }
|
||||||
deno_lint = { version = "=0.58.4", features = ["docs"] }
|
deno_lint = { version = "=0.59.1", features = ["docs"] }
|
||||||
deno_lockfile.workspace = true
|
deno_lockfile.workspace = true
|
||||||
deno_npm = "=0.21.0"
|
deno_npm = "=0.21.0"
|
||||||
deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||||
|
|
|
@ -1445,6 +1445,27 @@ impl CliOptions {
|
||||||
LintOptions::resolve(maybe_lint_config, Some(lint_flags), &self.initial_cwd)
|
LintOptions::resolve(maybe_lint_config, Some(lint_flags), &self.initial_cwd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn resolve_lint_config(
|
||||||
|
&self,
|
||||||
|
) -> Result<deno_lint::linter::LintConfig, AnyError> {
|
||||||
|
let ts_config_result =
|
||||||
|
self.resolve_ts_config_for_emit(TsConfigType::Emit)?;
|
||||||
|
|
||||||
|
let (transpile_options, _) =
|
||||||
|
crate::args::ts_config_to_transpile_and_emit_options(
|
||||||
|
ts_config_result.ts_config,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(deno_lint::linter::LintConfig {
|
||||||
|
default_jsx_factory: transpile_options
|
||||||
|
.jsx_automatic
|
||||||
|
.then(|| transpile_options.jsx_factory.clone()),
|
||||||
|
default_jsx_fragment_factory: transpile_options
|
||||||
|
.jsx_automatic
|
||||||
|
.then(|| transpile_options.jsx_fragment_factory.clone()),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn resolve_config_excludes(&self) -> Result<PathOrPatternSet, AnyError> {
|
pub fn resolve_config_excludes(&self) -> Result<PathOrPatternSet, AnyError> {
|
||||||
let maybe_config_files = if let Some(config_file) = &self.maybe_config_file
|
let maybe_config_files = if let Some(config_file) = &self.maybe_config_file
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@ use super::tsc;
|
||||||
|
|
||||||
use crate::args::jsr_url;
|
use crate::args::jsr_url;
|
||||||
use crate::tools::lint::create_linter;
|
use crate::tools::lint::create_linter;
|
||||||
|
use deno_lint::linter::LintConfig;
|
||||||
use deno_runtime::fs_util::specifier_to_file_path;
|
use deno_runtime::fs_util::specifier_to_file_path;
|
||||||
|
|
||||||
use deno_ast::SourceRange;
|
use deno_ast::SourceRange;
|
||||||
|
@ -169,9 +170,10 @@ fn as_lsp_range(
|
||||||
pub fn get_lint_references(
|
pub fn get_lint_references(
|
||||||
parsed_source: &deno_ast::ParsedSource,
|
parsed_source: &deno_ast::ParsedSource,
|
||||||
lint_rules: Vec<&'static dyn LintRule>,
|
lint_rules: Vec<&'static dyn LintRule>,
|
||||||
|
lint_config: LintConfig,
|
||||||
) -> Result<Vec<Reference>, AnyError> {
|
) -> Result<Vec<Reference>, AnyError> {
|
||||||
let linter = create_linter(lint_rules);
|
let linter = create_linter(lint_rules);
|
||||||
let lint_diagnostics = linter.lint_with_ast(parsed_source);
|
let lint_diagnostics = linter.lint_with_ast(parsed_source, lint_config);
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
lint_diagnostics
|
lint_diagnostics
|
||||||
|
|
|
@ -24,6 +24,7 @@ use deno_core::serde_json;
|
||||||
use deno_core::serde_json::json;
|
use deno_core::serde_json::json;
|
||||||
use deno_core::serde_json::Value;
|
use deno_core::serde_json::Value;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
|
use deno_lint::linter::LintConfig;
|
||||||
use deno_lockfile::Lockfile;
|
use deno_lockfile::Lockfile;
|
||||||
use deno_npm::npm_rc::ResolvedNpmRc;
|
use deno_npm::npm_rc::ResolvedNpmRc;
|
||||||
use deno_runtime::deno_node::PackageJson;
|
use deno_runtime::deno_node::PackageJson;
|
||||||
|
@ -1055,6 +1056,9 @@ impl Default for LspTsConfig {
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"useUnknownInCatchVariables": false,
|
"useUnknownInCatchVariables": false,
|
||||||
|
"jsx": "react",
|
||||||
|
"jsxFactory": "React.createElement",
|
||||||
|
"jsxFragmentFactory": "React.Fragment",
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1087,6 +1091,7 @@ pub struct ConfigData {
|
||||||
pub config_file: Option<Arc<ConfigFile>>,
|
pub config_file: Option<Arc<ConfigFile>>,
|
||||||
pub fmt_options: Arc<FmtOptions>,
|
pub fmt_options: Arc<FmtOptions>,
|
||||||
pub lint_options: Arc<LintOptions>,
|
pub lint_options: Arc<LintOptions>,
|
||||||
|
pub lint_config: LintConfig,
|
||||||
pub lint_rules: Arc<ConfiguredRules>,
|
pub lint_rules: Arc<ConfiguredRules>,
|
||||||
pub ts_config: Arc<LspTsConfig>,
|
pub ts_config: Arc<LspTsConfig>,
|
||||||
pub byonm: bool,
|
pub byonm: bool,
|
||||||
|
@ -1253,6 +1258,28 @@ impl ConfigData {
|
||||||
|
|
||||||
let ts_config = LspTsConfig::new(config_file.as_ref());
|
let ts_config = LspTsConfig::new(config_file.as_ref());
|
||||||
|
|
||||||
|
let lint_config = if ts_config.inner.0.get("jsx").and_then(|v| v.as_str())
|
||||||
|
== Some("react")
|
||||||
|
{
|
||||||
|
let default_jsx_factory =
|
||||||
|
ts_config.inner.0.get("jsxFactory").and_then(|v| v.as_str());
|
||||||
|
let default_jsx_fragment_factory = ts_config
|
||||||
|
.inner
|
||||||
|
.0
|
||||||
|
.get("jsxFragmentFactory")
|
||||||
|
.and_then(|v| v.as_str());
|
||||||
|
deno_lint::linter::LintConfig {
|
||||||
|
default_jsx_factory: default_jsx_factory.map(String::from),
|
||||||
|
default_jsx_fragment_factory: default_jsx_fragment_factory
|
||||||
|
.map(String::from),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
deno_lint::linter::LintConfig {
|
||||||
|
default_jsx_factory: None,
|
||||||
|
default_jsx_fragment_factory: None,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let vendor_dir = config_file.as_ref().and_then(|c| c.vendor_dir_path());
|
let vendor_dir = config_file.as_ref().and_then(|c| c.vendor_dir_path());
|
||||||
|
|
||||||
// Load lockfile
|
// Load lockfile
|
||||||
|
@ -1429,6 +1456,7 @@ impl ConfigData {
|
||||||
config_file: config_file.map(Arc::new),
|
config_file: config_file.map(Arc::new),
|
||||||
fmt_options,
|
fmt_options,
|
||||||
lint_options,
|
lint_options,
|
||||||
|
lint_config,
|
||||||
lint_rules,
|
lint_rules,
|
||||||
ts_config: Arc::new(ts_config),
|
ts_config: Arc::new(ts_config),
|
||||||
byonm,
|
byonm,
|
||||||
|
|
|
@ -38,6 +38,7 @@ use deno_graph::source::ResolutionMode;
|
||||||
use deno_graph::Resolution;
|
use deno_graph::Resolution;
|
||||||
use deno_graph::ResolutionError;
|
use deno_graph::ResolutionError;
|
||||||
use deno_graph::SpecifierError;
|
use deno_graph::SpecifierError;
|
||||||
|
use deno_lint::linter::LintConfig;
|
||||||
use deno_lint::rules::LintRule;
|
use deno_lint::rules::LintRule;
|
||||||
use deno_runtime::deno_fs;
|
use deno_runtime::deno_fs;
|
||||||
use deno_runtime::deno_node;
|
use deno_runtime::deno_node;
|
||||||
|
@ -804,12 +805,27 @@ fn generate_lint_diagnostics(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let version = document.maybe_lsp_version();
|
let version = document.maybe_lsp_version();
|
||||||
let (lint_options, lint_rules) = config
|
let (lint_options, lint_config, lint_rules) = config
|
||||||
.tree
|
.tree
|
||||||
.scope_for_specifier(specifier)
|
.scope_for_specifier(specifier)
|
||||||
.and_then(|s| config_data_by_scope.get(s))
|
.and_then(|s| config_data_by_scope.get(s))
|
||||||
.map(|d| (d.lint_options.clone(), d.lint_rules.clone()))
|
.map(|d| {
|
||||||
.unwrap_or_default();
|
(
|
||||||
|
d.lint_options.clone(),
|
||||||
|
d.lint_config.clone(),
|
||||||
|
d.lint_rules.clone(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
(
|
||||||
|
Arc::default(),
|
||||||
|
LintConfig {
|
||||||
|
default_jsx_factory: None,
|
||||||
|
default_jsx_fragment_factory: None,
|
||||||
|
},
|
||||||
|
Arc::default(),
|
||||||
|
)
|
||||||
|
});
|
||||||
diagnostics_vec.push(DiagnosticRecord {
|
diagnostics_vec.push(DiagnosticRecord {
|
||||||
specifier: specifier.clone(),
|
specifier: specifier.clone(),
|
||||||
versioned: VersionedDiagnostics {
|
versioned: VersionedDiagnostics {
|
||||||
|
@ -817,6 +833,7 @@ fn generate_lint_diagnostics(
|
||||||
diagnostics: generate_document_lint_diagnostics(
|
diagnostics: generate_document_lint_diagnostics(
|
||||||
&document,
|
&document,
|
||||||
&lint_options,
|
&lint_options,
|
||||||
|
lint_config,
|
||||||
lint_rules.rules.clone(),
|
lint_rules.rules.clone(),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -828,6 +845,7 @@ fn generate_lint_diagnostics(
|
||||||
fn generate_document_lint_diagnostics(
|
fn generate_document_lint_diagnostics(
|
||||||
document: &Document,
|
document: &Document,
|
||||||
lint_options: &LintOptions,
|
lint_options: &LintOptions,
|
||||||
|
lint_config: LintConfig,
|
||||||
lint_rules: Vec<&'static dyn LintRule>,
|
lint_rules: Vec<&'static dyn LintRule>,
|
||||||
) -> Vec<lsp::Diagnostic> {
|
) -> Vec<lsp::Diagnostic> {
|
||||||
if !lint_options.files.matches_specifier(document.specifier()) {
|
if !lint_options.files.matches_specifier(document.specifier()) {
|
||||||
|
@ -836,7 +854,7 @@ fn generate_document_lint_diagnostics(
|
||||||
match document.maybe_parsed_source() {
|
match document.maybe_parsed_source() {
|
||||||
Some(Ok(parsed_source)) => {
|
Some(Ok(parsed_source)) => {
|
||||||
if let Ok(references) =
|
if let Ok(references) =
|
||||||
analysis::get_lint_references(&parsed_source, lint_rules)
|
analysis::get_lint_references(&parsed_source, lint_rules, lint_config)
|
||||||
{
|
{
|
||||||
references
|
references
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
@ -17,6 +17,7 @@ use deno_core::parking_lot::Mutex;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_graph::FastCheckDiagnostic;
|
use deno_graph::FastCheckDiagnostic;
|
||||||
use deno_lint::diagnostic::LintDiagnostic;
|
use deno_lint::diagnostic::LintDiagnostic;
|
||||||
|
use deno_lint::linter::LintConfig;
|
||||||
use deno_lint::linter::LintFileOptions;
|
use deno_lint::linter::LintFileOptions;
|
||||||
use deno_lint::linter::Linter;
|
use deno_lint::linter::Linter;
|
||||||
use deno_lint::linter::LinterBuilder;
|
use deno_lint::linter::LinterBuilder;
|
||||||
|
@ -79,6 +80,7 @@ pub async fn lint(flags: Flags, lint_flags: LintFlags) -> Result<(), AnyError> {
|
||||||
let factory = CliFactory::from_flags(flags)?;
|
let factory = CliFactory::from_flags(flags)?;
|
||||||
let cli_options = factory.cli_options();
|
let cli_options = factory.cli_options();
|
||||||
let lint_options = cli_options.resolve_lint_options(lint_flags)?;
|
let lint_options = cli_options.resolve_lint_options(lint_flags)?;
|
||||||
|
let lint_config = cli_options.resolve_lint_config()?;
|
||||||
let files =
|
let files =
|
||||||
collect_lint_files(cli_options, lint_options.files.clone())
|
collect_lint_files(cli_options, lint_options.files.clone())
|
||||||
.and_then(|files| {
|
.and_then(|files| {
|
||||||
|
@ -105,7 +107,7 @@ pub async fn lint(flags: Flags, lint_flags: LintFlags) -> Result<(), AnyError> {
|
||||||
files
|
files
|
||||||
};
|
};
|
||||||
|
|
||||||
lint_files(factory, lint_options, lint_paths).await?;
|
lint_files(factory, lint_options, lint_config, lint_paths).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -116,6 +118,7 @@ pub async fn lint(flags: Flags, lint_flags: LintFlags) -> Result<(), AnyError> {
|
||||||
let cli_options = factory.cli_options();
|
let cli_options = factory.cli_options();
|
||||||
let is_stdin = lint_flags.is_stdin();
|
let is_stdin = lint_flags.is_stdin();
|
||||||
let lint_options = cli_options.resolve_lint_options(lint_flags)?;
|
let lint_options = cli_options.resolve_lint_options(lint_flags)?;
|
||||||
|
let lint_config = cli_options.resolve_lint_config()?;
|
||||||
let files = &lint_options.files;
|
let files = &lint_options.files;
|
||||||
let success = if is_stdin {
|
let success = if is_stdin {
|
||||||
let reporter_kind = lint_options.reporter_kind;
|
let reporter_kind = lint_options.reporter_kind;
|
||||||
|
@ -125,7 +128,7 @@ pub async fn lint(flags: Flags, lint_flags: LintFlags) -> Result<(), AnyError> {
|
||||||
cli_options.maybe_config_file().as_ref(),
|
cli_options.maybe_config_file().as_ref(),
|
||||||
)?;
|
)?;
|
||||||
let file_path = cli_options.initial_cwd().join(STDIN_FILE_NAME);
|
let file_path = cli_options.initial_cwd().join(STDIN_FILE_NAME);
|
||||||
let r = lint_stdin(&file_path, lint_rules.rules);
|
let r = lint_stdin(&file_path, lint_rules.rules, lint_config);
|
||||||
let success = handle_lint_result(
|
let success = handle_lint_result(
|
||||||
&file_path.to_string_lossy(),
|
&file_path.to_string_lossy(),
|
||||||
r,
|
r,
|
||||||
|
@ -143,7 +146,7 @@ pub async fn lint(flags: Flags, lint_flags: LintFlags) -> Result<(), AnyError> {
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
debug!("Found {} files", target_files.len());
|
debug!("Found {} files", target_files.len());
|
||||||
lint_files(factory, lint_options, target_files).await?
|
lint_files(factory, lint_options, lint_config, target_files).await?
|
||||||
};
|
};
|
||||||
if !success {
|
if !success {
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
|
@ -156,6 +159,7 @@ pub async fn lint(flags: Flags, lint_flags: LintFlags) -> Result<(), AnyError> {
|
||||||
async fn lint_files(
|
async fn lint_files(
|
||||||
factory: CliFactory,
|
factory: CliFactory,
|
||||||
lint_options: LintOptions,
|
lint_options: LintOptions,
|
||||||
|
lint_config: LintConfig,
|
||||||
paths: Vec<PathBuf>,
|
paths: Vec<PathBuf>,
|
||||||
) -> Result<bool, AnyError> {
|
) -> Result<bool, AnyError> {
|
||||||
let caches = factory.caches()?;
|
let caches = factory.caches()?;
|
||||||
|
@ -221,6 +225,7 @@ async fn lint_files(
|
||||||
let linter = create_linter(lint_rules.rules);
|
let linter = create_linter(lint_rules.rules);
|
||||||
let reporter_lock = reporter_lock.clone();
|
let reporter_lock = reporter_lock.clone();
|
||||||
let incremental_cache = incremental_cache.clone();
|
let incremental_cache = incremental_cache.clone();
|
||||||
|
let lint_config = lint_config.clone();
|
||||||
let fix = lint_options.fix;
|
let fix = lint_options.fix;
|
||||||
deno_core::unsync::spawn(async move {
|
deno_core::unsync::spawn(async move {
|
||||||
run_parallelized(paths, {
|
run_parallelized(paths, {
|
||||||
|
@ -232,7 +237,7 @@ async fn lint_files(
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let r = lint_file(&linter, &file_path, file_text, fix);
|
let r = lint_file(&linter, &file_path, file_text, lint_config, fix);
|
||||||
if let Ok((file_source, file_diagnostics)) = &r {
|
if let Ok((file_source, file_diagnostics)) = &r {
|
||||||
if file_diagnostics.is_empty() {
|
if file_diagnostics.is_empty() {
|
||||||
// update the incremental cache if there were no diagnostics
|
// update the incremental cache if there were no diagnostics
|
||||||
|
@ -335,19 +340,28 @@ fn lint_file(
|
||||||
linter: &Linter,
|
linter: &Linter,
|
||||||
file_path: &Path,
|
file_path: &Path,
|
||||||
source_code: String,
|
source_code: String,
|
||||||
|
config: LintConfig,
|
||||||
fix: bool,
|
fix: bool,
|
||||||
) -> Result<(ParsedSource, Vec<LintDiagnostic>), AnyError> {
|
) -> Result<(ParsedSource, Vec<LintDiagnostic>), AnyError> {
|
||||||
let specifier = specifier_from_file_path(file_path)?;
|
let specifier = specifier_from_file_path(file_path)?;
|
||||||
let media_type = MediaType::from_specifier(&specifier);
|
let media_type = MediaType::from_specifier(&specifier);
|
||||||
|
|
||||||
if fix {
|
if fix {
|
||||||
lint_file_and_fix(linter, &specifier, media_type, source_code, file_path)
|
lint_file_and_fix(
|
||||||
|
linter,
|
||||||
|
&specifier,
|
||||||
|
media_type,
|
||||||
|
source_code,
|
||||||
|
file_path,
|
||||||
|
config,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
linter
|
linter
|
||||||
.lint_file(LintFileOptions {
|
.lint_file(LintFileOptions {
|
||||||
specifier,
|
specifier,
|
||||||
media_type,
|
media_type,
|
||||||
source_code,
|
source_code,
|
||||||
|
config,
|
||||||
})
|
})
|
||||||
.map_err(AnyError::from)
|
.map_err(AnyError::from)
|
||||||
}
|
}
|
||||||
|
@ -359,12 +373,14 @@ fn lint_file_and_fix(
|
||||||
media_type: MediaType,
|
media_type: MediaType,
|
||||||
source_code: String,
|
source_code: String,
|
||||||
file_path: &Path,
|
file_path: &Path,
|
||||||
|
config: LintConfig,
|
||||||
) -> Result<(ParsedSource, Vec<LintDiagnostic>), deno_core::anyhow::Error> {
|
) -> Result<(ParsedSource, Vec<LintDiagnostic>), deno_core::anyhow::Error> {
|
||||||
// initial lint
|
// initial lint
|
||||||
let (source, diagnostics) = linter.lint_file(LintFileOptions {
|
let (source, diagnostics) = linter.lint_file(LintFileOptions {
|
||||||
specifier: specifier.clone(),
|
specifier: specifier.clone(),
|
||||||
media_type,
|
media_type,
|
||||||
source_code,
|
source_code,
|
||||||
|
config: config.clone(),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// Try applying fixes repeatedly until the file has none left or
|
// Try applying fixes repeatedly until the file has none left or
|
||||||
|
@ -379,6 +395,7 @@ fn lint_file_and_fix(
|
||||||
specifier,
|
specifier,
|
||||||
media_type,
|
media_type,
|
||||||
linter,
|
linter,
|
||||||
|
config.clone(),
|
||||||
source.text_info(),
|
source.text_info(),
|
||||||
&diagnostics,
|
&diagnostics,
|
||||||
)?;
|
)?;
|
||||||
|
@ -417,6 +434,7 @@ fn apply_lint_fixes_and_relint(
|
||||||
specifier: &ModuleSpecifier,
|
specifier: &ModuleSpecifier,
|
||||||
media_type: MediaType,
|
media_type: MediaType,
|
||||||
linter: &Linter,
|
linter: &Linter,
|
||||||
|
config: LintConfig,
|
||||||
text_info: &SourceTextInfo,
|
text_info: &SourceTextInfo,
|
||||||
diagnostics: &[LintDiagnostic],
|
diagnostics: &[LintDiagnostic],
|
||||||
) -> Result<Option<(ParsedSource, Vec<LintDiagnostic>)>, AnyError> {
|
) -> Result<Option<(ParsedSource, Vec<LintDiagnostic>)>, AnyError> {
|
||||||
|
@ -428,6 +446,7 @@ fn apply_lint_fixes_and_relint(
|
||||||
specifier: specifier.clone(),
|
specifier: specifier.clone(),
|
||||||
source_code: new_text,
|
source_code: new_text,
|
||||||
media_type,
|
media_type,
|
||||||
|
config,
|
||||||
})
|
})
|
||||||
.map(Some)
|
.map(Some)
|
||||||
.context(
|
.context(
|
||||||
|
@ -479,6 +498,7 @@ fn apply_lint_fixes(
|
||||||
fn lint_stdin(
|
fn lint_stdin(
|
||||||
file_path: &Path,
|
file_path: &Path,
|
||||||
lint_rules: Vec<&'static dyn LintRule>,
|
lint_rules: Vec<&'static dyn LintRule>,
|
||||||
|
config: LintConfig,
|
||||||
) -> Result<(ParsedSource, Vec<LintDiagnostic>), AnyError> {
|
) -> Result<(ParsedSource, Vec<LintDiagnostic>), AnyError> {
|
||||||
let mut source_code = String::new();
|
let mut source_code = String::new();
|
||||||
if stdin().read_to_string(&mut source_code).is_err() {
|
if stdin().read_to_string(&mut source_code).is_err() {
|
||||||
|
@ -492,6 +512,7 @@ fn lint_stdin(
|
||||||
specifier: specifier_from_file_path(file_path)?,
|
specifier: specifier_from_file_path(file_path)?,
|
||||||
source_code: source_code.clone(),
|
source_code: source_code.clone(),
|
||||||
media_type: MediaType::TypeScript,
|
media_type: MediaType::TypeScript,
|
||||||
|
config,
|
||||||
})
|
})
|
||||||
.map_err(AnyError::from)
|
.map_err(AnyError::from)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue