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 JavaScript plugin support #27203

Merged
merged 188 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 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
c831535
revert selector changes
bartlomieju Dec 21, 2024
66f22d8
fix the plugin
bartlomieju Dec 22, 2024
8479e95
update a todo
bartlomieju Dec 22, 2024
6d03baf
move ops
bartlomieju Dec 22, 2024
06ddb57
remove dead code
bartlomieju Dec 22, 2024
a446c89
remove --plugins flag support for now
bartlomieju Dec 22, 2024
3bea4cf
load plugins relative to the config file
bartlomieju Dec 22, 2024
71c82e4
run jsr plugins
bartlomieju Dec 22, 2024
46db6dd
Merge branch 'main' into lint_plugins
bartlomieju Dec 23, 2024
a6d1032
remove duplicate types
bartlomieju Dec 23, 2024
fdea4ea
type
bartlomieju Dec 23, 2024
a2bacbb
remove integration tests for now, we have unit tests for that
bartlomieju Dec 23, 2024
7be95bb
revert types change
bartlomieju Dec 23, 2024
0a28ac6
revert most of typings for now
bartlomieju Dec 24, 2024
0e8457d
simplify plugin loading
bartlomieju Dec 24, 2024
e6d0a6f
abstract away running plugins
bartlomieju Dec 24, 2024
f6efc9f
plugins are run inside CliLinter now
bartlomieju Dec 24, 2024
f55dd0d
wire up in the lsp
bartlomieju Dec 24, 2024
05a89f5
add PluginLogger, finally works in the LSP
bartlomieju Dec 25, 2024
c1e3357
add CancellationToken, but not wired up yet
bartlomieju Dec 26, 2024
f8e8f25
smaller diff
bartlomieju Dec 26, 2024
1a0a61d
cleanup
bartlomieju Dec 26, 2024
2d7ef06
revert
bartlomieju Dec 26, 2024
46e191c
remove debug logs
bartlomieju Dec 26, 2024
47178ef
lint
bartlomieju Dec 26, 2024
df54f58
use static strings
bartlomieju Dec 26, 2024
f283a0f
put fns into Rc
bartlomieju Dec 26, 2024
c3ac603
renames
bartlomieju Dec 26, 2024
a6d1f11
add support for hint
bartlomieju Dec 26, 2024
554bce9
Merge branch 'main' into lint_plugins
bartlomieju Jan 2, 2025
321e37b
feat: support js lint plugins fixes
marvinhagemeister Jan 2, 2025
2edd309
update for deno_lint changes
bartlomieju Jan 2, 2025
9685d71
use git deno_lint
bartlomieju Jan 2, 2025
adc25f8
feat: support excluding rules from lint plugins
marvinhagemeister Jan 3, 2025
b85974b
feat: add missing fixer methods
marvinhagemeister Jan 3, 2025
6cf3a27
fix: missing argument
marvinhagemeister Jan 3, 2025
0c1f93e
chore: remove cancellation branch
marvinhagemeister Jan 3, 2025
b972fc9
fix: add missing null check
marvinhagemeister Jan 3, 2025
9124e0a
chore: support more nodes
marvinhagemeister Jan 3, 2025
5af9453
testing helpers
bartlomieju Jan 3, 2025
ebb6b60
lint
bartlomieju Jan 3, 2025
7b3cdf1
wire up CancellationToken
bartlomieju Jan 3, 2025
37207e5
Merge branch 'main' into lint_plugins
bartlomieju Jan 6, 2025
64df2ce
revert changes to permissions
bartlomieju Jan 6, 2025
08482b0
lint
bartlomieju Jan 6, 2025
ad41ab7
foo
bartlomieju Jan 6, 2025
1f9a5c1
use structs instead
bartlomieju Jan 6, 2025
f7051e2
install all plugins in one go
bartlomieju Jan 6, 2025
ec745bd
Merge branch 'main' into lint_plugins
bartlomieju Jan 7, 2025
2fddd68
lint
bartlomieju Jan 7, 2025
f7b5ee2
run in tc_scope
bartlomieju Jan 9, 2025
900ef00
fix print functions
bartlomieju Jan 9, 2025
0db8db2
add todos
bartlomieju Jan 9, 2025
807cf19
Merge branch 'main' into lint_plugins
bartlomieju Jan 9, 2025
89af19d
fix after merge
bartlomieju Jan 9, 2025
714ed55
show errors with cause raised in JS
bartlomieju Jan 10, 2025
31473ca
validate range
bartlomieju Jan 10, 2025
ebaf18e
fix printer
bartlomieju Jan 10, 2025
0486303
lsp
bartlomieju Jan 10, 2025
aa145fd
log -> debug
bartlomieju Jan 10, 2025
67f7757
Merge branch 'main' into lint_plugins
bartlomieju Jan 10, 2025
cb638db
maybe cleanup
bartlomieju Jan 10, 2025
e56e7a2
add an error
bartlomieju Jan 12, 2025
a8c647e
Merge branch 'main' into lint_plugins
bartlomieju Jan 14, 2025
1b7ed4d
lint
bartlomieju Jan 14, 2025
9b36c6f
Merge branch 'main' into lint_plugins
bartlomieju Jan 26, 2025
278bfd0
Merge remote-tracking branch 'upstream/main' into lint_plugins
bartlomieju Jan 27, 2025
0a46741
Merge branch 'main' into lint_plugins
bartlomieju Jan 28, 2025
4d3aa3f
lint
bartlomieju Jan 28, 2025
008c789
bump deno_lint
bartlomieju Jan 28, 2025
532f756
Merge branch 'main' into lint_plugins
bartlomieju Jan 28, 2025
92876ea
Merge branch 'main' into lint_plugins
bartlomieju Jan 30, 2025
b1bfea6
add some comments in JSDoc
bartlomieju Jan 30, 2025
bf9e449
more JSDoc fixes
bartlomieju Jan 30, 2025
b3ddde1
simplify types
bartlomieju Jan 30, 2025
46e150d
more types
bartlomieju Jan 30, 2025
b3d0b0e
jsdoc my old friend
bartlomieju Jan 30, 2025
97d8ae2
further fixes
bartlomieju Jan 30, 2025
43fff85
fix dts
bartlomieju Jan 30, 2025
9782f41
Merge branch 'main' into lint_plugins
bartlomieju Jan 31, 2025
fb0fe35
fix lsp tests
bartlomieju Jan 31, 2025
d71ff4e
fix unit tests
bartlomieju Jan 31, 2025
843e8eb
should work now
bartlomieju Jan 31, 2025
418e264
fix again
bartlomieju Jan 31, 2025
09fbea1
integration tests should be passing now
bartlomieju Jan 31, 2025
142bac0
schema file test update
bartlomieju Jan 31, 2025
85099a9
Merge branch 'main' into lint_plugins
bartlomieju Jan 31, 2025
26555b4
Merge branch 'main' into lint_plugins
bartlomieju Jan 31, 2025
e5b57f6
review first pass
bartlomieju Jan 31, 2025
4a9c1d6
compute plugins when resolving options
bartlomieju Jan 31, 2025
69bc80f
Merge branch 'main' into lint_plugins
dsherret Feb 4, 2025
ce058ed
Fix ranges in tests
dsherret Feb 4, 2025
24b5976
remove top level test folder
dsherret Feb 4, 2025
9d2ccda
make js ranges utf16 and better error handling
dsherret Feb 4, 2025
554586f
stricter validation on plugin name
dsherret Feb 5, 2025
99d41a2
remove lock
dsherret Feb 5, 2025
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
8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ deno_doc = { version = "=0.164.0", features = ["rust", "comrak"] }
deno_error.workspace = true
deno_graph = { version = "=0.87.2" }
deno_lib.workspace = true
deno_lint = { version = "0.70.0" }
deno_lint = { version = "0.71.0" }
deno_lockfile.workspace = true
deno_media_type = { workspace = true, features = ["data_url", "decoding", "module_specifier"] }
deno_npm.workspace = true
Expand Down
1 change: 1 addition & 0 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ impl DenoSubcommand {
| Self::Jupyter(_)
| Self::Repl(_)
| Self::Bench(_)
| Self::Lint(_)
| Self::Lsp
)
}
Expand Down
42 changes: 32 additions & 10 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ pub struct LintOptions {
pub rules: LintRulesConfig,
pub files: FilePatterns,
pub fix: bool,
pub plugins: Vec<Url>,
}

