-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add eslint, prettier and lint staged configs * chore: run eslint:fix * chore: run prettier
- Loading branch information
1 parent
9b9926e
commit a01caf5
Showing
53 changed files
with
28,860 additions
and
24,490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.json | ||
*.html | ||
*.less | ||
*.css | ||
package.json | ||
docusaurus.config.js | ||
public/ | ||
src/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module.exports = { | ||
parserOptions: { | ||
ecmaVersion: 2020, | ||
sourceType: 'module', | ||
}, | ||
extends: ['eslint:recommended', 'prettier'], | ||
root: true, | ||
env: { | ||
node: true, | ||
jquery: true, | ||
es2017: true, | ||
browser: true, | ||
webextensions: true, | ||
}, | ||
rules: { | ||
// TODO: currently a lot of these issues are marked as | ||
// warnings because they are in the codebase already | ||
// and I don't want to fix them all at once. | ||
// Eventually, they should be fixed and the rules | ||
// should be set to 'error' (default in preset). | ||
'no-var': 'warn', | ||
'no-unused-vars': 'warn', | ||
'no-undef': 'warn', | ||
'no-redeclare': 'warn', | ||
'no-prototype-builtins': 'warn', | ||
'no-empty': 'warn', | ||
'no-inner-declarations': 'warn', | ||
'no-fallthrough': 'warn', | ||
'no-useless-escape': 'warn', | ||
'no-constant-condition': 'warn', | ||
'no-unreachable': 'warn', | ||
'no-duplicate-case': 'warn', | ||
'no-dupe-keys': 'warn', | ||
'no-irregular-whitespace': 'warn', | ||
'no-case-declarations': 'warn', | ||
'prefer-template': 'warn', | ||
'comma-dangle': ['warn', 'always-multiline'], | ||
semi: ['error', 'always'], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"**/*.{tsx,js}": [ | ||
"prettier --write --ignore-unknown", | ||
"eslint --fix --ext .tsx,.js" | ||
], | ||
"**/*.{html,md,mdx,less,css,json}": ["prettier --write --ignore-unknown"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# node.js npm related | ||
|
||
node_modules/ | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Configurator Build process | ||
cache/ | ||
apps/ | ||
dist/ | ||
public/ | ||
src/vendor/ | ||
dist_cordova/ | ||
debug/ | ||
release/ | ||
testresults/ | ||
.eslintcache | ||
cordova/bundle.keystore | ||
|
||
# OSX | ||
.DS_store | ||
|
||
# artefacts for Visual Studio Code | ||
/.vscode/ | ||
|
||
# NetBeans | ||
nbproject/ | ||
|
||
# IntelliJ | ||
.idea | ||
|
||
# Eclipse | ||
.project | ||
.settings/ | ||
test-results-junit/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,88 @@ | ||
/** | ||
* A FIFO cache to hold key-pair mappings. Its capacity will be at least the initialCapacity | ||
* supplied on creation, which you can increase by increasing the "capacity" property. | ||
* | ||
* supplied on creation, which you can increase by increasing the "capacity" property. | ||
* | ||
* One extra element beyond the set capacity will be stored which can be fetched by calling "recycle()". | ||
* This allows the oldest value to be removed in order to be reused, instead of leaving it to be collected | ||
* This allows the oldest value to be removed in order to be reused, instead of leaving it to be collected | ||
* by the garbage collector. | ||
* | ||
* | ||
* Element age is determined by the time it was added or last get()'d from the cache. | ||
*/ | ||
export function FIFOCache(initialCapacity) { | ||
//Private: | ||
var | ||
queue = [], | ||
items = {}; | ||
//Private: | ||
let queue = [], | ||
items = {}; | ||
|
||
function removeFromQueue(key) { | ||
for (var i = 0; i < queue.length; i++) { | ||
if (queue[i] == key) { | ||
//Assume there's only one copy to remove: | ||
for (var j = i; j < queue.length - 1; j++) { | ||
queue[j] = queue[j + 1]; | ||
} | ||
|
||
queue.length--; | ||
break; | ||
} | ||
function removeFromQueue(key) { | ||
for (let i = 0; i < queue.length; i++) { | ||
if (queue[i] == key) { | ||
//Assume there's only one copy to remove: | ||
for (let j = i; j < queue.length - 1; j++) { | ||
queue[j] = queue[j + 1]; | ||
} | ||
|
||
queue.length--; | ||
break; | ||
} | ||
} | ||
|
||
//Public: | ||
this.capacity = initialCapacity; | ||
|
||
/** | ||
* Remove and return the oldest value from the cache to be reused, or null if the cache wasn't full. | ||
*/ | ||
this.recycle = function() { | ||
if (queue.length > this.capacity) { | ||
var | ||
key = queue.shift(), | ||
result = items[key]; | ||
|
||
delete items[key]; | ||
|
||
return result; | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
/** | ||
* Add a mapping for the given key to the cache. If an existing value with that key was | ||
* present, it will be overwritten. | ||
*/ | ||
this.add = function(key, value) { | ||
// Was this already cached? Bump it back up to the end of the queue | ||
if (items[key] !== undefined) | ||
removeFromQueue(key); | ||
|
||
queue.push(key); | ||
|
||
items[key] = value; | ||
|
||
while (queue.length > this.capacity + 1) { | ||
delete items[queue.shift()]; | ||
} | ||
}; | ||
|
||
/** | ||
* Return the value in the cache that corresponds to the given key, or undefined if it has | ||
* expired or had never been stored. | ||
*/ | ||
this.get = function(key) { | ||
var item = items[key]; | ||
|
||
if (item) { | ||
removeFromQueue(key); | ||
queue.push(key); | ||
} | ||
|
||
return item; | ||
}; | ||
|
||
/** | ||
* Erase the entire content of the cache | ||
*/ | ||
this.clear = function() { | ||
queue = []; | ||
items = {}; | ||
}; | ||
} | ||
} | ||
|
||
//Public: | ||
this.capacity = initialCapacity; | ||
|
||
/** | ||
* Remove and return the oldest value from the cache to be reused, or null if the cache wasn't full. | ||
*/ | ||
this.recycle = function () { | ||
if (queue.length > this.capacity) { | ||
let key = queue.shift(), | ||
result = items[key]; | ||
|
||
delete items[key]; | ||
|
||
return result; | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
/** | ||
* Add a mapping for the given key to the cache. If an existing value with that key was | ||
* present, it will be overwritten. | ||
*/ | ||
this.add = function (key, value) { | ||
// Was this already cached? Bump it back up to the end of the queue | ||
if (items[key] !== undefined) removeFromQueue(key); | ||
|
||
queue.push(key); | ||
|
||
items[key] = value; | ||
|
||
while (queue.length > this.capacity + 1) { | ||
delete items[queue.shift()]; | ||
} | ||
}; | ||
|
||
/** | ||
* Return the value in the cache that corresponds to the given key, or undefined if it has | ||
* expired or had never been stored. | ||
*/ | ||
this.get = function (key) { | ||
let item = items[key]; | ||
|
||
if (item) { | ||
removeFromQueue(key); | ||
queue.push(key); | ||
} | ||
|
||
return item; | ||
}; | ||
|
||
/** | ||
* Erase the entire content of the cache | ||
*/ | ||
this.clear = function () { | ||
queue = []; | ||
items = {}; | ||
}; | ||
} |
Oops, something went wrong.