From 106b1f135ca93187074afe1d1e1dcd2f18a24a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 4 Dec 2024 01:43:19 +0100 Subject: [PATCH] load plugins from a config file --- Cargo.lock | 3 +-- Cargo.toml | 3 +++ cli/args/mod.rs | 9 +++++++++ cli/tools/lint/mod.rs | 9 +++++++++ deno.json | 7 +++++++ 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 deno.json diff --git a/Cargo.lock b/Cargo.lock index 58879c8d73..485d86b6d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1432,8 +1432,7 @@ dependencies = [ [[package]] name = "deno_config" version = "0.39.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce717af3fe6788dae63965d58d5637fd62be8fe4f345f189137ffc06c51837d2" +source = "git+https://github.com/denoland/deno_config.git?branch=deno_lint_rules#13f6ff94ce36896b29c2a84386e2173bb18a036d" dependencies = [ "anyhow", "deno_package_json", diff --git a/Cargo.toml b/Cargo.toml index 23670beec3..9f3686d786 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -339,3 +339,6 @@ opt-level = 3 opt-level = 3 [profile.release.package.zstd-sys] opt-level = 3 + +[patch.crates-io] +deno_config = { git = "https://github.com/denoland/deno_config.git", branch = "deno_lint_rules" } diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 0b049cf409..52c100ee55 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -471,6 +471,7 @@ pub struct LintOptions { pub rules: LintRulesConfig, pub files: FilePatterns, pub fix: bool, + pub plugins: Vec, } impl Default for LintOptions { @@ -485,6 +486,7 @@ impl LintOptions { rules: Default::default(), files: FilePatterns::new_with_base(base), fix: false, + plugins: vec![], } } @@ -498,6 +500,13 @@ impl LintOptions { lint_flags.maybe_rules_exclude.clone(), ), fix: lint_flags.fix, + plugins: if !lint_config.options.plugins.is_empty() { + lint_config.options.plugins.clone() + } else if let Some(plugins) = lint_flags.maybe_plugins.as_ref() { + plugins.clone() + } else { + vec![] + }, } } } diff --git a/cli/tools/lint/mod.rs b/cli/tools/lint/mod.rs index f86c0ead38..903aad97ed 100644 --- a/cli/tools/lint/mod.rs +++ b/cli/tools/lint/mod.rs @@ -295,6 +295,15 @@ impl WorkspaceLinter { )) }); + let maybe_plugins = if maybe_plugins.is_some() { + maybe_plugins + } else { + if lint_options.plugins.is_empty() { + None + } else { + Some(lint_options.plugins.clone()) + } + }; let plugin_specifiers = if let Some(plugins) = maybe_plugins { let mut plugin_specifiers = Vec::with_capacity(plugins.len()); let cwd = cli_options.initial_cwd(); diff --git a/deno.json b/deno.json new file mode 100644 index 0000000000..3343345ff4 --- /dev/null +++ b/deno.json @@ -0,0 +1,7 @@ +{ + "lint": { + "plugins": [ + "./plugin.js" + ] + } +}