惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
PCI Perspectives
PCI Perspectives
Webroot Blog
Webroot Blog
罗磊的独立博客
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
Last Week in AI
Last Week in AI
美团技术团队
Help Net Security
Help Net Security
The Hacker News
The Hacker News
C
Cisco Blogs
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
The Register - Security
The Register - Security
IT之家
IT之家
WordPress大学
WordPress大学
Jina AI
Jina AI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Help Net Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
NISL@THU
NISL@THU
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Scott Helme
Scott Helme
V
Vulnerabilities – Threatpost
B
Blog
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
T
The Exploit Database - CXSecurity.com
S
Security Affairs
小众软件
小众软件
Hacker News: Ask HN
Hacker News: Ask HN
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
W
WeLiveSecurity
A
Arctic Wolf
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence

博客园 - 豆豆の爸爸

IDEA 2024的零卡死配置 10分钟揭秘大模型的原理 苹果容器Apple container是做什么用的? pnpm 10.14 支持JavaScript运行时的安装了 白话Docker:用Web应用实例深入容器 用 rake 合并多个 JS 文件,并且用 Google Closure Compiler 压缩代码 HTML 5 就是 Web Application JS程序员的一天 Google Map 类实例在类式继承中的实现 写入 cookie 的过期时间时在GMT或UTC时间格式上的兼容问题 “当 HTML 5 来敲门”专题沙龙(上海)活动 PHP 的 Smarty 模板页中分离JS并避开literal标签的解决方法 Google Maps(Google 地图) V3 在 IE7 浏览器中拖放其容器时图块被覆盖的 bug 2010年我的个人总结 [译]用 Closure Compiler 编写更好的 OO 的 JavaScript 使用 IronScheme 进入 Scheme 编程语言的世界 - 豆豆の爸爸 《JS高级程序设计(第2版)》书评 [译]在 Firebug 中的表格化日志 在 Notepad++ 运行 Closure Compiler 工具来解析并压缩JS
在 Notepad++ 运行 Closure Linter 来校验JS代码
豆豆の爸爸 · 2010-11-27 · via 博客园 - 豆豆の爸爸

在这篇blog之前写过同类的校验JS代码工具:JavaScript Lint 的在 Notepad++ 中如何使用,google 提供的 Closure Linter 给了我们更多的工具选择。

Closure Linter是在Python上运行的,所以先在系统中配置安装Python的运行环境:

  1. 安装 Python。本人安装的版本为 Python 2.5.4
  2. 安装 Easy Install 模块。也就是要安装 setuptools windows下本人安装的为: setuptools-0.6c11.win32-py2.5.exe
  3. 确保 Easy Install 配置到Path环境变量

然后,在命令行中执行如下命令:

easy_install E:\closure_linter\closure_linter-2-1.2.6.tar.gz

如果出现啪啦啪啦如下的截图画面:

则说明Closure Linter 安装成功!OK,在Notepad++ 的NppExec执行如下命令:

gjslint --strict $(FULL_CURRENT_PATH)

可以将这个命令保存为 Closure Linter。点击“OK”试试,如果在控制台窗口输出如下结果:

