Skip to content

Commit

Permalink
update packages to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
folkvir committed Nov 6, 2024
1 parent f448b2b commit 6da11b2
Show file tree
Hide file tree
Showing 32 changed files with 365 additions and 422 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

87 changes: 87 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
const tseslint = require('@typescript-eslint/eslint-plugin')
const prettier = require('eslint-plugin-prettier')
const parser = require('@typescript-eslint/parser')
const node = require('eslint-plugin-node')
const { fixupPluginRules } = require('@eslint/compat')
const js = require('@eslint/js')
const globals = require('globals')


module.exports = [
js.configs.recommended,
{
files: ['src/**/*.ts'],
ignores: [
'dist/',
'docs/',
'build/',
'node_modules/',
'.github',
],
languageOptions: {
parser,
parserOptions: {
ecmaVersion: '2015',
project: 'tsconfig.json'
},
globals: {
...globals.browser,
...globals.amd,
...globals.mocha,
...globals.node,
...globals.nodeBuiltin,
}
},
plugins: {
'@typescript-eslint': tseslint,
prettier: fixupPluginRules(prettier),
node: fixupPluginRules(node),
},
settings: {
node: {
allowModules: [],
resolvePaths: [
'./src'
],
tryExtensions: [
'.ts',
'.js'
]
}
},
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"],
'node/no-unsupported-features/es-syntax': [
'error',
{
ignores: [
'modules'
]
}
],
'node/no-unsupported-features/es-builtins': [
'error',
{
ignores: []
}
],
'node/no-unpublished-require': [
'error',
{
allowModules: [
'mocha',
'chai',
'random'
]
}
]
}
}
]






78 changes: 11 additions & 67 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "mocha test/**/*-test.js --trace-deprecation --timeout=60000",
"doc": "typedoc --sort alphabetical --out docs/ --emit both --includeVersion src/api.ts",
"lint": "yarn prettier && yarn slint",
"slint": "eslint --fix src/**/*.ts",
"slint": "eslint src --fix",
"prettier": "prettier --config package.json --write \"(src|test)/**/*.(t|j)s\"",
"clean": "rimraf docs/ dist/ build/",
"compile": "tsc"
Expand Down Expand Up @@ -47,6 +47,7 @@
},
"homepage": "https://github.com/Callidon/bloom-filters#readme",
"devDependencies": {
"@eslint/compat": "^1.2.2",
"@types/cuint": "^0.2.X",
"@types/lodash": "^4.17.13",
"@types/lodash.eq": "^4.0.9",
Expand All @@ -55,27 +56,27 @@
"@types/lodash.sortedindexby": "^4.6.9",
"@types/node": "^22.9.0",
"@types/xxhashjs": "^0.2.X",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "^5.0.0",
"chai": "^4.3.6",
"eslint": "^8.57.1",
"eslint-config-prettier": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
"chai": "4",
"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.12.0",
"lodash.intersection": "^4.4.0",
"lodash.range": "^3.2.0",
"lodash.union": "^4.6.0",
"mocha": "10.8.2",
"mocha": "^10.8.2",
"prettier": "^3.3.3",
"random": "5.1.1",
"rimraf": "^6.0.1",
"typedoc": "0.26.11",
"typedoc-plugin-missing-exports": "^3.0.0",
"typescript": "4.7.x"
"typescript": "^5.6.3"
},
"resolutions": {
"mocha/glob": "^11.0.0",
"typedoc/glob": "^11.0.0"
"mocha/glob": "^11"
},
"dependencies": {
"@types/seedrandom": "3.0.8",
Expand All @@ -99,63 +100,6 @@
"trailingComma": "es5",
"arrowParens": "avoid"
},
"eslintConfig": {
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2015,
"project": "tsconfig.json"
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:node/recommended",
"prettier",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"plugins": [
"@typescript-eslint",
"prettier"
],
"globals": {
"chai": "readonly",
"it": "readonly",
"expect": "readonly",
"describe": "readonly"
},
"settings": {
"node": {
"allowModules": [],
"resolvePaths": [
"./src"
],
"tryExtensions": [
".ts",
".js"
]
}
},
"rules": {
"node/no-unsupported-features/es-syntax": [
"error",
{
"ignores": [
"modules"
]
}
],
"node/no-unpublished-require": [
"error",
{
"allowModules": [
"mocha",
"chai",
"random"
]
}
]
}
},
"engines": {
"node": ">=12"
}
Expand Down
4 changes: 4 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

// For documentation
export {type HashableInput as HashableInput} from './utils'

