-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
base: main
Are you sure you want to change the base?
Conversation
let diagnostic_range = SourceRange::new(start_pos + start, start_pos + end); | ||
if !source_range.contains(&diagnostic_range) { | ||
return Err(LintReportError::DiagnosticIncorrectRange { | ||
// JS uses 1-based indexes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it 1-based? Can we change this to 0-based?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU we wanted to use 1-based to mimic ESLint API that also uses 1-based offsets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should just do zero if we're not going for backwards compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is what eslint does: https://eslint.org/docs/latest/extend/custom-rules#reporting-problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see this is just for the error shown to the user. I misunderstood. Probalby we should show line and column numbers here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I show line and column number here if the passed range is not within the SourceRange
?
@@ -258,3 +317,87 @@ fn apply_lint_fixes( | |||
deno_ast::apply_text_changes(text_info.text_str(), quick_fixes); | |||
Some(new_text) | |||
} | |||
|
|||
fn run_plugins( | |||
plugin_runner: Arc<Mutex<PluginHostProxy>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should bury this lock instead of passing it around?
let diagnostic_range = SourceRange::new(start_pos + start, start_pos + end); | ||
if !source_range.contains(&diagnostic_range) { | ||
return Err(LintReportError::DiagnosticIncorrectRange { | ||
// JS uses 1-based indexes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should just do zero if we're not going for backwards compatibility?
Nothing to see here yet :))