jshint

jshint “use strict” issue [duplicate]

让人想犯罪 __ 提交于 2019-11-27 21:33:27
问题 This question already has an answer here: JSLint is suddenly reporting: Use the function form of “use strict” 8 answers Here's my file: app/scripts/controllers/main.js "use strict"; angular.module('appApp') .controller('MainCtrl', ['$scope', function ($scope) { $scope.awesomeThings = [ 'HTML5 Boilerplate', 'AngularJS', 'Karma' ]; }]); My Gruntfile.coffee has: jshint: options: globals: require: false module: false console: false __dirname: false process: false exports: false server: options:

setup pre-commit hook jshint

和自甴很熟 提交于 2019-11-27 19:53:21
问题 I recently started a project on github. I've managed to setup automatic testing after each commit using Travis. But now I would like to setup a pre-commit hook with jshint too. So if jshint reports errors, the commit should fail. But is this possible, and if so, how to do this ? 回答1: But is this possible... Yes! This is possible. I recently wrote about it. Note that it's not specific to GitHub, just Git in general - as it's a pre-commit hook, it runs before any data is sent to GitHub. Any

gulp-jshint: How to fail the build?

强颜欢笑 提交于 2019-11-27 14:35:44
问题 I want my Gulp build to fail, if there are errors in JSHint. According to the documentation of gulp-jshint I can use the "fail reporter". However the following does not work: gulp.task("lint", function() { return gulp.src(JS_SOURCES) .pipe(jshint()) .pipe(jshint.reporter("jshint-stylish")) .pipe(jshint.reporter("fail")); }); The task above always returns with exit code 0, even when there are errors in JSHint. I am using gulp 3.8.10 and gulp-jshint 1.9.0. There are discussions in the github

How to ignore node shebang error in Eclipse?

回眸只為那壹抹淺笑 提交于 2019-11-27 14:32:31
问题 I am writing some node command line utilities. They all start with the line: #!/usr/bin/env node With Eclipse Juno and the Nodeclipse Node.js plugin, this line of code produces an error as shown: OK, so # is not a valid comment character in javascript, but it is a valid character in Linux/UNIX as the shebang of the first line in a file. But how can I set up Eclipse to ignore this error? This is a problem for me because code formatting does not work if you have errors. I have to delete the

Jshint.com requires “use strict”. What does this mean? [duplicate]

南笙酒味 提交于 2019-11-27 14:28:30
问题 This question already has an answer here: What does “use strict” do in JavaScript, and what is the reasoning behind it? 27 answers Jshint.com is giving the error: Line 36: var signin_found; Missing "use strict" statement. 回答1: Add "use strict" at the top of your js file (at line 1 of your .js file): "use strict"; ... function initialize_page() { var signin_found; /*Used to determine which page is loaded / reloaded*/ signin_found=document.getElementById('signin_button'); if(signin_found) {

jshint expects the new 'prefix' for functions

北城以北 提交于 2019-11-27 12:44:56
问题 CSiginIn , CSignUp , CTryIt , CBlocks are all functions declared as such function CSignIn(){//stuff here} yet JSHint says that I am missing the 'new' 'prefix'. What can I do to fix this? They are just functions inside the module pattern. Also, it is asking me to remove semicolons I had placed at the end of the function which I have done. var Control = ( function () { /** *Publik */ var publik = function ( page ) { // page 1 initialization if( page == 1 ) { CSignIn(); CSignUp(); CTryIt();

JSHint (r10): 'angular' is not defined

天涯浪子 提交于 2019-11-27 11:06:02
问题 I have the following: angular.module('test') .controller('TestMenuController', [ '$http', '$scope', '$resource', '$state', 'os', 'us', function ( $http, $scope, $resource, $state, os, us) { When I build this in VS2014 it gives me an error message saying: JSHint (r10): 'angular' is not defined. Can someone tell me how I can avoid this message coming up? 回答1: One way to tackle this is to modify your .jshintrc and set angular as one of the predefined variables, as Jayantha said. .jshintrc would

Is there a way to suppress JSHint warning for one given line?

和自甴很熟 提交于 2019-11-27 05:50:49
I have a (single) case in my app were eval is used, and I would like to suppress JSHint warning only for this case. Is there a way to achieve that? Configuration, magic comment, ...? Jason Punyon Yes, there is a way. Two in fact. In October 2013 jshint added a way to ignore blocks of code like this: // Code here will be linted with JSHint. /* jshint ignore:start */ // Code here will be ignored by JSHint. /* jshint ignore:end */ // Code here will be linted with JSHint. You can also ignore a single line with a trailing comment like this: ignoreThis(); // jshint ignore:line tollmanz The "evil"

JSHint and jQuery: '$' is not defined

一世执手 提交于 2019-11-27 04:57:19
问题 The following JS: (function() { "use strict"; $("#target").click(function(){ console.log("clicked"); }); }()); Yields: test.js: line 5, col 3, '$' is not defined. When linted using JSHint 0.5.5. Any ideas? 回答1: If you are using a relatively recent version of JSHint, the generally preferred approach is to create a .jshintrc file in the root of your project, and put this config in it: { "globals": { "$": false } } This declares to JSHint that $ is a global variable, and the false indicates that

Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function

怎甘沉沦 提交于 2019-11-27 03:51:05
问题 I have the following code: if (typeof console === "object" && typeof console.error === "function") { function e(msg) {"use strict"; console.info(msg);} } For which jsLint gives the following error: Function statements should not be placed in blocks. Use a function expression or move the statement to the top of the outer function. Why is it giving this error and what does it mean? 回答1: You should not be creating function inside if block. You are much better off doing: var e = function(){}; if