mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-22 02:12:44 +01:00
Add .jshintrc, and use the "use strict" directive
.jshintrc's otion-set is a personal choice, merely a suggestion. Beside that, it includes some common globals for specific browsers, so there's no need to set the globals in every .js file. In order to force strict coding, "use strict" directive was added into every .js file.
This commit is contained in:
parent
4278121f74
commit
0886f7e886
20
src/.jshintrc
Normal file
20
src/.jshintrc
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"browser": true,
|
||||
"devel": true,
|
||||
"esnext": true,
|
||||
"globalstrict": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"nonew": false,
|
||||
"sub": true,
|
||||
"boss": true,
|
||||
"laxbreak": true,
|
||||
"validthis": true,
|
||||
"newcap": false,
|
||||
"-W058": true, // suppress "Missing '()' invoking a constructor" message
|
||||
"globals": {
|
||||
"chrome": false,
|
||||
"safari": false,
|
||||
"Components": false // global variable in Firefox
|
||||
}
|
||||
}
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global chrome, vAPI, uDom */
|
||||
/* global vAPI, uDom */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global vAPI, uDom */
|
||||
/* global µBlock, vAPI, uDom */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global µBlock, uDom */
|
||||
/* global µBlock, vAPI, uDom */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global chrome, vAPI, uDom */
|
||||
/* global vAPI, uDom */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global chrome, µBlock, YaMD5 */
|
||||
/* global µBlock, vAPI, YaMD5 */
|
||||
'use strict';
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global µBlock */
|
||||
/* global µBlock, vAPI */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global chrome */
|
||||
/* global vAPI */
|
||||
/* exported µBlock */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -30,7 +32,7 @@ var µBlock = (function() {
|
||||
var oneSecond = 1000;
|
||||
var oneMinute = 60 * oneSecond;
|
||||
var oneHour = 60 * oneMinute;
|
||||
var oneDay = 24 * oneHour;
|
||||
// var oneDay = 24 * oneHour;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,18 +19,24 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global chrome, vAPI */
|
||||
/* global vAPI */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// Injected into content pages
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// because Safari
|
||||
if (location.protocol !== "http:" && location.protocol !== "https:") {
|
||||
throw "uBlock> contentscript-end.js > Skipping page... " + location.protocol + location.host;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
var messager = vAPI.messaging.channel('contentscript-end.js');
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
// ABP cosmetic filters
|
||||
|
@ -20,7 +20,10 @@
|
||||
*/
|
||||
|
||||
/* jshint multistr: true */
|
||||
/* global chrome */
|
||||
/* global vAPI */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// Injected into content pages
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global chrome, µBlock */
|
||||
/* global vAPI, µBlock */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
/* jshint bitwise: false */
|
||||
/* global µBlock */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,6 +19,9 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global uDom */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
uDom.onLoad(function() {
|
||||
|
@ -19,6 +19,9 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global uDom */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(function() {
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global CSS, chrome, vAPI */
|
||||
/* global messager, CSS */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
@ -107,7 +108,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
}(window));
|
||||
}(this));
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
@ -19,6 +19,11 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global vAPI, uDom */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// Helper to deal with the i18n'ing of HTML files.
|
||||
|
||||
uDom.onLoad(function() {
|
||||
|
@ -1,4 +1,6 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
document.body.style.display = "none";
|
||||
document.addEventListener("DOMContentLoaded", function onDOMReady(e) {
|
||||
document.removeEventListener(e.type, onDOMReady, false);
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
/* jshint bitwise: false */
|
||||
/* global µBlock */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -60,16 +61,16 @@ var meltBucket = function(ldict, len, bucket) {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
var melt = function(ldict) {
|
||||
var buckets = ldict.dict;
|
||||
var bucket;
|
||||
for ( var key in buckets ) {
|
||||
bucket = buckets[key];
|
||||
if ( typeof bucket === 'string' ) {
|
||||
buckets[key] = meltBucket(ldict, key.charCodeAt(0) & 0xFF, bucket);
|
||||
}
|
||||
}
|
||||
};
|
||||
// var melt = function(ldict) {
|
||||
// var buckets = ldict.dict;
|
||||
// var bucket;
|
||||
// for ( var key in buckets ) {
|
||||
// bucket = buckets[key];
|
||||
// if ( typeof bucket === 'string' ) {
|
||||
// buckets[key] = meltBucket(ldict, key.charCodeAt(0) & 0xFF, bucket);
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global vAPI, µBlock, YaMD5 */
|
||||
/* global µBlock, vAPI, YaMD5 */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -20,7 +20,8 @@
|
||||
*/
|
||||
|
||||
/* jshint bitwise: false */
|
||||
/* global chrome, YaMD5, µBlock */
|
||||
/* global µBlock, vAPI, YaMD5 */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,8 +19,9 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* jshint esnext: true, bitwise: false */
|
||||
/* jshint bitwise: false */
|
||||
/* global µBlock */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -20,7 +20,8 @@
|
||||
*/
|
||||
|
||||
/* jshint bitwise: false */
|
||||
/* global µBlock */
|
||||
/* global µBlock, vAPI */
|
||||
'use strict';
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
*/
|
||||
|
||||
/* global vAPI, uDom */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
(function() {
|
||||
|
@ -19,6 +19,9 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* exported quickProfiler */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
var quickProfiler = (function() {
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
/* global vAPI, uDom */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
/* global µBlock */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
/* jshint bitwise: false */
|
||||
/* global uDom, vAPI */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global chrome, µBlock, punycode, publicSuffixList */
|
||||
/* global µBlock, vAPI, punycode, publicSuffixList */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global µBlock */
|
||||
/* global µBlock, vAPI */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global µBlock */
|
||||
/* global µBlock, vAPI */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
/* global µBlock */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -20,6 +20,10 @@
|
||||
*/
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* exported uDom */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// It's just a silly, minimalist DOM framework: this allows me to not rely
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
/* global µBlock, publicSuffixList */
|
||||
'use strict';
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@ -33,7 +34,7 @@ Naming convention from https://en.wikipedia.org/wiki/URI_scheme#Examples
|
||||
|
||||
// This will inserted as a module in the µBlock object.
|
||||
|
||||
µBlock = typeof µBlock === "undefined" ? {} : µBlock;
|
||||
var µBlock = typeof µBlock === "undefined" ? {} : µBlock;
|
||||
|
||||
µBlock.URI = (function() {
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global chrome, µBlock */
|
||||
/* global µBlock */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
// for non background pages
|
||||
/* global chrome, Components, safari */
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
@ -1,5 +1,4 @@
|
||||
// only for background and other extension pages
|
||||
/* global chrome, Components, BeforeLoadEvent */
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global chrome, vAPI, uDom */
|
||||
/* global vAPI, uDom */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global chrome, µBlock */
|
||||
/* global µBlock, vAPI */
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user