Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

enforce single quotes

fix #60
  • Loading branch information...
commit 1be44d213ef15f2eec774cb33692c6e1e694a93e 1 parent 57effe2
@rmurphey authored
View
3  .jshintrc
@@ -20,5 +20,6 @@
"regexp": false,
"undef": true,
"sub": true,
- "strict": false
+ "strict": false,
+ "quotmark": "single"
}
View
4 app/bestPractices.js
@@ -17,9 +17,9 @@ define(function() {
functions : function(flag) {
if (flag) {
- function getValue() { return "a"; }
+ function getValue() { return 'a'; }
} else {
- function getValue() { return "b"; }
+ function getValue() { return 'b'; }
}
return getValue();
View
26 tests/app/arrays.js
@@ -5,23 +5,23 @@ if (typeof expect !== 'function') { var expect = require('expect.js'); }
define([
'app/arrays'
], function(answers) {
- describe("arrays", function() {
+ describe('arrays', function() {
var a;
beforeEach(function() {
a = [ 1, 2, 3, 4 ];
});
- it("you should be able to determine the location of an item in an array", function() {
+ it('you should be able to determine the location of an item in an array', function() {
expect(answers.indexOf(a, 3)).to.eql(2);
expect(answers.indexOf(a, 5)).to.eql(-1);
});
- it("you should be able to add the values of an array", function() {
+ it('you should be able to add the values of an array', function() {
expect(answers.sum(a)).to.eql(10);
});
- it("you should be able to remove a value from an array", function() {
+ it('you should be able to remove a value from an array', function() {
a.push(2); // Make sure the value appears more than one time
var result = answers.remove(a, 2);
@@ -29,7 +29,7 @@ define([
expect(result.join(' ')).to.eql('1 3 4');
});
- it("you should be able to remove a value from an array, returning the original array", function() {
+ it('you should be able to remove a value from an array, returning the original array', function() {
a.splice( 1, 0, 2 );
a.push( 2 );
a.push( 2 );
@@ -43,21 +43,21 @@ define([
expect(result).equal(a);
});
- it("you should be able to add an item to the end of an array", function() {
+ it('you should be able to add an item to the end of an array', function() {
var result = answers.append(a, 10);
expect(result).to.have.length(5);
expect(result[result.length - 1]).to.eql(10);
});
- it("you should be able to remove the last item of an array", function() {
+ it('you should be able to remove the last item of an array', function() {
var result = answers.truncate(a);
expect(result).to.have.length(3);
expect(result.join(' ')).to.eql('1 2 3');
});
- it("you should be able to join together two arrays", function() {
+ it('you should be able to join together two arrays', function() {
var c = [ 'a', 'b', 'c', 1 ],
result = answers.concat(a, c);
@@ -65,34 +65,34 @@ define([
expect(result.join(' ')).to.eql('1 2 3 4 a b c 1');
});
- it("you should be able to add an item anywhere in an array", function() {
+ it('you should be able to add an item anywhere in an array', function() {
var result = answers.insert(a, 'z', 2);
expect(result).to.have.length(5);
expect(result.join(' ')).to.eql('1 2 z 3 4');
});
- it("you should be able to count the occurences of an item in an array", function() {
+ it('you should be able to count the occurences of an item in an array', function() {
var result = answers.count([ 1, 1, 1, 2, 1, 3 ], 1);
expect(result).to.eql(4);
});
- it("you should be able to find duplicates in an array", function() {
+ it('you should be able to find duplicates in an array', function() {
var result = answers.duplicates([ 1, 2, 4, 4, 3, 3, 1, 5 ]);
expect(result).to.have.length(3);
expect(result.sort().join(' ')).to.eql('1 3 4');
});
- it("you should be able to square each number in an array", function() {
+ it('you should be able to square each number in an array', function() {
var result = answers.square(a);
expect(result).to.have.length(4);
expect(result.join(' ')).to.eql('1 4 9 16');
});
- it("you should be able to find all occurrences of an item in an array", function() {
+ it('you should be able to find all occurrences of an item in an array', function() {
var result = answers.findAllOccurrences('abcdefabc'.split(''), 'a');
expect(result.join(' ')).to.eql('0 6');
View
6 tests/app/async.js
@@ -5,8 +5,8 @@ if (typeof expect !== 'function') { var expect = require('expect.js'); }
define([
'app/async'
], function(answers) {
- describe("async behavior", function() {
- it("you should understand how to use 'promises' to handle asynchronicity", function(done) {
+ describe('async behavior', function() {
+ it('you should understand how to use promises to handle asynchronicity', function(done) {
var flag = false;
var finished = 0;
var total = 2;
@@ -30,7 +30,7 @@ define([
expect(flag).to.eql(false);
});
- it("you should be able to receive data from the server and manipulate it", function(done) {
+ it('you should be able to receive data from the server and manipulate it', function(done) {
var url = '/data/testdata.json';
answers.manipulateRemoteData(url).then(function(result) {
View
10 tests/app/bestPractices.js
@@ -6,24 +6,24 @@ if (typeof expect !== 'function') { var expect = require('expect.js'); }
define([
'app/bestPractices'
], function(answers) {
- describe("best practices", function(){
- it("you should avoid global variables", function() {
+ describe('best practices', function(){
+ it('you should avoid global variables', function() {
answers.globals();
expect(window.myObject).not.to.be.ok;
});
- it("you should declare functions safely", function() {
+ it('you should declare functions safely', function() {
var val = answers.functions(true);
expect(val).to.eql('a');
});
- it("you should use parseInt correctly", function() {
+ it('you should use parseInt correctly', function() {
expect(answers.parseInt('12')).to.eql(12);
expect(answers.parseInt('12px')).to.eql(12);
expect(answers.parseInt('0x12')).to.eql(0);
});
- it("you should understand strict comparison", function() {
+ it('you should understand strict comparison', function() {
expect(answers.identity(1, '1')).to.eql(false);
expect(answers.identity(1, 1)).to.eql(true);
expect(answers.identity(0, false)).to.eql(false);
View
4 tests/app/flowControl.js
@@ -6,8 +6,8 @@ if (typeof expect !== 'function') { var expect = require('expect.js'); }
define([
'app/flowControl'
], function(answers) {
- describe("flow control", function() {
- it("you should be able to conditionally branch your code", function() {
+ describe('flow control', function() {
+ it('you should be able to conditionally branch your code', function() {
var num = 0;
while (num % 3 === 0 || num % 5 === 0) {
View
18 tests/app/functions.js
@@ -8,7 +8,7 @@ define([
'app/functions'
], function(_, answers) {
- describe("functions", function() {
+ describe('functions', function() {
var sayItCalled = false;
var sayIt = function(greeting, name, punctuation) {
sayItCalled = true;
@@ -19,13 +19,13 @@ define([
sayItCalled = false;
});
- it("you should be able to use an array as arguments when calling a function", function() {
+ it('you should be able to use an array as arguments when calling a function', function() {
var result = answers.argsAsArray(sayIt, [ 'Hello', 'Ellie', '!' ]);
expect(result).to.eql('Hello, Ellie!');
expect(sayItCalled).to.be.ok;
});
- it("you should be able to change the context in which a function is called", function() {
+ it('you should be able to change the context in which a function is called', function() {
var speak = function() {
return sayIt(this.greeting, this.name, '!!!');
},
@@ -39,7 +39,7 @@ define([
expect(sayItCalled).to.be.ok;
});
- it("you should be able to return a function from a function", function() {
+ it('you should be able to return a function from a function', function() {
expect(answers.functionFunction('Hello')('world')).to.eql('Hello, world');
expect(answers.functionFunction('Hai')('can i haz funxtion?')).to.eql('Hai, can i haz funxtion?');
});
@@ -58,13 +58,13 @@ define([
}
});
- it("you should be able to create a 'partial' function", function() {
+ it('you should be able to create a "partial" function', function() {
var partial = answers.partial(sayIt, 'Hello', 'Ellie');
expect(partial('!!!')).to.eql('Hello, Ellie!!!');
expect(sayItCalled).to.be.ok;
});
- it("you should be able to use arguments", function () {
+ it('you should be able to use arguments', function () {
var a = Math.random(),
b = Math.random(),
c = Math.random(),
@@ -76,7 +76,7 @@ define([
expect(answers.useArguments(a, b, c, d)).to.eql(a + b + c + d);
});
- it("you should be able to apply functions with arbitrary numbers of arguments", function () {
+ it('you should be able to apply functions with arbitrary numbers of arguments', function () {
(function () {
var a = Math.random(), b = Math.random(), c = Math.random();
@@ -108,7 +108,7 @@ define([
});
- it("you should be able to create a 'partial' function for variable number of applied arguments", function () {
+ it('you should be able to create a "partial" function for variable number of applied arguments', function () {
var partialMe = function (x, y, z) {
return x / y * z;
};
@@ -120,7 +120,7 @@ define([
expect(answers.partialUsingArguments(partialMe, a, b, c)()).to.eql(partialMe(a, b, c));
});
- it("you should be able to curry existing functions", function () {
+ it('you should be able to curry existing functions', function () {
var curryMe = function (x, y, z) {
return x / y * z;
};
View
6 tests/app/logicalOperators.js
@@ -6,14 +6,14 @@ if (typeof expect !== 'function') { var expect = require('expect.js'); }
define([
'app/logicalOperators'
], function(answers) {
- describe("logical operators", function(){
- it("you should be able to work with logical and", function() {
+ describe('logical operators', function(){
+ it('you should be able to work with logical and', function() {
expect(answers.and(false, false)).not.to.be.ok;
expect(answers.and(true, false)).not.to.be.ok;
expect(answers.and(true, true)).to.be.ok;
});
- it("you should be able to work with logical or", function() {
+ it('you should be able to work with logical or', function() {
expect(answers.or(true, false)).to.be.ok;
expect(answers.or(true, true)).to.be.ok;
expect(answers.or(false, false)).not.to.be.ok;
View
4 tests/app/modules.js
@@ -5,8 +5,8 @@ if (typeof expect !== 'function') { var expect = require('expect.js'); }
define([
'app/modules'
], function(answers) {
- describe("the module pattern", function() {
- it("you should be able to create a function that returns a module", function() {
+ describe('the module pattern', function() {
+ it('you should be able to create a function that returns a module', function() {
var module = answers.createModule('hello', 'matt');
expect(module.sayIt).to.be.a('function');
View
10 tests/app/objects.js
@@ -5,7 +5,7 @@ if (typeof expect !== 'function') { var expect = require('expect.js'); }
define([
'app/objects'
], function(answers) {
- describe("objects and context", function() {
+ describe('objects and context', function() {
var a, b, C;
beforeEach(function() {
@@ -29,16 +29,16 @@ define([
};
});
- it("you should be able to alter the context in which a method runs", function() {
+ it('you should be able to alter the context in which a method runs', function() {
// define a function for fn so that the following will pass
expect(answers.alterContext(a.sayIt, b)).to.eql('Yo, Rebecca!');
});
- it("you should be able to alter multiple objects at once", function() {
+ it('you should be able to alter multiple objects at once', function() {
// define a function for fn so that the following will pass
var obj1 = new C('Rebecca'),
obj2 = new C('Melissa'),
- greeting = "What's up";
+ greeting = 'What\'s up';
answers.alterObjects(C, greeting);
@@ -47,7 +47,7 @@ define([
expect(new C('Ellie').greeting).to.eql(greeting);
});
- it("you should be able to iterate over an object's 'own' properties", function() {
+ it('you should be able to iterate over an object\'s "own" properties', function() {
// define a function for fn so that the following will pass
var C = function() {
this.foo = 'bar';
View
10 tests/app/recursion.js
@@ -7,7 +7,7 @@ define([
'app/recursion',
'underscore'
], function(answers, _) {
- describe("recursion", function() {
+ describe('recursion', function() {
var fileData = {
dir : 'app',
files : [
@@ -37,7 +37,7 @@ define([
]
};
- it("you should be able to return a list of files from the data", function() {
+ it('you should be able to return a list of files from the data', function() {
var result = answers.listFiles(fileData);
expect(result.length).to.eql(8);
expect(result.indexOf('index.html') > -1).to.be.ok;
@@ -45,7 +45,7 @@ define([
expect(result.indexOf('underscore.js') > -1).to.be.ok;
});
- it("you should be able to return a list of files in a subdir", function() {
+ it('you should be able to return a list of files in a subdir', function() {
var result = answers.listFiles(fileData, 'js');
expect(result.length).to.eql(5);
expect(result.indexOf('main.js') > -1).to.be.ok;
@@ -53,7 +53,7 @@ define([
});
});
- describe("permutation", function() {
+ describe('permutation', function() {
var arr = [ 1, 2, 3, 4 ];
var answer = [
[1, 2, 3, 4],
@@ -82,7 +82,7 @@ define([
[4, 3, 2, 1]
];
- it("you should be able to return the permutations of an array", function() {
+ it('you should be able to return the permutations of an array', function() {
var result = answers.permute(arr);
var resultStrings = _.map(result, function(r) { return r.join(''); });
View
14 tests/app/regex.js
@@ -5,13 +5,13 @@ if (typeof expect !== 'function') { var expect = require('expect.js'); }
define([
'app/regex'
], function(answers) {
- describe("regular expressions", function() {
- it("you should be able to detect a number in a string", function() {
+ describe('regular expressions', function() {
+ it('you should be able to detect a number in a string', function() {
expect(answers.containsNumber('abc123')).to.eql(true);
expect(answers.containsNumber('abc')).to.eql(false);
});
- it("you should be able to detect a repeating letter in a string", function() {
+ it('you should be able to detect a repeating letter in a string', function() {
expect(answers.containsRepeatingLetter('bookkeeping')).to.eql(true);
expect(answers.containsRepeatingLetter('rattler')).to.eql(true);
expect(answers.containsRepeatingLetter('ZEPPELIN')).to.eql(true);
@@ -19,20 +19,20 @@ define([
expect(answers.containsRepeatingLetter('l33t')).to.eql(false);
});
- it("you should be able to determine whether a string ends with a vowel (aeiou)", function() {
+ it('you should be able to determine whether a string ends with a vowel (aeiou)', function() {
expect(answers.endsWithVowel('cats')).to.eql(false);
expect(answers.endsWithVowel('gorilla')).to.eql(true);
expect(answers.endsWithVowel('I KNOW KUNG FU')).to.eql(true);
});
- it("you should be able to capture the first series of three numbers", function() {
+ it('you should be able to capture the first series of three numbers', function() {
expect(answers.captureThreeNumbers('abc123')).to.eql('123');
expect(answers.captureThreeNumbers('9876543')).to.eql('987');
expect(answers.captureThreeNumbers('abcdef')).to.eql(false);
expect(answers.captureThreeNumbers('12ab12ab')).to.eql(false);
});
- it("you should be able to determine whether a string matches a pattern", function() {
+ it('you should be able to determine whether a string matches a pattern', function() {
// the pattern is XXX-XXX-XXXX where all X's are digits
expect(answers.matchesPattern('800-555-1212')).to.eql(true);
expect(answers.matchesPattern('451-933-7899')).to.eql(true);
@@ -44,7 +44,7 @@ define([
expect(answers.matchesPattern('800-55-1212')).to.eql(false);
});
- it("you should be able to detect correctly-formatted monetary amounts in USD", function() {
+ it('you should be able to detect correctly-formatted monetary amounts in USD', function() {
expect(answers.isUSD('$132.03')).to.eql(true);
expect(answers.isUSD('$32.03')).to.eql(true);
expect(answers.isUSD('$2.03')).to.eql(true);
Please sign in to comment.
Something went wrong with that request. Please try again.