Closed tirthaguha closed 7 years ago
This isn't quite enough information. From our contribution guidelines:
Bug Reports
If you believe you have identified incorrect behavior, please let the team know by filing an issue. In order to help the team diagnose and fix the problem, the issue report should have the following information:
- Version of JSHint being used
- Input source code (simplified to only contain details necessary to demonstrate the problem)
- Configuration values
- Description of expected behavior
- Description of actual behavior
Also: from the error message, it looks like the offending code is the fifth line of the input file. The preceding lines may be relevant, so please include those, too.
Hi,
Version of JSHint being used: "grunt-contrib-jshint": "^0.9.2",
Input source code:
We were running casperJS with Grunt, The following command executes in shell.
casperjs --ignore-ssl-errors=true --ssl-protocol=any, casperStarter.js
and in casperStarter.js we have
var casper = require('casper').create
({
verbose: true,
logLevel: "debug"
});
casper.on('remote.alert', function (message) {
this.echo(message);
});
Configuration values: in jshintrc
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": false,
"boss": true,
"eqnull": true,
"node": true,
"nonew": false,
"phantom": true,
"globals": {
"casper": false
}
}
Description of expected behavior: should not show this error
JSHint is warning about the casper
redefinition because you have listed that
identifier as a read-only global variable in your .jshintrc
file and also
included a casper
variable declaration in your source code. This is expected
behavior. There are a couple of ways you can avoid the warning:
"casper"
entry in the globals
configuration from your
.jshintrc
fileWrap your code in an immediately-invoked function expression, e.g.
(function() {
var casper = require('casper').create
// etc.
}());
true
as the value for the "casper"
entry in the globals
configuration (which means, "this is a writable global")Based on the way your code is written, where casper
is being explicitly
defined (as opposed to provided globally by the environment), I would recommend
#1
.
Hope that helps!
I was working wiht casperJS and I have the following in my code
and here's the error I get