diff options
author | Luca Casonato <hello@lcas.dev> | 2024-05-30 02:09:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-30 00:09:16 +0000 |
commit | e084fe10a98556d4630b54bdda2ce23b3b5b8a60 (patch) | |
tree | fe9d25aadc1fdf3884ead22f90595f1f9e1f3e55 /cli/lsp/config.rs | |
parent | 13723f267eb87f8c28ef0769cdf7e233b971326e (diff) |
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>
Diffstat (limited to 'cli/lsp/config.rs')
-rw-r--r-- | cli/lsp/config.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index 364999cff..02f3d5afb 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -24,6 +24,7 @@ use deno_core::serde_json; use deno_core::serde_json::json; use deno_core::serde_json::Value; use deno_core::ModuleSpecifier; +use deno_lint::linter::LintConfig; use deno_lockfile::Lockfile; use deno_npm::npm_rc::ResolvedNpmRc; use deno_runtime::deno_node::PackageJson; @@ -1055,6 +1056,9 @@ impl Default for LspTsConfig { "target": "esnext", "useDefineForClassFields": true, "useUnknownInCatchVariables": false, + "jsx": "react", + "jsxFactory": "React.createElement", + "jsxFragmentFactory": "React.Fragment", })), } } @@ -1087,6 +1091,7 @@ pub struct ConfigData { pub config_file: Option<Arc<ConfigFile>>, pub fmt_options: Arc<FmtOptions>, pub lint_options: Arc<LintOptions>, + pub lint_config: LintConfig, pub lint_rules: Arc<ConfiguredRules>, pub ts_config: Arc<LspTsConfig>, pub byonm: bool, @@ -1253,6 +1258,28 @@ impl ConfigData { 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()); // Load lockfile @@ -1429,6 +1456,7 @@ impl ConfigData { config_file: config_file.map(Arc::new), fmt_options, lint_options, + lint_config, lint_rules, ts_config: Arc::new(ts_config), byonm, |