// API
export {default as BaseFilter} from './base-filter'
export {default as BloomFilter} from './bloom/bloom-filter'
export {default as BitSet} from './bloom/bit-set'
Expand Down
3 changes: 1 addition & 2 deletions src/base-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export default abstract class BaseFilter {
/**
* Save the current structure as a JSON
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public saveAsJSON(): any {
throw new Error('not-implemented')
}
Expand All @@ -87,7 +86,7 @@ export default abstract class BaseFilter {
* @param json the JSON object to load
* @return Return the Object loaded from the provided JSON object
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public static fromJSON(json: JSON): any {
throw new Error(`not-implemented`)
}
Expand Down
4 changes: 2 additions & 2 deletions src/bloom/bit-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default class BitSet {

/**
* Returns the index of the maximum bit in the number, or -1 for 0
* @bits an unsigned 8-bit number
* @param bits an unsigned 8-bit number
* ```js
* @example
* BitSet.highBit(0) // returns -1
Expand All @@ -155,7 +155,7 @@ export default class BitSet {

/**
* Returns the number of true bits in the number
* @bits an unsigned 8-bit number
* @param bits an unsigned 8-bit number
* @example
* ```js
* BitSet.countBits(0) // returns 0
Expand Down
2 changes: 1 addition & 1 deletion src/bloom/scalable-bloom-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class ScalableBloomFilter
*/
@Field(
(filters: PartitionBloomFilter[]) =>
filters.map(filter => filter.saveAsJSON()), // eslint-disable-line @typescript-eslint/no-unsafe-return
filters.map(filter => filter.saveAsJSON()),
(array: []) =>
array.map(
data => PartitionBloomFilter.fromJSON(data) as PartitionBloomFilter
Expand Down
2 changes: 1 addition & 1 deletion src/bloom/xor-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default class XorFilter extends BaseFilter {
const l1 = this._readBuffer(this._filter[h1])
const l2 = this._readBuffer(this._filter[h2])
const xored = fingerprint ^ l0 ^ l1 ^ l2
const constant = CONSTANTS.get(this._bits)! // eslint-disable-line @typescript-eslint/no-non-null-assertion
const constant = CONSTANTS.get(this._bits)!
return (xored & constant) === 0
}

Expand Down
9 changes: 4 additions & 5 deletions src/cuckoo/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,18 @@ import {cloneObject} from '../exportable'
* @private
*/
@Exportable({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
export: cloneObject('Bucket', '_size', '_elements'),
// eslint-disable-next-line @typescript-eslint/no-explicit-any

import: (json: any) => {
if (
(json.type !== 'Bucket' || !('_size' in json), !('_elements' in json)) // eslint-disable-line @typescript-eslint/no-unsafe-member-access
(json.type !== 'Bucket' || !('_size' in json), !('_elements' in json))
) {
throw new Error(
'Cannot create a Bucket from a JSON export which does not represent a bucket'
)
}
const bucket = new Bucket(json._size as number) // eslint-disable-line @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
const bucket = new Bucket(json._size as number)

json._elements.forEach((elt: any, i: number) => {
if (elt !== null) {
bucket._elements[i] = elt
Expand Down
13 changes: 5 additions & 8 deletions src/cuckoo/cuckoo-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ function computeFingerpintLength(size: number, rate: number): number {
* @author Thomas Minier & Arnaud Grall
*/
@Exportable({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
export: cloneObject(
'CuckooFilter',
'_size',
Expand All @@ -61,9 +60,8 @@ function computeFingerpintLength(size: number, rate: number): number {
'_filter',
'_seed'
),
// eslint-disable-next-line @typescript-eslint/no-explicit-any

import: (json: any) => {
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */
if (
json.type !== 'CuckooFilter' ||
!('_size' in json) ||
Expand All @@ -84,10 +82,10 @@ function computeFingerpintLength(size: number, rate: number): number {
json._maxKicks as number | undefined
)
filter._length = json._length
// eslint-disable-next-line @typescript-eslint/no-explicit-any

filter._filter = json._filter.map((j: any) => {
const bucket = new Bucket<string>(j._size as number)
// eslint-disable-next-line @typescript-eslint/no-explicit-any

j._elements.forEach((elt: any, i: number) => {
if (elt !== null) {
bucket._elements[i] = elt
Expand All @@ -98,7 +96,6 @@ function computeFingerpintLength(size: number, rate: number): number {
})
filter.seed = json._seed
return filter
/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */
},
})
export default class CuckooFilter
Expand Down Expand Up @@ -254,7 +251,7 @@ export default class CuckooFilter
this._filter[index].length - 1,
this.random
)
const tmp = this._filter[index].at(rndIndex)! // eslint-disable-line @typescript-eslint/no-non-null-assertion
const tmp = this._filter[index].at(rndIndex)!
logs.push([index, rndIndex, tmp])
this._filter[index].set(rndIndex, movedElement)
movedElement = tmp
Expand All @@ -279,7 +276,7 @@ export default class CuckooFilter
if (throwError) {
// rollback all operations
throw new Error(
`The Cuckoo Filter is full, cannot insert element "${element}"` // eslint-disable-line @typescript-eslint/restrict-template-expressions
`The Cuckoo Filter is full, cannot insert element "${element}"`
)
} else {
return false
Expand Down
Loading

0 comments on commit 6da11b2

Please sign in to comment.