[英]How to make Visual Studio stop “compiling” .js and .css files
I use Visual Studio as my editor for .css and .js files.. It REALLY SUCKS especially with .js files since it insists on indenting them in a very weird way, but I find it convenient that the first alt-tab is always the browser instead of another editor, and that ctrl-tab is always either the code file or the css/js. 我使用Visual Studio作为.css和.js文件的编辑器。它真的很糟糕,尤其是.js文件,因为它坚持以非常奇怪的方式缩进它们,但我发现第一个alt-tab始终是浏览器而不是另一个编辑器,并且ctrl-tab始终是代码文件或css / js。
Anyways, in all its radiant wisdom it decides to check them for syntax errors as well and every time I compile my project it gives several "errors" that push down the real errors of the compilation, so every time I make a syntax error in a code file I have to scroll down through all the js/css errors to see what's wrong. 无论如何,它的所有光芒四射的智慧决定检查它们的语法错误,每次我编译我的项目时它会产生几个“错误”,从而压低编译的真实错误,所以每次我在一个语法错误中代码文件我必须向下滚动浏览所有js / css错误,看看有什么问题。
Examples of such errors (that aren't really errors) are: 此类错误(不是真正的错误)的示例如下:
Error 7 Validation (CSS 2.1): 'text-rendering' is not a known CSS property name. Error 8 Validation (CSS 2.1): 'opacity' is not a known CSS property name.
The situation also got much worse recently, since it now keeps parsing a .js file as a .css file for some reason, so I get errors such as: 最近情况也变得更糟,因为它现在因为某种原因将.js文件解析为.css文件,所以我得到如下错误:
Error 1 Unexpected character sequence. Expected a selector for the style rule. E:\Dev\anacletus\Static\set_focus.js 2 Error 2 Unexpected character sequence. Expected a property name for the " : " declaration. E:\Dev\anacletus\Static\set_focus.js 3 Error 3 Validation (CSS 2.1): 'set-focus' is not a known CSS property name. E:\Dev\anacletus\Static\set_focus.js 3
I even deleted that particular file from the solution (it's not there anymore anywhere), but it keeps parsing it anyway. 我甚至从解决方案中删除了该特定文件(它不再存在于任何地方),但无论如何它仍在解析它。
In short, how can I disable this feature? 简而言之,我该如何禁用此功能?
Enter the options through 输入选项
Tools > Options
工具>选项
If it isn't checked, check the "Show all settings" box at the bottom of that window. 如果未选中,请选中该窗口底部的“显示所有设置”框。
In the tree to the left, choose: 在左侧的树中,选择:
Text Editor > CSS > CSS Specific
文本编辑器> CSS> CSS特定
Uncheck "Detect Errors" . 取消选中“检测错误” 。 Then, choose:
然后,选择:
Text Editor > JScript > Miscellaneous
文本编辑器> JScript>杂项
Uncheck "Show syntax errors" . 取消选中“显示语法错误” 。
You can also change how it indents each type of code too, in the various settings in those "Text Editor" sub-options. 您还可以在“文本编辑器”子选项的各种设置中更改缩进每种类型代码的方式。
I know, this question is old, but I have an update (for Visual Studio 2010): 我知道,这个问题很老,但我有一个更新(对于Visual Studio 2010):
The accepted solution has a big disadvantage: It disables all syntax checking of CSS and JScript. 接受的解决方案有一个很大的缺点:它禁用CSS和JScript的所有语法检查。 If you still want to have meaningful warnings , you can do the following workaround.
如果您仍希望获得有意义的警告 ,则可以执行以下解决方法。 It will treat errors as warnings , and it will do css validation on css V3.0 level rather than on (old) css V2.1:
它会将错误视为警告 ,它将在css V3.0级别而不是(旧)css V2.1上进行css验证:
Program Files
) Program Files
)
C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Packages\\1033\\schemas\\CSS
C:\\ Program Files(x86)\\ Microsoft Visual Studio 10.0 \\ Common7 \\ Packages \\ 1033 \\ schemas \\ CSS
CSS21.xml
for safety reasons CSS21.xml
CSS21.xml
by the file CSS30.xml
(in the same directory) CSS30.xml
覆盖CSS21.xml
(在同一目录下) (Note that the Style Sheet toolbar only allows to enable CSS 3.0 checking for css files, not for HTML. Hence, this fix is needed if you want to keep syntax checking) (请注意,样式表工具栏仅允许启用CSS 3.0检查css文件,而不是HTML。因此,如果要保持语法检查,则需要此修复)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.