-
-
Notifications
You must be signed in to change notification settings - Fork 470
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(linter): support lint vue files #1706
Conversation
Current dependencies on/for this PR: This stack of pull requests is managed by Graphite. |
66ddc97
to
2322730
Compare
} | ||
fn may_parser_special_extension<P: AsRef<Path>>(path: P) -> (Option<bool>, Option<Span>) { | ||
let default_ret = (None, None); | ||
let Ok(content) = std::fs::read_to_string(path.as_ref()) else { return default_ret }; |
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.
I don't really like here, it's means we need to read the content of Vue file twice. One here, another is in process_path
oxc/crates/oxc_linter/src/service.rs
Lines 142 to 153 in 2322730
let mut source_text = match fs::read_to_string(path) { | |
Ok(source_text) => source_text, | |
Err(e) => { | |
tx_error | |
.send(Some(( | |
path.to_path_buf(), | |
vec![Error::new(FailedToOpenFileError(path.to_path_buf(), e))], | |
))) | |
.unwrap(); | |
return; | |
} | |
}; |
How should I improve it? Where should I put SpecialLanguageVariantParser
in?😥
2322730
to
0aa3c2c
Compare
The architecture around this is a bit more involved I think. We can support Let's iterate on this instead of having a huge PR. |
0aa3c2c
to
ca824dc
Compare
CodSpeed Performance ReportMerging #1706 will improve performances by 5.9%Comparing Summary
Benchmarks breakdown
|
Eagerly awaiting this! 🙏 |
let attributes_text = | ||
Span::new(open_tag_start, open_tag_end).source_text(self.source_text); | ||
is_ts = attributes_text.contains(r#"lang="ts""#) | ||
|| attributes_text.contains("lang='ts'"); |
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.
I'm not very familiar with Vue, but I believe there might be another case here:
<script lang=ts>
let is_definition_file = file_name.ends_with(".d.ts") | ||
|| file_name.ends_with(".d.mts") | ||
|| file_name.ends_with(".d.cts"); | ||
|
||
let language = match extension { | ||
"js" | "mjs" | "cjs" | "jsx" => Language::JavaScript, | ||
"ts" | "mts" | "cts" | "tsx" => Language::TypeScript { is_definition_file }, | ||
"vue" => { |
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.
I'm prretty sure the same code will solve the case for svelte, as requested in #1770
- Svelte should use the same
<script lang="ts">
style
"vue" => { | |
"vue" | "svelte" => { |
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.
Thank you, I am planing to support svelte in another way.
Will continue work on #1814 |
vue support has been merged as a stack, see #1863 (comment) Feel free to join, test and improve it together. |
closes: #1238