jshint

什么是“Linting”?

梦想与她 提交于 2020-01-06 20:53:37
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> PHPLint,JSLint和我最近遇到了“你可以动态地抓取你的JS代码”,同时阅读有关某些IDE的内容。 那么,这是什么 掉毛 人人都知道,而我呢? #1楼 lint是一个用于标记源代码的工具,带有一些可疑和非结构(可能导致bug)。 它是C语言中的静态代码分析工具。现在它成为用于描述标记可疑代码的软件分析工具的通用术语。 #2楼 Linting 是检查Programmatic和Stylistic错误的源代码的过程。 这有助于识别编码过程中出现的一些常见和不常见的错误。 Lint 或 Linter 是一个支持linting(验证代码质量)的程序。 它们适用于大多数语言,如JavaScript,CSS,HTML,Python等。 一些有用的棉绒是 JSLint的 , CSSLint , JSHint , pylint的 #3楼 除了别人提到的内容外,我想补充一点,Linting将通过您的源代码查找 - formatting discrepancy - non-adherence to coding standards and conventions - pinpointing possible logical errors in your program 在源代码上运行Lint程序有助于确保源代码易读,易读

JSHint and skipping lines with custom non-JS templating code

為{幸葍}努か 提交于 2020-01-06 15:32:15
问题 I am using SublimeLinter3 in SublimeText3 with the SublimeLinter-jshint linter. I have server side JavaScript that is processed by a custom CGI. It imports other server side JS files with a import statement that is formatted as follows (the :ssjs just tells the interpreter to process the import as server side JavaScript): %import /foo/bar.js:ssjs Needless to say, this is causing all sorts of problems with JSHint, such as: Expected an identifier and instead saw '%' Expected an assignment or

Why does using `this` within function give me a “Possible strict violation” in jshint?

邮差的信 提交于 2020-01-03 06:01:07
问题 Say I have a function that I would like reuse as a method on a couple objects in order to add data to those objects. function addToObject(data) { for (var d in data) { if (data.hasOwnProperty(d)) { this[d] = data[d]; } } } myObjOne = { add: addToObject }; myObjTwo = { add: addToObject }; My goal here was to be able to call myObjOne.add(myData) where myData is an object that I would like to add to myObjOne and be able to replicate this functionality on myObjTwo . My issue is that using this

How can I force JSHint running in grunt to always use the --verbose flag

非 Y 不嫁゛ 提交于 2020-01-02 03:16:12
问题 I have a particular JSHint/Grunt setup in which I would like to accomplish the following: Load from a single .jshintrc file to allow my IDE linter to pick up my settings Be able to override single options from the .jshintrc in other grunt tasks Have JSHint always run in verbose mode so that I can always see the warning numbers, without needing to run all of grunt with --verbose The following allows me to load from the .jshintrc and always run in verbose, but does not allow option overrides.

npm run cmd fails while cmd on command line works

前提是你 提交于 2020-01-01 04:27:06
问题 In my HTTP Status Check project: If I run node_modules/.bin/jshint . I get: $ node_modules/.bin/jshint . test/inAdapters_fileAdapter.js: line 73, col 31, Missing semicolon. 1 error It executes correctly and produces the expected output: 1 error. But if I add that command to package.json and try and run it through npm run then it works and produces the expected output but also follows that with a bunch of errors: $ npm run jshint > http-status-check@0.0.5 jshint /home/guy/source/http-status

Using this in event handler in strict javascript?

半腔热情 提交于 2019-12-31 04:45:10
问题 Suppose you have a routine like the following to wire up click event handlers getElements(".board>div").forEach(function(elem){ elem.addEventListener("click", handleClick); }); And then in the handler, you need to work with the sender (i.e. this) function handleClick(){ if(this.innerText.toLowerCase() !== "x"){ ... How do you use this in this scenario without a jshint violation/warning? 回答1: Your use of this is valid. To suppress the this errors in your event handler add /*jshint validthis:

Gulp returns 0 when tasks fail

℡╲_俬逩灬. 提交于 2019-12-30 03:39:11
问题 I'm using Gulp in my small project in order to run tests and lint my code. When any of those tasks fail, Gulp always exits with return code 0. If I run jshint by hand, it exits with non-zero code as it should. Here's my very simple gulpfile. Do I need to somehow explicitly tell Gulp to return a meaningful value? Is this Gulp's fault, or maybe the gulp-jshint and gulp-jasmine plugins are to blame? 回答1: A fix has been introduced in this commit. It works something like this: gulp.src("src/**/*

Why does JSHint throw a warning if I am using const?

僤鯓⒐⒋嵵緔 提交于 2019-12-29 10:03:52
问题 This is the error I get when using const: <error line="2" column="1" severity="warning" message="&apos;const&apos; is available in ES6 (use esnext option) or Mozilla JS extensions (use moz)." source="jshint.W104" /> My code looks like this: const Suites = { Spade: 1, Heart: 2, Diamond: 3, Club: 4 }; The code works fine only JSHint is warning me every time. 回答1: When relying upon ECMAScript 6 features such as const , you should set this option so JSHint doesn't raise unnecessary warnings. /

How to turn off JSHint error?

家住魔仙堡 提交于 2019-12-25 04:29:16
问题 I have the following error for my files in tests: Expected an assignment or function call and instead saw an expression. It is generated from Chai libraries asserts. How can I turn it off in my .jshintrc file? I run a Gulp task based on it. 回答1: Here's how you can silence it inside of a .jshintrc file. { ... "expr": true ... } Source: http://jshint.com/docs/options/#expr 回答2: You can add the following on top of the line that's generating the error : /*jshint -W030 */ Reference : http:/

How do I modify jshint sublimelinter settings?

倾然丶 夕夏残阳落幕 提交于 2019-12-25 04:26:18
问题 I am sorrry if this is a duplicate question. I want to turn off warnings for semi-colon, and change appearance of warning cursors in jshint sublimelinter. What file or menu do I need to access to change these settings? 回答1: See this duplicate answer, among the many questions. Create a .jshintrc file in the directory you want to lint (a simple JSON file like this, and drop your options in there. You'll be looking for the asi option for semicolons. To set it globally you can place it in a top