gjslint –-strict D:\work\js\WOYO\event.js
Process started >>>
----- FILE  :  D:\work\js\WOYO\event.js -----
Line 3, E:0217: Missing @return JsDoc in function with non-trivial return
Line 4, E:0002: Missing space before "{"
Line 5, E:0005: Illegal tab in whitespace before "if"
Line 5, E:0002: Missing space before "("
Line 6, E:0005: Illegal tab in whitespace before "return"
Line 7, E:0005: Illegal tab in whitespace before "}"
Line 8, E:0005: Illegal tab in whitespace before "else"
Line 8, E:0002: Missing space before "("
Line 9, E:0005: Illegal tab in whitespace before "var"
Line 9, E:0002: Missing space before "="
Line 9, E:0002: Missing space before "["
Line 9, E:0131: Single-quoted string preferred over double-quoted string.
Line 9, E:0131: Single-quoted string preferred over double-quoted string.
Line 9, E:0131: Single-quoted string preferred over double-quoted string.
Line 10, E:0005: Illegal tab in whitespace before "		"
Line 10, E:0001: Extra space at end of line
Line 11, E:0005: Illegal tab in whitespace before "for"
Line 11, E:0002: Missing space before "("
Line 11, E:0002: Missing space before "="
Line 11, E:0002: Missing space after "="
Line 11, E:0002: Missing space before "<"
Line 11, E:0002: Missing space after "<"
Line 12, E:0005: Illegal tab in whitespace before "try"
Line 13, E:0005: Illegal tab in whitespace before "var"
Line 14, E:0005: Illegal tab in whitespace before "return"
Line 15, E:0005: Illegal tab in whitespace before "}"
Line 16, E:0005: Illegal tab in whitespace before "catch"
Line 16, E:0002: Missing space before "("
Line 16, E:0002: Missing space before "{"
Line 17, E:0005: Illegal tab in whitespace before "//"
Line 18, E:0005: Illegal tab in whitespace before "}"
Line 19, E:0005: Illegal tab in whitespace before "}"
Line 20, E:0005: Illegal tab in whitespace before "}"
Line 21, E:0005: Illegal tab in whitespace before "throw"
Line 21, E:0131: Single-quoted string preferred over double-quoted string.
Line 24, E:0220: No docs found for member 'Ajax.Request'
Line 24, E:0002: Missing space before "{"
Line 25, E:0005: Illegal tab in whitespace before "var"
Line 26, E:0005: Illegal tab in whitespace before "var"
Line 27, E:0005: Illegal tab in whitespace before "if"
Line 27, E:0002: Missing space before "("
Line 28, E:0005: Illegal tab in whitespace before "var"
Line 28, E:0001: Extra space at end of line
Line 29, E:0005: Illegal tab in whitespace before "if"
Line 29, E:0002: Missing space before "("
Line 30, E:0005: Illegal tab in whitespace before "requestType"
Line 31, E:0005: Illegal tab in whitespace before "}"
Line 32, E:0005: Illegal tab in whitespace before "var"
Line 33, E:0005: Illegal tab in whitespace before "req.open"
Line 34, E:0005: Illegal tab in whitespace before "req.onreadystatechange"
Line 35, E:0005: Illegal tab in whitespace before "if"
Line 36, E:0005: Illegal tab in whitespace before "callbackData"
Line 36, E:0002: Missing space after "+"
Line 36, E:0002: Missing space before "+"
Line 37, E:0005: Illegal tab in whitespace before "}"
Line 38, E:0005: Illegal tab in whitespace before "}"
Line 39, E:0005: Illegal tab in whitespace before "this.onSuccess"
Line 39, E:0002: Missing space before "{"
Line 41, E:0002: Missing space before "{"
Line 42, E:0005: Illegal tab in whitespace before "$"
Line 42, E:0002: Missing space before "{"
Line 43, E:0005: Illegal tab in whitespace before "var"
Line 44, E:0005: Illegal tab in whitespace before "url"
Line 45, E:0005: Illegal tab in whitespace before "dataType"
Line 46, E:0005: Illegal tab in whitespace before "}"
Line 47, E:0005: Illegal tab in whitespace before "req.onSuccess"
Line 47, E:0002: Missing space before "{"
Line 48, E:0005: Illegal tab in whitespace before "		"
Line 48, E:0001: Extra space at end of line
Line 49, E:0005: Illegal tab in whitespace before "}"
Line 50, E:0005: Illegal tab in whitespace before "$.ajax"
Line 51, E:0005: Illegal tab in whitespace before "url"
Line 52, E:0005: Illegal tab in whitespace before "dataType"
Line 53, E:0005: Illegal tab in whitespace before "success"
Line 54, E:0005: Illegal tab in whitespace before "$"
Line 55, E:0005: Illegal tab in whitespace before "}"
Line 56, E:0005: Illegal tab in whitespace before "}"
Line 57, E:0005: Illegal tab in whitespace before "return"
Line 58, E:0005: Illegal tab in whitespace before "}"
Line 66, E:0210: Missing docs for parameter: "file"
Line 66, E:0210: Missing docs for parameter: "postData"
Line 67, E:0005: Illegal tab in whitespace before "var"
Line 68, E:0005: Illegal tab in whitespace before "if"
Line 68, E:0002: Missing space before "("
Line 69, E:0005: Illegal tab in whitespace before "req.onreadystatechange"
Line 70, E:0005: Illegal tab in whitespace before "if"
Line 71, E:0005: Illegal tab in whitespace before "if"
Line 72, E:0005: Illegal tab in whitespace before "alert"
Line 73, E:0005: Illegal tab in whitespace before "return"
Line 74, E:0005: Illegal tab in whitespace before "}"
Line 75, E:0005: Illegal tab in whitespace before "		"
Line 75, E:0001: Extra space at end of line
Line 76, E:0005: Illegal tab in whitespace before "updateobj"
Line 76, E:0110: Line too long (94 characters).
Line 77, E:0005: Illegal tab in whitespace before "}"
Line 78, E:0005: Illegal tab in whitespace before "req.open"
Line 79, E:0005: Illegal tab in whitespace before "req.setRequestHeader"
Line 79, E:0002: Missing space after ","
Line 80, E:0005: Illegal tab in whitespace before "if"
Line 81, E:0005: Illegal tab in whitespace before "req.send"
Line 84, E:0005: Illegal tab in whitespace before "document.getElementsByTagName"
Line 88, E:0005: Illegal tab in whitespace before "function"
Line 89, E:0005: Illegal tab in whitespace before "function"
Line 89, E:0001: Extra space after "function"
Line 89, E:0131: Single-quoted string preferred over double-quoted string.
Line 90, E:0005: Illegal tab in whitespace before "function"
Line 90, E:0001: Extra space after "function"
Line 90, E:0131: Single-quoted string preferred over double-quoted string.
Line 91, E:0005: Illegal tab in whitespace before "function"
Line 91, E:0001: Extra space after "function"
Line 91, E:0131: Single-quoted string preferred over double-quoted string.
Line 95, E:0005: Illegal tab in whitespace before "var"
Line 96, E:0005: Illegal tab in whitespace before "for"
Line 96, E:0002: Missing space before "("
Line 96, E:0002: Missing space before "="
Line 96, E:0002: Missing space after "="
Line 96, E:0002: Missing space before "<"
Line 96, E:0002: Missing space after "<"
Line 97, E:0005: Illegal tab in whitespace before "try"
Line 98, E:0005: Illegal tab in whitespace before "xmlhttp"
Line 99, E:0005: Illegal tab in whitespace before "}"
Line 100, E:0005: Illegal tab in whitespace before "catch"
Line 100, E:0002: Missing space before "("
Line 101, E:0005: Illegal tab in whitespace before "continue"
Line 102, E:0005: Illegal tab in whitespace before "}"
Line 103, E:0005: Illegal tab in whitespace before "break"
Line 104, E:0005: Illegal tab in whitespace before "}"
Line 105, E:0005: Illegal tab in whitespace before "return"
Line 106, E:0300: File does not end with new line.  (})
Found 129 errors, including 0 new errors, in 1 files (0 files OK).

Some of the errors reported by GJsLint may be auto-fixable using the script
fixjsstyle. Please double check any changes it makes and report any bugs. The
script can be run by executing:

fixjsstyle –-strict D:\work\js\WOYO\event.js

<<< Process finished.
================ READY ================

则说明JS代码已经被 Closure Linter工具校验。居然这么多 bug!不过,修复 bug 也可以利用工具来完成,哈哈!执行如下的命令即可:

fixjsstyle –-strict $(FULL_CURRENT_PATH)

在Console窗口中显示的结果:

fixjsstyle –-strict D:\work\js\WOYO\event.js
Process started >>>
Fixed 44 errors in D:\work\js\WOYO\event.js
<<< Process finished.
================ READY ================

129个bug修复了44个!因为选择了strict参数,果然很严苛!哈哈!

(完)