Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lint): add support for lint plugin selectors #27448

Closed
wants to merge 92 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
79b5c3e
basic plugin loading
bartlomieju Dec 1, 2024
7e8e4ae
basic execution
bartlomieju Dec 1, 2024
1eb4862
some basic structure
bartlomieju Dec 1, 2024
49c2d9e
add visitor
bartlomieju Dec 1, 2024
99d70c9
actually pass AST to plugin
bartlomieju Dec 1, 2024
1fdcbd9
PluginRunner and PluginRunnerProxy
bartlomieju Dec 2, 2024
bc00517
req -> resp
bartlomieju Dec 2, 2024
7f45875
first diagnostic from a plugin!
bartlomieju Dec 2, 2024
c9fa293
load plugins from a flag
bartlomieju Dec 2, 2024
5639379
declarative
bartlomieju Dec 2, 2024
0b36971
cleanup
bartlomieju Dec 2, 2024
f9291e4
basic range
bartlomieju Dec 2, 2024
dea3219
measure how long i takes to run
bartlomieju Dec 2, 2024
439d43e
don't dump ast
bartlomieju Dec 2, 2024
c3208df
Merge branch 'main' into lint_plugins
bartlomieju Dec 3, 2024
5a6c128
add basic traversal
bartlomieju Dec 3, 2024
fb47288
correctly report
bartlomieju Dec 3, 2024
a15c116
remove some prints
bartlomieju Dec 3, 2024
008e249
drop!: vue demo rule
marvinhagemeister Dec 3, 2024
f3745f9
feat: add source() method
marvinhagemeister Dec 3, 2024
4676643
chore: add more lint rules
marvinhagemeister Dec 3, 2024
1217314
build on stable rust
bartlomieju Dec 3, 2024
a1dfea6
remove unneeded files
bartlomieju Dec 3, 2024
37bafdc
remove debug log, lint
bartlomieju Dec 3, 2024
77526ca
fix: show correct specifier in error output
marvinhagemeister Dec 3, 2024
5a950e5
drop!: temporary disable lint cache
marvinhagemeister Dec 3, 2024
42d9936
wip
bartlomieju Dec 3, 2024
c2ac424
Merge branch 'main' into lint_plugins
bartlomieju Dec 4, 2024
106b1f1
load plugins from a config file
bartlomieju Dec 4, 2024
3e1e46d
almost working with regular cli worker
bartlomieju Dec 4, 2024
052a035
plugins can be authored in TS
bartlomieju Dec 4, 2024
a1e590d
add basic type decl
bartlomieju Dec 4, 2024
3588e75
comment out type decls, capture more fns
bartlomieju Dec 4, 2024
026a5d9
optimize callign to js
bartlomieju Dec 4, 2024
78dc5b8
remove dead code
bartlomieju Dec 4, 2024
a148205
fix: only invoke lint plugin runner when there are plugins
marvinhagemeister Dec 4, 2024
2dba36e
feat: merge lint plugin visitors
marvinhagemeister Dec 4, 2024
1fc41dc
add visitor types
marvinhagemeister Dec 6, 2024
58e7c2d
more types
marvinhagemeister Dec 6, 2024
54f002f
chore: ignore lint type errors for now
marvinhagemeister Dec 6, 2024
c734214
WIP
marvinhagemeister Dec 4, 2024
f0a2614
WIP
marvinhagemeister Dec 5, 2024
d8897bd
WIP
marvinhagemeister Dec 5, 2024
4d3767b
WIP
marvinhagemeister Dec 5, 2024
4365959
WIP
marvinhagemeister Dec 5, 2024
83da570
WIP
marvinhagemeister Dec 6, 2024
ccf7009
WIP
marvinhagemeister Dec 6, 2024
19baadf
WIP
marvinhagemeister Dec 9, 2024
280d10e
WIP
marvinhagemeister Dec 10, 2024
99b9e72
WIP
marvinhagemeister Dec 10, 2024
c039c51
WIP
marvinhagemeister Dec 10, 2024
22681b4
WIP
marvinhagemeister Dec 10, 2024
ccabd64
WIP
marvinhagemeister Dec 10, 2024
20c477d
WIP
marvinhagemeister Dec 11, 2024
3c19d06
WIP
marvinhagemeister Dec 11, 2024
3629fd1
WIP
marvinhagemeister Dec 11, 2024
d6c20d3
WIP
marvinhagemeister Dec 11, 2024
a2b10d4
more nodes
marvinhagemeister Dec 11, 2024
8e56216
more nodes
marvinhagemeister Dec 11, 2024
17ad68b
more nodes
marvinhagemeister Dec 11, 2024
a3421b9
more nodes
marvinhagemeister Dec 12, 2024
499257c
refactor
marvinhagemeister Dec 12, 2024
dd75c31
more_nodes
marvinhagemeister Dec 12, 2024
d9e506e
refactors
marvinhagemeister Dec 12, 2024
dda408b
fix: clippy
marvinhagemeister Dec 12, 2024
2902eba
refactor ast
marvinhagemeister Dec 12, 2024
7c7a888
basic ts nodes
marvinhagemeister Dec 12, 2024
8f10431
more nodes
marvinhagemeister Dec 12, 2024
76c1275
fix traversal
marvinhagemeister Dec 12, 2024
c83f722
Refactor binary ast
marvinhagemeister Dec 12, 2024
f50bf9b
refactor node handling
marvinhagemeister Dec 12, 2024
65fcda4
improve format
marvinhagemeister Dec 13, 2024
ea11f95
make js plugins independent of ast strucure
marvinhagemeister Dec 14, 2024
3f9ee0d
feat(lint): support visitor selector syntax
marvinhagemeister Dec 13, 2024
f167277
remove dead code
marvinhagemeister Dec 15, 2024
86fc6e6
WIP
marvinhagemeister Dec 16, 2024
2f18594
WIP
marvinhagemeister Dec 16, 2024
e542ba8
fix selector parser
marvinhagemeister Dec 16, 2024
132db56
fix nth child
marvinhagemeister Dec 16, 2024
d9fd959
integrate selctors part 1
marvinhagemeister Dec 17, 2024
6e70ba2
get selector integration working
marvinhagemeister Dec 17, 2024
dde9f52
fix: descendant selector
marvinhagemeister Dec 17, 2024
53a680b
Merge branch 'main' into lint_plugins
bartlomieju Dec 18, 2024
8d9f9ce
fix: node name
marvinhagemeister Dec 18, 2024
321a1fe
fix: sibling selectors
marvinhagemeister Dec 18, 2024
e296022
fix more types
marvinhagemeister Dec 18, 2024
5ea018a
improve conversion safety
marvinhagemeister Dec 18, 2024
13cc74d
clippy stuff
marvinhagemeister Dec 18, 2024
d3e41a7
Merge branch 'main' into lint_plugins
bartlomieju Dec 21, 2024
fcfd4c0
wip after merge
bartlomieju Dec 21, 2024
67e2d06
Try to load files differently
bartlomieju Dec 21, 2024
6e28ae5
runs tests, but they fail
bartlomieju Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,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" }
57 changes: 57 additions & 0 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ pub struct LintFlags {
pub json: bool,
pub compact: bool,
pub watch: Option<WatchFlags>,
pub maybe_plugins: Option<Vec<String>>,
}

