Skip to content

Commit 33f723f

Browse files
Revert "chore(website): align file names to RuleTester requirements" (typescript-eslint#9327)
Revert "chore(website): align file names to RuleTester requirements (typescript-eslint#9271)" This reverts commit d28bcb6.
1 parent 8a178ed commit 33f723f

File tree

5 files changed

+8
-20
lines changed

5 files changed

+8
-20
lines changed

packages/website/src/components/editor/LoadedEditor.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ import {
1313
} from '../lib/jsonSchema';
1414
import { parseTSConfig, tryParseEslintModule } from '../lib/parseConfig';
1515
import type { LintCodeAction } from '../linter/utils';
16-
import {
17-
createFileName,
18-
parseLintResults,
19-
parseMarkers,
20-
} from '../linter/utils';
16+
import { parseLintResults, parseMarkers } from '../linter/utils';
2117
import type { TabType } from '../types';
2218
import { createProvideCodeActions } from './createProvideCodeActions';
2319
import type { CommonEditorProps } from './types';
@@ -93,7 +89,7 @@ export const LoadedEditor: React.FC<LoadedEditorProps> = ({
9389
}, [webLinter, sourceType]);
9490

9591
useEffect(() => {
96-
const newPath = createFileName(fileType);
92+
const newPath = `/input${fileType}`;
9793
if (tabs.code.uri.path !== newPath) {
9894
const code = tabs.code.getValue();
9995
const newModel = monaco.editor.createModel(
@@ -244,7 +240,7 @@ export const LoadedEditor: React.FC<LoadedEditorProps> = ({
244240
system.watchFile('/.eslintrc', filename => {
245241
onChange({ eslintrc: system.readFile(filename) });
246242
}),
247-
system.watchFile('/{file,react}.*', filename => {
243+
system.watchFile('/input.*', filename => {
248244
onChange({ code: system.readFile(filename) });
249245
}),
250246
];

packages/website/src/components/linter/bridge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type * as ts from 'typescript';
44
import { debounce } from '../lib/debounce';
55
import type { ConfigModel } from '../types';
66
import type { PlaygroundSystem } from './types';
7-
import { createFileName, getPathRegExp } from './utils';
7+
import { getPathRegExp } from './utils';
88

99
export function createFileSystem(
1010
config: Pick<ConfigModel, 'code' | 'eslintrc' | 'fileType' | 'tsconfig'>,
@@ -13,7 +13,7 @@ export function createFileSystem(
1313
const files = new Map<string, string>();
1414
files.set(`/.eslintrc`, config.eslintrc);
1515
files.set(`/tsconfig.json`, config.tsconfig);
16-
files.set(createFileName(config.fileType), config.code);
16+
files.set(`/input${config.fileType}`, config.code);
1717

1818
const fileWatcherCallbacks = new Map<RegExp, Set<ts.FileWatcherCallback>>();
1919

packages/website/src/components/linter/createLinter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ export function createLinter(
164164
};
165165

166166
const triggerLintAll = (): void => {
167-
system.searchFiles('/{file,react}.*').forEach(triggerLint);
167+
system.searchFiles('/input.*').forEach(triggerLint);
168168
};
169169

170-
system.watchFile('/{file,react}.*', triggerLint);
170+
system.watchFile('/input.*', triggerLint);
171171
system.watchFile('/.eslintrc', filename => {
172172
applyEslintConfig(filename);
173173
triggerLintAll();

packages/website/src/components/linter/createParser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type {
1010
UpdateModel,
1111
WebLinterModule,
1212
} from './types';
13-
import { createFileName } from './utils';
1413

1514
export function createParser(
1615
system: PlaygroundSystem,
@@ -44,7 +43,7 @@ export function createParser(
4443
text: string,
4544
options: ParserOptions = {},
4645
): Parser.ParseResult => {
47-
const filePath = options.filePath ?? createFileName('.ts');
46+
const filePath = options.filePath ?? '/input.ts';
4847

4948
// if text is empty use empty line to avoid error
5049
const code = text || '\n';

packages/website/src/components/linter/utils.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ export function createEditOperation(
4848
};
4949
}
5050

51-
/**
52-
* @see https://typescript-eslint.io/packages/rule-tester/#type-aware-testing
53-
*/
54-
export function createFileName(extension = '.ts'): string {
55-
return `/${extension.endsWith('sx') ? 'react' : 'file'}.${extension}`;
56-
}
57-
5851
function normalizeCode(code: Monaco.editor.IMarker['code']): {
5952
value: string;
6053
target?: string;

0 commit comments

Comments
 (0)