我们每个人写代码时,都有自己的个人习惯,为了更好地合作开发,团队的编码习惯还是要有的,那么jshint将是一个不错的可编辑代码约束规范和风格的代码检测工具。
一、sublime下插件安装
通过package control安装Sublimelinter(我只找到Sublimelint)和SublimeLinter-jshint插件。
接下来的需要Node支持了。
二、npm包安装
去Node官网下载个Node,其中自带了npm包管理工具。
去控制台,输入:
install -g jshint
等安装完成后,重启sublime,检测功能就可以使用了。
三、jshint配置
在Node的安装目录下搜到一个.jshintrc的文件,打开这个JSON文件,编辑其中的内容,指定选项的打开或关闭。
目前刚开始,暂时弄这些,后期根据实际情况再更新。
{ "curly": true,// true: Require {} for every new block or scope "eqeqeq": false,// 设置为true,禁止使用这个选项 ==和 !=,强制使用 ===和 !== "immed": false,// true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` "latedef": false,// true: Require variables/functions to be defined before being used "noarg": true,// true: 禁止使用这个选项 arguments.caller和 arguments.callee "sub": true,// true: Prohibit use of empty blocks "undef": true,// true: Require all non-global variables to be declared (prevents global leaks) "unused": true,// 变量定义未使用 "eqnull": true,// true: Requires all functions run in ES5 Strict Mode "es3": true,// {int} Max number of formal params allowed per function "freeze": true,// 这个选项禁止重写原生对象的原型列如 Array,Date等等。 "funcscope": true,// 禁止从外部访问内部声明的变量 "latedef": true,// 禁止定义之前使用变量。 "bitwise": false,// 是否禁用位运算符 "maxstatements": 7,// 这个选项允许您设置语句允许的最大声明数 "nocomma": true,// 这个选项禁止使用逗号操作符。 "predef": true,// 扩展的隐式全局变量 "asi": true,// 禁止缺少分号警告 "browser": true,// 暴露浏览器属性的全局变量,列如 window,document; 注意:这个选项不暴露变量 alert或 console。 "devel": true,"laxcomma": true,"es5": true,"esversion: 6": true,"node": true,"strict": false,// {int} Max depth of nested blocks (within functions) "-W117": true // {int} Max number statements per function }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。