npm i -g eslint
eslint [options] [file|dir]*
eslint -c myconfig.json model.js
{
"env": {
"browser": true
},
"rules": {
// Override our default settings just for this directory
"eqeqeq": 1,
"strict": 1,
"quotes": 0,
"no-extra-semi": 1
}
}
38:13 error 'require' is not defined no-undef
41:18 error 'Java' is not defined no-undef
43:11 error 'require' is not defined no-undef
515:69 error 'serviceContainer' is not defined no-undef
710:0 error 'exports' is not defined no-undef
36:0 error Use the function form of "use strict" no-global-strict
36:0 warning Strings must use doublequote quotes
152:36 error It's not necessary to initialize 'cb' to undefined no-undef-init
173:63 warning Strings must use doublequote quotes
193:36 error It's not necessary to initialize 'cb' to undefined no-undef-init
389:43 warning Strings must use doublequote quotes
491:15 warning Expected '!==' and instead saw '!=' eqeqeq
568:13 warning Unnecessary semicolon no-extra-semi
203:93 error args is defined but never used no-unused-vars
module.exports = function(context) {
return {
"BinaryExpression": function(node) {
var operator = node.operator;
...
if (context.options[0] === "smart" && (isTypeOf(node) ||
bothAreSameTypeLiterals(node)) || isNullCheck(node))
{ return; }
if (operator === "==") {
context.report(node, "Expected '===' and instead saw '=='.");
} else if (operator === "!=") {
context.report(node, "Expected '!==' and instead saw '!='.");
}
}
}; };
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
}
var greeter = new Greeter("world");
alert(greeter.greet());
describe("A spec", function() {
it("is just a function, so it can contain any code", function() {
var foo = 0;
foo += 1;
expect(foo).toEqual(1);
});
it("can have more than one expectation", function() {
var foo = 0;
foo += 1;
expect(foo).toEqual(1);
expect(true).toEqual(true);
expect(true).not.toBe(false);
});
});
describe('Array', function () {
describe('#indexOf()', function () {
it('should return -1 when the value is not present', function () {
assert.equal(-1, [1, 2, 3].indexOf(5));
assert.equal(-1, [1, 2, 3].indexOf(0));
// same as above, other assertion notation
[1,2,3].indexOf(5).should.equal(-1);
[1,2,3].indexOf(0).should.equal(-1);
});
});
});
casper.start('http://www.someurl.com', function() {
casper.assertHttpStatus(200, 'Testlab is up');
casper.capture('LoginScreen.png', {
top: 0, left: 0, width: 1000, height: 900
});
casper.waitForSelector('#logonForm', function() {
casper.fill('form#logonForm', {
'user': 'heiko.spindler@hirnsport.de',
'password': 'xxx' }, true);
});
casper.wait(1000, function() { ... });
casper.test.assertExists('Filterform(click to hide)', "Form found");
});
casper.run();
$ curl --data-binary @hello-world.js http://api.casperbox.com/scripts -H 'Content-Type:text/plain'
{
"id": "430638dd-046a-4d1c-95cd-f510b752de32",
"status": "QUEUED"
}
$ curl http://api.casperbox.com/scripts/ 430638dd-046a-4d1c-95cd-f510b752de32
{
"id": "430638dd-046a-4d1c-95cd-f510b752de32",
"source": "var casper = require('casper').create();\ncasper.start('http://casperjs.org', function() {\n\tcasper.echo('Hello, world!');\n});\ncasper.run();\n",
"status": "RUN",
"output": "Hello, world!"
}
/**
* Creates an instance of Circle.
*
* @constructor
* @param {number} r The desired radius of the circle.
*/
function Circle(r) {
/** @private */ this.radius = r;
/** @private */ this.circumference = 2 * Math.PI * r;
}
/**
* Creates a new Circle from a diameter.
*
* @param {number} d The desired diameter of the circle.
* @return {Circle} The new Circle object.
*/
Circle.fromDiameter = function (d) {
return new Circle(d / 2);
};