CSS、HTML 和 javascript 代码分析
任何人都可以向我指出类似于 StyleCop for C# 的软件方向,它可以根据预定义规则/自定义规则集分析 CSS、HTML 和 javascript。
例如,
- css - 确保类名使用驼峰式大小写
- html - 确保不使用内联语法
- javascript - 还不确定:P
理想情况下,可以作为 msbuild 的一部分运行的工具将是有益的,因此可以包含它们作为质量构建的一部分。开发人员可以运行的工具也是理想的。
Can anybody point me in the direction of software similar to StyleCop for C# which can analyse CSS, HTML and javascript against sets of predefined rules / custom rules.
For Example,
- css - to ensure camel case is used for class names
- html - to ensure inline sytles are not used
- javascript - not sure yet :P
Ideally, tools which can be run as-part of msbuild would be benefical so they can be included as part of a quality build. Tools runnable by developers would also be desirable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于 javascript,请查看 JSLint:
http://www.jslint.com/
For javascript check out JSLint:
http://www.jslint.com/
对于 CSS,您可以使用 csslint 工具。
http://csslint.net/
它也可以从命令行执行。
https://github.com/stubbornella/csslint/wiki/Command-line-interface
For CSS you can use csslint tool.
http://csslint.net/
It can be execute from command line also.
https://github.com/stubbornella/csslint/wiki/Command-line-interface
如果您想要针对多种语言的可定制规则,可以考虑使用 DMS Software Reengineering工具包。
DMS 具有适用于多种语言(包括“脏”HTML 和JavaScript)的编译器式解析器以及定义此类语言方言的方法(例如,用于HTML 的CSS)。这些解析器构建完整的抽象语法树,然后您可以为 DMS 编写自定义脚本来遍历这些树并检查您的样式约定是否被违反。
基于 DMS 的工具可以轻松合并到命令脚本中。
DMS 已用于 COBOL 和 C++ 的此目的。
If you want customizable rules for a wide variety of languages, you can consider using the DMS Software Reengineering Toolkit.
DMS has compiler-style parsers for a wide variety of langauges (including "dirty" HTML and JavaScript) as well as means to define dialects of such langauges (e.g., CSS for HTML). These parsers build full abstract syntax trees, and then you can code custom scripts for DMS to walk over these trees and check that your style conventions have not been violated.
DMS-based tools are easily incorporated into command scripts.
DMS has already been used for this purpose for both COBOL and C++.
如果您正在使用
Visual Studio
,那么您可以尝试Web Analyzer
它是 Lints JavaScript、JSX、TypeScript、CoffeeScript 和 CSS 文件,使用:
https://marketplace.visualstudio.com/items?itemName=MadsKristensen.WebAnalyzer&ssr=false#overview
注意:在 Visual Studio 2015 及更低版本上效果更好。
If you are working with
Visual Studio
then you can tryWeb Analyzer
It's Lints JavaScript, JSX, TypeScript, CoffeeScript and CSS files using:
https://marketplace.visualstudio.com/items?itemName=MadsKristensen.WebAnalyzer&ssr=false#overview
Note: Work better for visual studio 2015 and lower version.