1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 04:52:26 -05:00

load plugins from a config file

This commit is contained in:
Bartek Iwańczuk 2024-12-04 01:43:19 +01:00
parent c2ac42485f
commit 106b1f135c
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
5 changed files with 29 additions and 2 deletions

3
Cargo.lock generated
View file

@ -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",

View file

@ -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" }

View file

@ -471,6 +471,7 @@ pub struct LintOptions {
pub rules: LintRulesConfig,
pub files: FilePatterns,
pub fix: bool,
pub plugins: Vec<String>,
}
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![]
},
}
}
}

View file

@ -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();

7
deno.json Normal file
View file

@ -0,0 +1,7 @@
{
"lint": {
"plugins": [
"./plugin.js"
]
}
}