auto-fixed prefer-const violation

This commit is contained in:
Johannes
2022-06-08 17:49:21 +02:00
parent aa23a0dbb7
commit 0656d21d11
862 changed files with 6489 additions and 6489 deletions

View File

@@ -19,13 +19,13 @@ export interface ItemDescription {
suite('Completions', () => {
let assertCompletion = function (completions: CompletionList, expected: ItemDescription, document: TextDocument, _offset: number) {
let matches = completions.items.filter(completion => {
const assertCompletion = function (completions: CompletionList, expected: ItemDescription, document: TextDocument, _offset: number) {
const matches = completions.items.filter(completion => {
return completion.label === expected.label;
});
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.resultText && TextEdit.is(match.textEdit)) {
assert.strictEqual(TextDocument.applyEdits(document, [match.textEdit]), expected.resultText);
}
@@ -47,21 +47,21 @@ suite('Completions', () => {
const context = getDocumentContext(testUri, workspaceFolders);
const stylesheet = cssLanguageService.parseStylesheet(document);
let list = await cssLanguageService.doComplete2(document, position, stylesheet, context);
const list = await cssLanguageService.doComplete2(document, position, stylesheet, 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, offset);
}
}
}
test('CSS url() Path completion', async function () {
let testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
await assertCompletions('html { background-image: url("./|")', {
items: [
@@ -119,8 +119,8 @@ suite('Completions', () => {
});
test('CSS url() Path Completion - Unquoted url', async function () {
let testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
await assertCompletions('html { background-image: url(./|)', {
items: [
@@ -148,8 +148,8 @@ suite('Completions', () => {
});
test('CSS @import Path completion', async function () {
let testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
await assertCompletions(`@import './|'`, {
items: [
@@ -171,8 +171,8 @@ suite('Completions', () => {
* For SCSS, `@import 'foo';` can be used for importing partial file `_foo.scss`
*/
test('SCSS @import Path completion', async function () {
let testCSSUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
const testCSSUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
/**
* We are in a CSS file, so no special treatment for SCSS partial files
@@ -184,7 +184,7 @@ suite('Completions', () => {
]
}, testCSSUri, folders);
let testSCSSUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/scss/main.scss')).toString();
const testSCSSUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/scss/main.scss')).toString();
await assertCompletions(`@import './|'`, {
items: [
{ label: '_foo.scss', resultText: `@import './foo'` }
@@ -193,8 +193,8 @@ suite('Completions', () => {
});
test('Completion should ignore files/folders starting with dot', async function () {
let testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
const testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
const folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
await assertCompletions('html { background-image: url("../|")', {
count: 4

View File

@@ -21,13 +21,13 @@ export interface ItemDescription {
suite('Links', () => {
const cssLanguageService = getCSSLanguageService({ fileSystemProvider: getNodeFSRequestService() });
let assertLink = function (links: DocumentLink[], expected: ItemDescription, document: TextDocument) {
let matches = links.filter(link => {
const assertLink = function (links: DocumentLink[], expected: ItemDescription, document: TextDocument) {
const matches = links.filter(link => {
return document.offsetAt(link.range.start) === expected.offset;
});
assert.strictEqual(matches.length, 1, `${expected.offset} should only existing once: Actual: ${links.map(l => document.offsetAt(l.range.start)).join(', ')}`);
let match = matches[0];
const match = matches[0];
assert.strictEqual(document.getText(match.range), expected.value);
assert.strictEqual(match.target, expected.target);
};
@@ -45,11 +45,11 @@ suite('Links', () => {
const context = getDocumentContext(testUri, workspaceFolders);
const stylesheet = cssLanguageService.parseStylesheet(document);
let links = await cssLanguageService.findDocumentLinks2(document, stylesheet, context)!;
const links = await cssLanguageService.findDocumentLinks2(document, stylesheet, context)!;
assert.strictEqual(links.length, expected.length);
for (let item of expected) {
for (const item of expected) {
assertLink(links, item, document);
}
}
@@ -60,8 +60,8 @@ suite('Links', () => {
test('url links', async function () {
let testUri = getTestResource('about.css');
let folders = [{ name: 'x', uri: getTestResource('') }];
const testUri = getTestResource('about.css');
const folders = [{ name: 'x', uri: getTestResource('') }];
await assertLinks('html { background-image: url("hello.html|")',
[{ offset: 29, value: '"hello.html"', target: getTestResource('hello.html') }], testUri, folders
@@ -70,8 +70,8 @@ suite('Links', () => {
test('node module resolving', async function () {
let testUri = getTestResource('about.css');
let folders = [{ name: 'x', uri: getTestResource('') }];
const testUri = getTestResource('about.css');
const folders = [{ name: 'x', uri: getTestResource('') }];
await assertLinks('html { background-image: url("~foo/hello.html|")',
[{ offset: 29, value: '"~foo/hello.html"', target: getTestResource('node_modules/foo/hello.html') }], testUri, folders
@@ -80,8 +80,8 @@ suite('Links', () => {
test('node module subfolder resolving', async function () {
let testUri = getTestResource('subdir/about.css');
let folders = [{ name: 'x', uri: getTestResource('') }];
const testUri = getTestResource('subdir/about.css');
const folders = [{ name: 'x', uri: getTestResource('') }];
await assertLinks('html { background-image: url("~foo/hello.html|")',
[{ offset: 29, value: '"~foo/hello.html"', target: getTestResource('node_modules/foo/hello.html') }], testUri, folders