Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"env": {
"jasmine": true,
"node": true,
"mocha": true,
"browser": true,
"builtin": true
},
"globals": {
"require": false
},
"rules": {
"block-scoped-var": 2,
"dot-notation": [
2,
{
"allowKeywords": true
}
],
"eqeqeq": [
2,
"allow-null"
],
"guard-for-in": 2,
"new-cap": 2,
"no-caller": 2,
"no-cond-assign": [
2,
"except-parens"
],
"no-debugger": 2,
"no-empty": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-parens": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-loop-func": 2,
"no-multi-str": 2,
"no-new": 2,
"no-proto": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-undef": 2,
"no-unused-vars": [
2,
{"args": "none"}
],
"no-with": 2,
"quotes": [
2,
"single",
"avoid-escape"
],
"semi": [
0,
"never"
],
"strict": [
2,
"global"
],
"valid-typeof": 2,
"wrap-iife": [
2,
"inside"
]
}
}
11 changes: 0 additions & 11 deletions .jshintrc

This file was deleted.

26 changes: 11 additions & 15 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = function(grunt) {
"use strict";
'use strict';

module.exports = function(grunt) {
var _ = require('lodash');
var path = require('path');
var through = require('through2');
Expand All @@ -14,12 +14,12 @@ module.exports = function(grunt) {
var plugins = grunt.option('plugins');
// Create plugin paths and verify they exist
plugins = _.map(plugins ? plugins.split(',') : [], function (plugin) {
var path = 'plugins/' + plugin + '.js';
var p = 'plugins/' + plugin + '.js';

if(!grunt.file.exists(path))
if(!grunt.file.exists(p))
throw new Error("Plugin '" + plugin + "' not found in plugins directory.");

return path;
return p;
});

// custom browserify transformer to re-write plugins to
Expand Down Expand Up @@ -136,7 +136,7 @@ module.exports = function(grunt) {
compress: {
dead_code: true,
global_defs: {
"TEST": false
'TEST': false
}
}
},
Expand All @@ -151,11 +151,8 @@ module.exports = function(grunt) {
all: ['build/**/*.map']
},

jshint: {
options: {
jshintrc: '.jshintrc'
},
all: ['Gruntfile.js', 'src/**/*.js', 'plugins/**/*.js']
eslint: {
target: ['Gruntfile.js', 'src/**/*.js', 'plugins/**/*.js']
},

mocha: {
Expand Down Expand Up @@ -270,8 +267,7 @@ module.exports = function(grunt) {

grunt.registerMultiTask('fixSourceMaps', function () {
this.files.forEach(function (f) {
var result;
var sources = f.src.filter(function (filepath) {
f.src.filter(function (filepath) {
if (!grunt.file.exists(filepath)) {
grunt.log.warn('Source file "' + filepath + '" not found.');
return false;
Expand All @@ -294,7 +290,6 @@ module.exports = function(grunt) {
// Grunt contrib tasks
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');

Expand All @@ -305,6 +300,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-s3');
grunt.loadNpmTasks('grunt-gitinfo');
grunt.loadNpmTasks('grunt-sri');
grunt.loadNpmTasks('grunt-eslint');

// Build tasks
grunt.registerTask('_prep', ['clean', 'gitinfo', 'version']);
Expand All @@ -317,7 +313,7 @@ module.exports = function(grunt) {
grunt.registerTask('dist', ['build.core', 'copy:dist']);

// Test task
grunt.registerTask('test', ['jshint', 'browserify.core', 'browserify:test', 'mocha']);
grunt.registerTask('test', ['eslint', 'browserify.core', 'browserify:test', 'mocha']);

// Webserver tasks
grunt.registerTask('run:test', ['connect:test']);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"grunt-contrib-copy": "^0.8.2",
"grunt-contrib-jshint": "^0.11.3",
"grunt-contrib-uglify": "^0.11.0",
"grunt-eslint": "^17.3.1",
"grunt-gitinfo": "^0.1.7",
"grunt-mocha": "^0.4.15",
"grunt-release": "^0.13.0",
Expand Down
4 changes: 2 additions & 2 deletions plugins/angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ function angularPlugin(Raven, angular) {
['Raven', '$delegate', exceptionHandler]);
}

function exceptionHandler(Raven, $delegate) {
function exceptionHandler(R, $delegate) {
return function (ex, cause) {
Raven.captureException(ex, {
R.captureException(ex, {
extra: { cause: cause }
});
$delegate(ex, cause);
Expand Down
4 changes: 2 additions & 2 deletions plugins/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ function consolePlugin(Raven, console) {
logLevels = ['debug', 'info', 'warn', 'error'],
level = logLevels.pop();

var logForGivenLevel = function(level) {
var originalConsoleLevel = console[level];
var logForGivenLevel = function(l) {
var originalConsoleLevel = console[l];

// warning level is the only level that doesn't map up
// correctly with what Sentry expects.
Expand Down
22 changes: 13 additions & 9 deletions src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function Raven() {
this._plugins = [];
this._startTime = now();

for (var method in this._originalConsole) {
for (var method in this._originalConsole) { // eslint-disable-line guard-for-in
this._originalConsoleMethods[method] = this._originalConsole[method];
}
}
Expand Down Expand Up @@ -98,7 +98,7 @@ Raven.prototype = {
if (options) {
each(options, function(key, value){
// tags and extra are special and need to be put into context
if (key == 'tags' || key == 'extra') {
if (key === 'tags' || key === 'extra') {
self._globalContext[key] = value;
} else {
self._globalOptions[key] = value;
Expand Down Expand Up @@ -535,7 +535,9 @@ Raven.prototype = {
// IE9 if quirks
try {
document.fireEvent('on' + evt.eventType.toLowerCase(), evt);
} catch(e) {}
} catch(e) {
// Do nothing
}
}
},

Expand All @@ -555,7 +557,7 @@ Raven.prototype = {
// Make a copy of the arguments
var args = [].slice.call(arguments);
var originalCallback = args[0];
if (typeof (originalCallback) === 'function') {
if (typeof originalCallback === 'function') {
args[0] = self.wrap(originalCallback);
}

Expand Down Expand Up @@ -591,7 +593,9 @@ Raven.prototype = {
if (fn && fn.handleEvent) {
fn.handleEvent = self.wrap(fn.handleEvent);
}
} catch (err) {} // can sometimes get 'Permission denied to access property "handle Event'
} catch (err) {
// can sometimes get 'Permission denied to access property "handle Event'
}
return orig.call(this, evt, self.wrap(fn), capture, secure);
};
});
Expand Down Expand Up @@ -658,7 +662,7 @@ Raven.prototype = {
return dsn;
},

_handleOnErrorStackInfo: function(stackInfo, options) {
_handleOnErrorStackInfo: function() {
// if we are intentionally ignoring errors via onerror, bail out
if (!this._ignoreOnError) {
this._handleStackInfo.apply(this, arguments);
Expand Down Expand Up @@ -712,9 +716,9 @@ Raven.prototype = {

normalized.in_app = !( // determine if an exception came from outside of our app
// first we check the global includePaths list.
(!!this._globalOptions.includePaths.test && !this._globalOptions.includePaths.test(normalized.filename)) ||
!!this._globalOptions.includePaths.test && !this._globalOptions.includePaths.test(normalized.filename) ||
// Now we check for fun, if the function name is Raven or TraceKit
/(Raven|TraceKit)\./.test(normalized['function']) ||
/(Raven|TraceKit)\./.test(normalized.function) ||
// finally, we do a last ditch effort and check for raven.min.js
/raven\.(min\.)?js$/.test(normalized.filename)
);
Expand Down Expand Up @@ -762,7 +766,7 @@ Raven.prototype = {
},

_processException: function(type, message, fileurl, lineno, frames, options) {
var stacktrace, i, fullMessage;
var stacktrace, fullMessage;

if (!!this._globalOptions.ignoreErrors.test && this._globalOptions.ignoreErrors.test(message)) return;

Expand Down
8 changes: 4 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function isObject(what) {
}

function isEmptyObject(what) {
for (var k in what) return false;
for (var _ in what) return false; // eslint-disable-line guard-for-in, no-unused-vars
return true;
}

Expand Down Expand Up @@ -87,7 +87,7 @@ function joinRegExp(patterns) {
if (isString(pattern)) {
// If it's a string, we need to escape it
// Taken from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
sources.push(pattern.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"));
sources.push(pattern.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1'));
} else if (pattern && pattern.source) {
// If it's a regexp already, we want to extract the source
sources.push(pattern.source);
Expand Down Expand Up @@ -126,13 +126,13 @@ function uuid4() {
return v;
};

return (pad(arr[0]) + pad(arr[1]) + pad(arr[2]) + pad(arr[3]) + pad(arr[4]) +
return pad(arr[0]) + pad(arr[1] + pad(arr[2]) + pad(arr[3]) + pad(arr[4]) +
pad(arr[5]) + pad(arr[6]) + pad(arr[7]));
} else {
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0,
v = c == 'x' ? r : (r&0x3|0x8);
v = c === 'x' ? r : r&0x3|0x8;
return v.toString(16);
});
}
Expand Down