Skip to content
This repository has been archived by the owner on Jun 24, 2020. It is now read-only.

Commit

Permalink
Replace jshint with eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
anselmbradford committed May 18, 2016
1 parent 8c5a6b3 commit b317f2e
Show file tree
Hide file tree
Showing 56 changed files with 4,883 additions and 3,589 deletions.
986 changes: 986 additions & 0 deletions .eslintrc

Large diffs are not rendered by default.

93 changes: 42 additions & 51 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
module.exports = function(grunt) {
module.exports = function( grunt ) {

'use strict';

var path = require('path');
var path = require( 'path' );

require('time-grunt')(grunt);
require( 'time-grunt' )( grunt );

// Allows a `--quiet` flag to be passed to Grunt from the command-line.
// If the flag is present the value is true, otherwise it is false.
// This flag can be used to, for example, suppress warning output
// from linters.
var env = {
quiet: grunt.option('quiet') ? true : false
};

grunt.initConfig({

Expand Down Expand Up @@ -367,56 +375,34 @@ module.exports = function(grunt) {
},

/**
* JSHint: https://github.com/gruntjs/grunt-contrib-jshint
*
* Validate files with JSHint.
* Below are options that conform to idiomatic.js standards.
* Feel free to add/remove your favorites: http://www.jshint.com/docs/#options
* Lint the JavaScript.
*/
jshint: {
options: {
asi: false,
bitwise: true,
boss: true,
camelcase: true,
eqeqeq: true,
eqnull: true,
evil: true,
expr: true,
forin: true,
immed: true,
indent: 2,
latedef: false,
maxdepth: 4,
maxparams: 4,
maxstatements: 300,
newcap: true,
noarg: true,
noempty: true,
nonew: true,
quotmark: true,
strict: false,
trailing: true,
undef: true,
node: true,
browser: true,
jquery: true,
globals: {
jQuery: true,
$: true,
module: true,
require: true,
define: true,
console: true,
EventEmitter: true
}
},
files: [
'src/static/js/**/*',
'!node_modules/**/*',
'!src/static/js/main.js'
]
lint: {
/**
* Validate files with ESLint.
* https://www.npmjs.com/package/grunt-contrib-eslint
*/
eslint: {
options: {
quiet: env.quiet
},
src: [
// 'Gruntfile.js', // Uncomment to lint the Gruntfile.
'src/static/js/**/*.js',
// Ignore polyfills.
'!src/static/js/modules/local-storage-polyfill.js',
'!src/static/js/modules/placeholder-polyfill.js',
'!src/static/js/modules/object.observe-polyfill.js',
'!src/static/js/modules/placeholder-polyfill.js',
'!src/static/js/legacy/**/*.js',
// Ignore React components.
'!src/static/js/modules/loan-comparison.js',
'!src/static/js/modules/monthly-payment-worksheet.js',
'!src/static/js/modules/loan-comparison/components/**/*.js'
]
}
},

mocha_istanbul: {
coverage: {
src: ['test/js/*.js'], // multiple folders also works
Expand Down Expand Up @@ -539,6 +525,11 @@ module.exports = function(grunt) {
grunt.registerTask('dev-deploy', ['reset', 'js', 'css', 'copy', 'concat:ie9', 'concat:ie8', 'test']);
grunt.registerTask('ship', ['uglify', 'cssmin', 'usebanner']);
grunt.registerTask('test', ['browserify:tests', 'mocha_istanbul']);
grunt.registerMultiTask('lint', 'Lint the JavaScript', function(){
grunt.config.set(this.target, this.data);
grunt.task.run(this.target);
});

grunt.registerTask('release', ['clean:dist', 'js', 'browserify:tests', 'css', 'copy:release', 'copy:img', 'copy:fonts', 'concat:ie9', 'concat:ie8']);
grunt.registerTask('production-deploy', ['release', 'ship']);
grunt.registerTask('default', ['dev-deploy', 'ship']);
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ If you already have [Autoenv](https://github.com/kennethreitz/autoenv) installed
```
(OAH)username$
```

If the virtualenv did not activate right away, run this command from the directory above where the OAH directory lives:
```
$ source OAH/bin/activate
```

To deactivate, use the command `deactivate`.

4. Install sheer into the virtualenv with the `-e` flag (which allows you to make changes to sheer itself). The path to sheer is the root directory of the GitHub repository you checked out (cloned) earlier, which likely will be `./sheer`:
Expand Down Expand Up @@ -159,7 +159,7 @@ The Rate Checker and Mortgage Insurance are JavaScript applications for checking
#### Private API Users
To configure the Rate Checker and Loan Comparison you will need to point to the required API URLs in `config/config.json`.
To configure the Rate Checker and Loan Comparison you will need to point to the required API URLs in `config/config.json`.
1. In `config/config.json`, change lines to point to the API URLs, respectively:
```json
Expand Down Expand Up @@ -200,9 +200,9 @@ Elastic Search needs to be running to display wordpress content:
```bash
$ elasticsearch
```

### Sheer workflow
Sheer needs to be running to compile the templates in `_layouts`.
Sheer needs to be running to compile the templates in `_layouts`.

1. Use the sheer virtualenv:
```bash
Expand Down Expand Up @@ -230,7 +230,11 @@ Grunt watch will recompile Less and JS everytime you save changes to those proje

To view the site browse to: <http://localhost:7000>

## Browser tests
## How to test the software

### Linting JavaScript

JavaScript errors and warnings can be detected and corrected by running `grunt lint`.

### Browser test setup

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
"grunt-contrib-concat": "latest",
"grunt-contrib-copy": "latest",
"grunt-contrib-cssmin": "^0.9.0",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-less": "~0.11.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-watch": "~0.4.4",
"grunt-eslint": "^18.1.0",
"grunt-mocha-istanbul": "^2.3.1",
"grunt-newer": "^0.7.0",
"grunt-release": "latest",
Expand Down
14 changes: 6 additions & 8 deletions src/static/js/app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
var $ = require('jquery');
'use strict';

$(function() {
var $ = require( 'jquery' );

'use strict';

require('./modules/loan-options');
require('./modules/rate-checker');

});
$( function() {
require( './modules/loan-options' );
require( './modules/rate-checker' );
} );
6 changes: 5 additions & 1 deletion src/static/js/legacy/ie9.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
'use strict';

if ( typeof console === 'undefined' ) {
console = {};
console.log = function(){};
console.log = function() {
// noop function.
};
}
16 changes: 9 additions & 7 deletions src/static/js/legacy/lte-ie8.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
var cfHead = document.getElementsByTagName('head')[0],
cfStyle = document.createElement('style');
'use strict';

var cfHead = document.getElementsByTagName( 'head' )[0],
cfStyle = document.createElement( 'style' );
cfStyle.type = 'text/css';
cfStyle.styleSheet.cssText = ':before,:after{content:none !important}';
cfHead.appendChild(cfStyle);
setTimeout(function(){
cfHead.removeChild(cfStyle);
}, 300);
cfHead.appendChild( cfStyle );
setTimeout( function() {
cfHead.removeChild(cfStyle);
}, 300 );

// Some polyfills

Expand Down Expand Up @@ -175,4 +177,4 @@ if (!Array.isArray) {
Array.isArray = function(arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
};
}
}
12 changes: 7 additions & 5 deletions src/static/js/modules/analytics/delay.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
var delay = (function(){
'use strict';

var delay = ( function() {
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
return function( callback, ms ) {
clearTimeout( timer );
timer = setTimeout( callback, ms );
};
})();
} )();

module.exports = delay;

0 comments on commit b317f2e

Please sign in to comment.