impl LintFlags {
Expand Down Expand Up @@ -499,6 +500,7 @@ impl DenoSubcommand {
| Self::Jupyter(_)
| Self::Repl(_)
| Self::Bench(_)
| Self::Lint(_)
| Self::Lsp
)
}
Expand Down Expand Up @@ -2865,6 +2867,16 @@ To ignore linting on an entire file, you can add an ignore comment at the top of
.help("Use set of rules with a tag")
.help_heading(LINT_HEADING),
)
.arg(
Arg::new("plugins")
.long("plugins")
.require_equals(true)
.num_args(1..)
.action(ArgAction::Append)
.use_value_delimiter(true)
.help("Plugins to run, relative or absolute paths")
.help_heading(LINT_HEADING),
)
.arg(
Arg::new("rules-include")
.long("rules-include")
Expand Down Expand Up @@ -5133,6 +5145,10 @@ fn lint_parse(
.remove_many::<String>("rules-exclude")
.map(|f| f.collect());

let maybe_plugins = matches
.remove_many::<String>("plugins")
.map(|f| f.collect());

let json = matches.get_flag("json");
let compact = matches.get_flag("compact");

Expand All @@ -5149,6 +5165,7 @@ fn lint_parse(
json,
compact,
watch: watch_arg_parse(matches)?,
maybe_plugins,
});
Ok(())
}
Expand Down Expand Up @@ -7160,6 +7177,7 @@ mod tests {
json: false,
compact: false,
watch: Default::default(),
maybe_plugins: None,
}),
..Flags::default()
}
Expand Down Expand Up @@ -7189,6 +7207,7 @@ mod tests {
json: false,
compact: false,
watch: Some(Default::default()),
maybe_plugins: None,
}),
permissions: PermissionFlags {
allow_import: Some(vec![]),
Expand Down Expand Up @@ -7226,6 +7245,7 @@ mod tests {
no_clear_screen: true,
exclude: vec![],
}),
maybe_plugins: None,
}),
..Flags::default()
}
Expand Down Expand Up @@ -7253,6 +7273,7 @@ mod tests {
json: false,
compact: false,
watch: Default::default(),
maybe_plugins: None,
}),
..Flags::default()
}
Expand All @@ -7275,6 +7296,7 @@ mod tests {
json: false,
compact: false,
watch: Default::default(),
maybe_plugins: None,
}),
..Flags::default()
}
Expand Down Expand Up @@ -7302,6 +7324,7 @@ mod tests {
json: false,
compact: false,
watch: Default::default(),
maybe_plugins: None,
}),
..Flags::default()
}
Expand Down Expand Up @@ -7330,6 +7353,7 @@ mod tests {
json: false,
compact: false,
watch: Default::default(),
maybe_plugins: None,
}),
..Flags::default()
}
Expand All @@ -7352,6 +7376,7 @@ mod tests {
json: true,
compact: false,
watch: Default::default(),
maybe_plugins: None,
}),
..Flags::default()
}
Expand Down Expand Up @@ -7381,6 +7406,7 @@ mod tests {
json: true,
compact: false,
watch: Default::default(),
maybe_plugins: None,
}),
config_flag: ConfigFlag::Path("Deno.jsonc".to_string()),
..Flags::default()
Expand Down Expand Up @@ -7411,11 +7437,42 @@ mod tests {
json: false,
compact: true,
watch: Default::default(),
maybe_plugins: None,
}),
config_flag: ConfigFlag::Path("Deno.jsonc".to_string()),
..Flags::default()
}
);

let r = flags_from_vec(svec![
"deno",
"lint",
"--plugins=./plugins/plugin1.js,/dev/plugins/plugin2.js",
]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Lint(LintFlags {
files: FileFlags {
include: vec![],
ignore: vec![],
},
fix: false,
rules: false,
maybe_rules_tags: None,
maybe_rules_include: None,
maybe_rules_exclude: None,
json: false,
compact: false,
watch: Default::default(),
maybe_plugins: Some(vec![
"./plugins/plugin1.js".to_string(),
"/dev/plugins/plugin2.js".to_string()
]),
}),
..Flags::default()
}
);
}

#[test]
Expand Down
9 changes: 9 additions & 0 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ pub struct LintOptions {
pub rules: LintRulesConfig,
pub files: FilePatterns,
pub fix: bool,
pub plugins: Vec<String>,
}

impl Default for LintOptions {
Expand All @@ -442,6 +443,7 @@ impl LintOptions {
rules: Default::default(),
files: FilePatterns::new_with_base(base),
fix: false,
plugins: vec![],
}
}

Expand All @@ -455,6 +457,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![]
},
}
}
}
Expand Down
Loading
Loading