Resharper:如何抑制 CSS 黑客攻击导致的检查错误?

发布于 2024-12-23 06:02:57 字数 576 浏览 2 评论 0原文

有问题的代码是这样的:

/*fix ie transform offset*/
.adAffiliate.adDeclarationPosition-Right .adAffiliate-header
{
   *left: -20px    !important; /* IE 7 (IE6 also uses this, so put it first) */
   _left: -20px    !important; /* IE 6 */
    left: -20px\0/ !important; /* IE 8-9 */
}

在此处输入图像描述

如您所见,前两行被识别为 CSS hack。它们不会出现在解决方案错误列表中。我只想删除解决方案错误列表中出现的第三行。 不幸的是,“忽略错误”在 VS 重新启动时不起作用。有没有办法抑制这个特定的错误?也许是一个特殊的“忽略评论”?

这是我在数千个 LOC 中唯一的 CSS hack。我只是这次没有找到出路。我对这个黑客的存在感到满意。

The code in question is this:

/*fix ie transform offset*/
.adAffiliate.adDeclarationPosition-Right .adAffiliate-header
{
   *left: -20px    !important; /* IE 7 (IE6 also uses this, so put it first) */
   _left: -20px    !important; /* IE 6 */
    left: -20px\0/ !important; /* IE 8-9 */
}

enter image description here

As you can see, the first two lines get recognized as CSS hacks. They do not appear in the solution error list. I just want to get rid of the 3rd line appearing in the solution error list. Unfortunately, "ignore error" does not work across VS restarts. Is there a way to suppress this particular error? Maybe a special "ignore comment"?

This is the only CSS hack I have in 1000s of LOC. I just did not find a way out this time. And I am ok with this hack being there.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天邊彩虹 2024-12-30 06:02:57

只需在错误突出显示时按Alt+Enter,选择检查选项...并将严重性设置为警告,即可更改此类错误的严重性或更低。

这将迫使问题从解决方案中的错误工具窗口中消失,显然,该窗口仅显示错误级别的问题。请注意,检查严重性更改在 VS 重新启动后仍然存在。

当然,这个解决方案意味着,每当您的代码在其他地方碰巧遇到类似问题时,您将无法通过解决方案中的错误观察到它:您要么必须密切关注ReSharper 问题在代码编辑器中突出显示(无论如何,这是一个有用的习惯)或使用 ReSharper > 检查您的代码检查> 范围中的代码问题

Just change severity for this type of error by pressing Alt+Enter at the error highlighting, selecting Inspection options... and setting severity to Warning or lower.

This would force the issue to disappear from the Errors in Solution tool window which, obviously, shows only error-level issues. Mind you, inspection severity changes persist across VS restarts.

Of course, this solution implies that whenever your code happens to have a similar issue somewhere else, you won't be able to observe it through Errors in Solution: you'll either have to keep your eye on ReSharper issue highlighting in the code editor (a useful habit anyway) or inspect your code with ReSharper > Inspect > Code Issues in scope

以酷 2024-12-30 06:02:57

你称之为CSS hacks,我称之为无效CSS(验证器也这样做)。我建议使用 条件注释 包含的不同 css 文件。这是更多的工作,但它更干净。

You call it CSS hacks, I call it invalid CSS (and the validator does it too). I recommend to use different css files included by i.e. conditional comments. This is more work, but it is much cleaner.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文