mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
auto-fixed prefer-const violation
This commit is contained in:
@@ -19,7 +19,7 @@ export interface ItemDescription {
|
||||
}
|
||||
|
||||
export function assertCompletion(completions: CompletionList, expected: ItemDescription, document: TextDocument) {
|
||||
let matches = completions.items.filter(completion => {
|
||||
const matches = completions.items.filter(completion => {
|
||||
return completion.label === expected.label;
|
||||
});
|
||||
if (expected.notAvailable) {
|
||||
@@ -28,7 +28,7 @@ export function assertCompletion(completions: CompletionList, expected: ItemDesc
|
||||
}
|
||||
|
||||
assert.strictEqual(matches.length, 1, `${expected.label} should only existing once: Actual: ${completions.items.map(c => c.label).join(', ')}`);
|
||||
let match = matches[0];
|
||||
const match = matches[0];
|
||||
if (expected.documentation) {
|
||||
assert.strictEqual(match.documentation, expected.documentation);
|
||||
}
|
||||
@@ -47,28 +47,28 @@ export function assertCompletion(completions: CompletionList, expected: ItemDesc
|
||||
const testUri = 'test://test/test.html';
|
||||
|
||||
export async function testCompletionFor(value: string, expected: { count?: number; items?: ItemDescription[] }, uri = testUri, workspaceFolders?: WorkspaceFolder[]): Promise<void> {
|
||||
let offset = value.indexOf('|');
|
||||
const offset = value.indexOf('|');
|
||||
value = value.substr(0, offset) + value.substr(offset + 1);
|
||||
|
||||
let workspace = {
|
||||
const workspace = {
|
||||
settings: {},
|
||||
folders: workspaceFolders || [{ name: 'x', uri: uri.substr(0, uri.lastIndexOf('/')) }]
|
||||
};
|
||||
|
||||
let document = TextDocument.create(uri, 'html', 0, value);
|
||||
let position = document.positionAt(offset);
|
||||
const document = TextDocument.create(uri, 'html', 0, value);
|
||||
const position = document.positionAt(offset);
|
||||
const context = getDocumentContext(uri, workspace.folders);
|
||||
|
||||
const languageModes = getLanguageModes({ css: true, javascript: true }, workspace, ClientCapabilities.LATEST, getNodeFileFS());
|
||||
const mode = languageModes.getModeAtPosition(document, position)!;
|
||||
|
||||
let list = await mode.doComplete!(document, position, context);
|
||||
const list = await mode.doComplete!(document, position, context);
|
||||
|
||||
if (expected.count) {
|
||||
assert.strictEqual(list.items.length, expected.count);
|
||||
}
|
||||
if (expected.items) {
|
||||
for (let item of expected.items) {
|
||||
for (const item of expected.items) {
|
||||
assertCompletion(list, item, document);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ suite('HTML Document Context', () => {
|
||||
const docURI = 'file:///users/test/folder/test.html';
|
||||
const rootFolders = [{ name: '', uri: 'file:///users/test/' }];
|
||||
|
||||
let context = getDocumentContext(docURI, rootFolders);
|
||||
const context = getDocumentContext(docURI, rootFolders);
|
||||
assert.strictEqual(context.resolveReference('/', docURI), 'file:///users/test/');
|
||||
assert.strictEqual(context.resolveReference('/message.html', docURI), 'file:///users/test/message.html');
|
||||
assert.strictEqual(context.resolveReference('message.html', docURI), 'file:///users/test/folder/message.html');
|
||||
|
||||
@@ -15,7 +15,7 @@ import { getNodeFileFS } from '../node/nodeFs';
|
||||
suite('HTML Embedded Formatting', () => {
|
||||
|
||||
async function assertFormat(value: string, expected: string, options?: any, formatOptions?: FormattingOptions, message?: string): Promise<void> {
|
||||
let workspace = {
|
||||
const workspace = {
|
||||
settings: options,
|
||||
folders: [{ name: 'foo', uri: 'test://foo' }]
|
||||
};
|
||||
@@ -32,21 +32,21 @@ suite('HTML Embedded Formatting', () => {
|
||||
rangeStartOffset = 0;
|
||||
rangeEndOffset = value.length;
|
||||
}
|
||||
let document = TextDocument.create('test://test/test.html', 'html', 0, value);
|
||||
let range = Range.create(document.positionAt(rangeStartOffset), document.positionAt(rangeEndOffset));
|
||||
const document = TextDocument.create('test://test/test.html', 'html', 0, value);
|
||||
const range = Range.create(document.positionAt(rangeStartOffset), document.positionAt(rangeEndOffset));
|
||||
if (!formatOptions) {
|
||||
formatOptions = FormattingOptions.create(2, true);
|
||||
}
|
||||
|
||||
let result = await format(languageModes, document, range, formatOptions, undefined, { css: true, javascript: true });
|
||||
const result = await format(languageModes, document, range, formatOptions, undefined, { css: true, javascript: true });
|
||||
|
||||
let actual = TextDocument.applyEdits(document, result);
|
||||
const actual = TextDocument.applyEdits(document, result);
|
||||
assert.strictEqual(actual, expected, message);
|
||||
}
|
||||
|
||||
async function assertFormatWithFixture(fixtureName: string, expectedPath: string, options?: any, formatOptions?: FormattingOptions): Promise<void> {
|
||||
let input = fs.readFileSync(path.join(__dirname, '..', '..', 'src', 'test', 'fixtures', 'inputs', fixtureName)).toString().replace(/\r\n/mg, '\n');
|
||||
let expected = fs.readFileSync(path.join(__dirname, '..', '..', 'src', 'test', 'fixtures', 'expected', expectedPath)).toString().replace(/\r\n/mg, '\n');
|
||||
const input = fs.readFileSync(path.join(__dirname, '..', '..', 'src', 'test', 'fixtures', 'inputs', fixtureName)).toString().replace(/\r\n/mg, '\n');
|
||||
const expected = fs.readFileSync(path.join(__dirname, '..', '..', 'src', 'test', 'fixtures', 'expected', expectedPath)).toString().replace(/\r\n/mg, '\n');
|
||||
await assertFormat(input, expected, options, formatOptions, expectedPath);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ suite('HTML Embedded Formatting', () => {
|
||||
});
|
||||
|
||||
test('EndWithNewline', async () => {
|
||||
let options = {
|
||||
const options = {
|
||||
html: {
|
||||
format: {
|
||||
endWithNewline: true
|
||||
@@ -160,7 +160,7 @@ suite('HTML Embedded Formatting', () => {
|
||||
);
|
||||
});
|
||||
test('#58435', async () => {
|
||||
let options = {
|
||||
const options = {
|
||||
html: {
|
||||
format: {
|
||||
contentUnformatted: 'textarea'
|
||||
|
||||
@@ -15,7 +15,7 @@ async function assertRanges(content: string, expected: (number | string)[][]): P
|
||||
const offset = content.indexOf('|');
|
||||
content = content.substr(0, offset) + content.substr(offset + 1);
|
||||
|
||||
let workspace = {
|
||||
const workspace = {
|
||||
settings: {},
|
||||
folders: [{ name: 'foo', uri: 'test://foo' }]
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ async function assertTokens(lines: string[], expected: ExpectedToken[], ranges?:
|
||||
const legend = semanticTokensProvider.legend;
|
||||
const actual = await semanticTokensProvider.getSemanticTokens(document, ranges);
|
||||
|
||||
let actualRanges = [];
|
||||
const actualRanges = [];
|
||||
let lastLine = 0;
|
||||
let lastCharacter = 0;
|
||||
for (let i = 0; i < actual.length; i += 5) {
|
||||
|
||||
Reference in New Issue
Block a user