-
-
Notifications
You must be signed in to change notification settings - Fork 82
feat(oxc): lint results inspecteor #432
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
Draft
yuyinws
wants to merge
6
commits into
main
Choose a base branch
from
chore/clean-code
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4f71f56
fix(oxc): start standalone dev server directly
yuyinws 8ed9bdc
refactor(oxc): remove lint log cli
yuyinws 54aef9f
refactor(oxc): use cac for cli
yuyinws 526adf2
chore: clean code
yuyinws 1163c49
feat: reorganize page structure
yuyinws 4583b98
feat: lint inspector
yuyinws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| outline: deep | ||
| --- | ||
| # OXDT0001: Failed to Create Lint Result | ||
|
|
||
| ## Message | ||
| > Failed to create a lint result: `{reason}` | ||
|
|
||
| ## Cause | ||
| Oxlint could not start, its output could not be parsed, or the lint result could not be written to the project directory. | ||
|
|
||
| ## Example | ||
| Clicking `Run Lint` when oxlint is not installed in the project. | ||
|
|
||
| ## Fix | ||
| Ensure oxlint is installed, its configuration is valid, and the project directory is writable. | ||
|
|
||
| ## Source | ||
| - [`packages/oxc/src/node/rpc/functions/oxlint-run.ts`](https://github.com/vitejs/devtools/blob/main/packages/oxc/src/node/rpc/functions/oxlint-run.ts) — Runs oxlint and saves the lint result. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| outline: deep | ||
| --- | ||
| # OXDT0002: Invalid Lint Result ID | ||
|
|
||
| ## Message | ||
| > Invalid lint result ID "`{resultId}`". | ||
|
|
||
| ## Cause | ||
| A non-numeric ID was provided when reading or deleting a lint result. | ||
|
|
||
| ## Example | ||
| Passing `../other-directory` as the result ID in an RPC call. | ||
|
|
||
| ## Fix | ||
| Use a numeric ID shown in the lint result list. | ||
|
|
||
| ## Source | ||
| - [`packages/oxc/src/node/utils/lint-results-manager.ts`](https://github.com/vitejs/devtools/blob/main/packages/oxc/src/node/utils/lint-results-manager.ts) — Validates the result ID before file operations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| outline: deep | ||
| --- | ||
| # OXDT0003: Failed to Delete Lint Result | ||
|
|
||
| ## Message | ||
| > Failed to delete lint result "`{resultId}`": `{reason}` | ||
|
|
||
| ## Cause | ||
| The lint result does not exist, or the project directory does not allow the file to be deleted. | ||
|
|
||
| ## Example | ||
| Deleting a lint result that another process has already removed. | ||
|
|
||
| ## Fix | ||
| Refresh the lint result list and ensure the project directory is writable. | ||
|
|
||
| ## Source | ||
| - [`packages/oxc/src/node/rpc/functions/oxlint-delete-result.ts`](https://github.com/vitejs/devtools/blob/main/packages/oxc/src/node/rpc/functions/oxlint-delete-result.ts) — Deletes the local lint result. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
packages/oxc/src/app/components/LintResultDetailsLoader.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| <script setup lang="ts"> | ||
| import DisplayCloseButton from '@vitejs/devtools-ui/components/Display/DisplayCloseButton.vue' | ||
| import VisualEmptyState from '@vitejs/devtools-ui/components/Visual/VisualEmptyState.vue' | ||
| import { useAsyncState, useDebounceFn } from '@vueuse/core' | ||
| import { computed, ref, watch } from 'vue' | ||
| import { isMatch } from 'picomatch' | ||
| import { useRpc } from '#imports' | ||
|
|
||
| const props = defineProps<{ | ||
| resultId: string | ||
| }>() | ||
|
|
||
| const emit = defineEmits<{ | ||
| close: [] | ||
| }>() | ||
|
|
||
| const rpc = useRpc() | ||
| const { state: lintResult, isLoading } = useAsyncState( | ||
| () => rpc.value.call('devtools-oxc:get-lint-result', { resultId: props.resultId }), | ||
| null, | ||
| ) | ||
|
|
||
| const showEmpty = computed(() => lintResult.value?.logs.files.length === 0) | ||
|
|
||
| const totalIssues = computed(() => { | ||
| if (!lintResult.value?.logs) return 0 | ||
|
|
||
| return lintResult.value.logs.files.reduce( | ||
| (sum, file) => sum + file.lines.reduce((lineSum, line) => lineSum + line.messages.length, 0), | ||
| 0, | ||
| ) | ||
| }) | ||
|
|
||
| const showSummary = computed(() => !!lintResult.value?.meta.summary) | ||
| const search = ref('') | ||
| const debouncedSearch = ref('') | ||
| const debouncedUpdateSearch = useDebounceFn((value: string) => { | ||
| debouncedSearch.value = value | ||
| }, 300) | ||
|
|
||
| function resetSearch() { | ||
| search.value = '' | ||
| debouncedSearch.value = '' | ||
| } | ||
|
|
||
| watch(search, value => debouncedUpdateSearch(value), { immediate: true }) | ||
|
|
||
| const filteredFiles = computed(() => { | ||
| if (!lintResult.value?.logs?.files) return [] | ||
|
|
||
| const searchTerm = debouncedSearch.value.trim() | ||
| if (!searchTerm) return lintResult.value.logs.files | ||
|
|
||
| try { | ||
| return lintResult.value.logs.files.filter(file => | ||
| isMatch(file.filename, searchTerm, { contains: true }), | ||
| ) | ||
| } catch { | ||
| return lintResult.value.logs.files.filter(file => file.filename.includes(searchTerm)) | ||
| } | ||
| }) | ||
|
|
||
| const showFiles = computed(() => filteredFiles.value.length > 0) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div relative h-full w-full> | ||
| <DisplayCloseButton absolute right-1 top-1 z-panel-content bg-glass @click="emit('close')" /> | ||
|
|
||
| <VisualLoading v-if="isLoading" text="Loading lint result..." /> | ||
| <div v-else h-full of-auto flex="~ col" gap-4 p7> | ||
| <SummaryCard | ||
| v-if="showSummary && lintResult?.meta.summary" | ||
| :summary="lintResult.meta.summary" | ||
| :total-issues="totalIssues" | ||
| :version="lintResult.meta.version" | ||
| :config="lintResult.logs.config" | ||
| :timestamp="lintResult.meta.timestamp" | ||
| /> | ||
|
|
||
| <Search v-model="search" /> | ||
|
|
||
| <VisualEmptyState | ||
| v-if="showEmpty" | ||
| icon="i-twemoji:partying-face" | ||
| description="Congratulations! There is no oxlint issues." | ||
| /> | ||
|
|
||
| <template v-else> | ||
| <div v-if="showFiles" grid="~ cols-1 lg:cols-2" gap-4> | ||
| <FileCard v-for="file in filteredFiles" :key="file.filename" :file="file" /> | ||
| </div> | ||
|
|
||
| <VisualEmptyState | ||
| v-else | ||
| icon="i-ph-file-minus-light" | ||
| description="No files found." | ||
| border="~ base rounded-lg dashed" | ||
| > | ||
| <button btn-action @click="resetSearch">Reset search</button> | ||
| </VisualEmptyState> | ||
| </template> | ||
| </div> | ||
| </div> | ||
| </template> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 am actually ok with keeping gunshi for a bit of diversity
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.
cac is more lightweight than gunshi. Given that the current CLI is relatively simple, I think it's a better fit for now. We can consider switching to gunshi if the CLI grows more complex in the future.