Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
chore(website): [playground] use languageService for linting code#6806
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
a9028d51f872c2a655909fec541d0adaa65684833a6f897b5223b947403d8a1f49243d2b17752f04f533File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4,14 +4,15 @@ import { useEffect, useState } from 'react'; | ||
| import type { createTypeScriptSandbox } from '../../vendor/sandbox'; | ||
| import { createCompilerOptions } from '../lib/createCompilerOptions'; | ||
| import { createFileSystem } from '../linter/bridge'; | ||
| import { type CreateLinter, createLinter } from '../linter/createLinter'; | ||
| import type { PlaygroundSystem } from '../linter/types'; | ||
| import type { RuleDetails } from '../types'; | ||
| import { editorEmbedId } from './EditorEmbed'; | ||
| import { sandboxSingleton } from './loadSandbox'; | ||
| import type { CommonEditorProps } from './types'; | ||
| export interface SandboxServicesProps { | ||
| readonly onLoaded: ( | ||
| ruleDetails: RuleDetails[], | ||
| tsVersions: readonly string[], | ||
| @@ -23,7 +24,8 @@ export type SandboxInstance = ReturnType<typeof createTypeScriptSandbox>; | ||
| export interface SandboxServices { | ||
| sandboxInstance: SandboxInstance; | ||
| system: PlaygroundSystem; | ||
| webLinter: CreateLinter; | ||
| } | ||
| export const useSandboxServices = ( | ||
| @@ -67,22 +69,27 @@ export const useSandboxServices = ( | ||
| colorMode === 'dark' ? 'vs-dark' : 'vs-light', | ||
| ); | ||
| const system = createFileSystem(props, sandboxInstance.tsvfs); | ||
| const worker = await sandboxInstance.getWorkerProcess(); | ||
| if (worker.getLibFiles) { | ||
| const libs = await worker.getLibFiles(); | ||
| for (const [key, value] of Object.entries(libs)) { | ||
| system.writeFile('/' + key, value); | ||
| } | ||
| } | ||
| window.system =system; | ||
armano2 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| window.esquery = lintUtils.esquery; | ||
| const webLinter = createLinter( | ||
| system, | ||
| lintUtils, | ||
| sandboxInstance.tsvfs, | ||
| ); | ||
| onLoaded( | ||
| Array.from(webLinter.rules.values()), | ||
| Array.from( | ||
| new Set([...sandboxInstance.supportedVersions, window.ts.version]), | ||
| ) | ||
| @@ -91,8 +98,9 @@ export const useSandboxServices = ( | ||
| ); | ||
| setServices({ | ||
| system, | ||
| webLinter, | ||
| sandboxInstance, | ||
| }); | ||
| }) | ||
| .catch(setServices); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| export function createEventsBinder<T extends (...args: any[]) => void>(): { | ||
| trigger: (...args: Parameters<T>) => void; | ||
| register: (cb: T) => () => void; | ||
| } { | ||
| const events = new Set<T>(); | ||
| return { | ||
| trigger(...args: Parameters<T>): void { | ||
| events.forEach(cb => cb(...args)); | ||
| }, | ||
| register(cb: T): () => void { | ||
| events.add(cb); | ||
| return (): void => { | ||
| events.delete(cb); | ||
| }; | ||
| }, | ||
| }; | ||
| } |
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.