diff --git a/packages/website/src/components/editor/LoadedEditor.tsx b/packages/website/src/components/editor/LoadedEditor.tsx index da02b4e9352d..6dab67a39278 100644 --- a/packages/website/src/components/editor/LoadedEditor.tsx +++ b/packages/website/src/components/editor/LoadedEditor.tsx @@ -13,11 +13,7 @@ import { } from '../lib/jsonSchema'; import { parseTSConfig, tryParseEslintModule } from '../lib/parseConfig'; import type { LintCodeAction } from '../linter/utils'; -import { - createFileName, - parseLintResults, - parseMarkers, -} from '../linter/utils'; +import { parseLintResults, parseMarkers } from '../linter/utils'; import type { TabType } from '../types'; import { createProvideCodeActions } from './createProvideCodeActions'; import type { CommonEditorProps } from './types'; @@ -93,7 +89,7 @@ export const LoadedEditor: React.FC = ({ }, [webLinter, sourceType]); useEffect(() => { - const newPath = createFileName(fileType); + const newPath = `/input${fileType}`; if (tabs.code.uri.path !== newPath) { const code = tabs.code.getValue(); const newModel = monaco.editor.createModel( @@ -244,7 +240,7 @@ export const LoadedEditor: React.FC = ({ system.watchFile('/.eslintrc', filename => { onChange({ eslintrc: system.readFile(filename) }); }), - system.watchFile('/{file,react}.*', filename => { + system.watchFile('/input.*', filename => { onChange({ code: system.readFile(filename) }); }), ]; diff --git a/packages/website/src/components/linter/bridge.ts b/packages/website/src/components/linter/bridge.ts index ef5892837ac8..a553b7d7f283 100644 --- a/packages/website/src/components/linter/bridge.ts +++ b/packages/website/src/components/linter/bridge.ts @@ -4,7 +4,7 @@ import type * as ts from 'typescript'; import { debounce } from '../lib/debounce'; import type { ConfigModel } from '../types'; import type { PlaygroundSystem } from './types'; -import { createFileName, getPathRegExp } from './utils'; +import { getPathRegExp } from './utils'; export function createFileSystem( config: Pick, @@ -13,7 +13,7 @@ export function createFileSystem( const files = new Map(); files.set(`/.eslintrc`, config.eslintrc); files.set(`/tsconfig.json`, config.tsconfig); - files.set(createFileName(config.fileType), config.code); + files.set(`/input${config.fileType}`, config.code); const fileWatcherCallbacks = new Map>(); diff --git a/packages/website/src/components/linter/createLinter.ts b/packages/website/src/components/linter/createLinter.ts index 770e5fb429f7..9ce38ce032b3 100644 --- a/packages/website/src/components/linter/createLinter.ts +++ b/packages/website/src/components/linter/createLinter.ts @@ -164,10 +164,10 @@ export function createLinter( }; const triggerLintAll = (): void => { - system.searchFiles('/{file,react}.*').forEach(triggerLint); + system.searchFiles('/input.*').forEach(triggerLint); }; - system.watchFile('/{file,react}.*', triggerLint); + system.watchFile('/input.*', triggerLint); system.watchFile('/.eslintrc', filename => { applyEslintConfig(filename); triggerLintAll(); diff --git a/packages/website/src/components/linter/createParser.ts b/packages/website/src/components/linter/createParser.ts index 6848dea658c5..c8348c77da87 100644 --- a/packages/website/src/components/linter/createParser.ts +++ b/packages/website/src/components/linter/createParser.ts @@ -10,7 +10,6 @@ import type { UpdateModel, WebLinterModule, } from './types'; -import { createFileName } from './utils'; export function createParser( system: PlaygroundSystem, @@ -44,7 +43,7 @@ export function createParser( text: string, options: ParserOptions = {}, ): Parser.ParseResult => { - const filePath = options.filePath ?? createFileName('.ts'); + const filePath = options.filePath ?? '/input.ts'; // if text is empty use empty line to avoid error const code = text || '\n'; diff --git a/packages/website/src/components/linter/utils.ts b/packages/website/src/components/linter/utils.ts index ea99c7cfee1a..1d44a322bc4a 100644 --- a/packages/website/src/components/linter/utils.ts +++ b/packages/website/src/components/linter/utils.ts @@ -48,13 +48,6 @@ export function createEditOperation( }; } -/** - * @see https://typescript-eslint.io/packages/rule-tester/#type-aware-testing - */ -export function createFileName(extension = '.ts'): string { - return `/${extension.endsWith('sx') ? 'react' : 'file'}.${extension}`; -} - function normalizeCode(code: Monaco.editor.IMarker['code']): { value: string; target?: string;