impl Default for LintOptions {
Expand All @@ -380,20 +381,41 @@ impl LintOptions {
rules: Default::default(),
files: FilePatterns::new_with_base(base),
fix: false,
plugins: vec![],
}
}

pub fn resolve(lint_config: LintConfig, lint_flags: &LintFlags) -> Self {
Self {
pub fn resolve(
dir_path: PathBuf,
lint_config: LintConfig,
lint_flags: &LintFlags,
) -> Result<Self, AnyError> {
let rules = resolve_lint_rules_options(
lint_config.options.rules,
lint_flags.maybe_rules_tags.clone(),
lint_flags.maybe_rules_include.clone(),
lint_flags.maybe_rules_exclude.clone(),
);

let plugins = {
let plugin_specifiers = lint_config.options.plugins;
let mut plugins = Vec::with_capacity(plugin_specifiers.len());
for plugin in &plugin_specifiers {
// TODO(bartlomieju): handle import-mapped specifiers
let url = resolve_url_or_path(plugin, &dir_path)?;
plugins.push(url);
}
// ensure stability for hasher
plugins.sort_unstable();
plugins
};

Ok(Self {
files: lint_config.files,
rules: resolve_lint_rules_options(
lint_config.options.rules,
lint_flags.maybe_rules_tags.clone(),
lint_flags.maybe_rules_include.clone(),
lint_flags.maybe_rules_exclude.clone(),
),
rules,
fix: lint_flags.fix,
}
plugins,
})
}
}

Expand Down Expand Up @@ -759,7 +781,7 @@ impl CliOptions {
.resolve_lint_config_for_members(&cli_arg_patterns)?;
let mut result = Vec::with_capacity(member_configs.len());
for (ctx, config) in member_configs {
let options = LintOptions::resolve(config, lint_flags);
let options = LintOptions::resolve(ctx.dir_path(), config, lint_flags)?;
result.push((ctx, options));
}
Ok(result)
Expand Down
Loading