VSCode在字符串字面量中的/*之后将代码注释掉。我怎样才能禁用这个功能?

huangapple go评论68阅读模式
英文:

VSCode is commenting out code after /* in string literals. How can I disable this?

问题

VSCode 在我的 JS 文件中,从字符串文字中的部分 '/*' 开始注释掉了所有代码。

我不想要这种行为。

是否有人在使用 VSCode 时遇到类似的情况?

此文件的完整代码在这里:

import { json } from '@sveltejs/kit';

async function getPost() {
    let posts = [];

    const paths = import.meta.glob('/src/posts/*.md', { eager: true });

    for (const path in paths) {
        console.log(path);
    }

    return posts;
}

export async function GET() {
    const post = await getPost();
    return json(post);
}

我尝试在字符串文字中转义星号,但 prettier 自动修复了它。

'/src/posts/*.md' => /src/posts/*.md' (prettier 自动修复)
英文:

VSCode is commenting out all the code behind from the part '/*' in the string literal on my JS file.

VSCode在字符串字面量中的/*之后将代码注释掉。我怎样才能禁用这个功能?
I don't want this behaviour.

Is there anybody who experienced some similar things like this using VSCode?

Whole code of this file is here

import { json } from '@sveltejs/kit';

async function getPost() {
	let posts = [];

	const paths = import.meta.glob('/src/posts/*.md', { eager: true });

	for (const path in paths) {
		console.log(path);
	}

	return posts;
}

export async function GET() {
	const post = await getPost();
	return json(post);
}

I tried to escape the asterisk in the string literal but the prettier auto fixed it.

'/src/posts/\*.md' => /src/posts/*.md' (auto fixed by prettier)

答案1

得分: 1

我检查了在VS Code上安装的插件,并禁用了Babel JS和JSDoc插件。这有所帮助,问题似乎已解决。

英文:

I checked the plugins installed on VS Code and disabled Babel JS and JSDoc plugin.
It helped and it seems the problem is resolved.

huangapple
  • 本文由 发表于 2023年5月22日 09:32:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76302594.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定