Google 发布 Closure Linter
Google 很重视代码风格的一致性,而且还公开过一份 JavaScript 代码风格指南:
Google JavaScript Style Guide,现在它们又发布了一个工具来帮助你检查 JavaScript
代码是否严格遵循了 Google JavaScript Style Guide :Closure Linter。
var x = 10 var y=20; for(var i = 0;i < 10; i++ ) { x += i; y -= i; } var z = [10, 20,]; x = y + z[0] + 10;Line 1, E:0010: (New error) Missing semicolon at end of line Line 2, E:0002: Missing space before "=" Line 2, E:0002: Missing space after "=" Line 4, E:0002: Missing space before "(" Line 4, E:0002: Missing space after ";" in for statement Line 4, E:0001: Extra space before ")" Line 6, E:0006: (New error) Wrong indentation: expected any of {2} but got 3 Line 9, E:0121: Illegal comma at end of array literal Line 12, E:0120: Binary operator should go on previous line "+"这个工具甚至可以帮你自动修复一些错误,运行 fixjsstyle –strict fixme.js 即可。(注意:不一定可以修复全部错误) Closure Linter 支持 Windows, Linux & Mac OS X. 具体使用方法请看这里 。
本文出自 传播、沟通、分享,转载时请注明出处及相应链接。
本文永久链接: https://www.nickdd.cn/?p=1009