From d227dfba0cb7877bae6ea05ef2591ec75cdae2bd Mon Sep 17 00:00:00 2001 From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com> Date: Thu, 11 Jan 2024 08:26:29 -0500 Subject: [PATCH] Merge pull request #16393 from overleaf/em-typescript-libraries Add type checking to libraries GitOrigin-RevId: bed79f5123081773d6ac6e27698246726184c5e6 --- libraries/access-token-encryptor/package.json | 19 +++-- .../access-token-encryptor/tsconfig.json | 7 ++ libraries/fetch-utils/package.json | 20 +++--- libraries/fetch-utils/tsconfig.json | 7 ++ libraries/logger/package.json | 20 ++++-- libraries/logger/tsconfig.json | 7 ++ libraries/metrics/package.json | 21 +++--- libraries/metrics/tsconfig.json | 7 ++ libraries/o-error/package.json | 17 +++-- libraries/o-error/tsconfig.json | 7 ++ libraries/object-persistor/package.json | 20 +++--- libraries/object-persistor/tsconfig.json | 7 ++ libraries/overleaf-editor-core/package.json | 16 +++-- .../test/operation.test.js | 4 +- libraries/overleaf-editor-core/tsconfig.json | 17 ++--- libraries/promise-utils/package.json | 19 ++--- libraries/promise-utils/tsconfig.json | 7 ++ libraries/ranges-tracker/package.json | 18 +++-- libraries/ranges-tracker/test/notests.js | 1 + libraries/ranges-tracker/tsconfig.json | 7 ++ libraries/redis-wrapper/package.json | 18 +++-- libraries/redis-wrapper/tsconfig.json | 7 ++ libraries/settings/package.json | 19 +++-- libraries/settings/test/notests.js | 1 + libraries/settings/tsconfig.json | 7 ++ libraries/stream-utils/package.json | 22 +++--- libraries/stream-utils/tsconfig.json | 7 ++ package-lock.json | 70 +++++++++++++------ 28 files changed, 276 insertions(+), 123 deletions(-) create mode 100644 libraries/access-token-encryptor/tsconfig.json create mode 100644 libraries/fetch-utils/tsconfig.json create mode 100644 libraries/logger/tsconfig.json create mode 100644 libraries/metrics/tsconfig.json create mode 100644 libraries/o-error/tsconfig.json create mode 100644 libraries/object-persistor/tsconfig.json create mode 100644 libraries/promise-utils/tsconfig.json create mode 100644 libraries/ranges-tracker/test/notests.js create mode 100644 libraries/ranges-tracker/tsconfig.json create mode 100644 libraries/redis-wrapper/tsconfig.json create mode 100644 libraries/settings/test/notests.js create mode 100644 libraries/settings/tsconfig.json create mode 100644 libraries/stream-utils/tsconfig.json diff --git a/libraries/access-token-encryptor/package.json b/libraries/access-token-encryptor/package.json index ea340c8cd5..9b09bb76ae 100644 --- a/libraries/access-token-encryptor/package.json +++ b/libraries/access-token-encryptor/package.json @@ -3,13 +3,17 @@ "version": "3.0.0", "description": "", "main": "index.js", + "types": "./types/index.js", "scripts": { - "test": "mocha test/**/*.js", - "lint": "eslint --max-warnings 0 --format unix .", - "lint:fix": "eslint --fix .", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "test:ci": "npm run test" + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "test:ci": "npm run test:unit", + "typecheck": "tsc --noEmit", + "test:unit": "mocha --exit test/**/*.{js,cjs}", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" }, "author": "", "license": "AGPL-3.0-only", @@ -22,6 +26,7 @@ "devDependencies": { "chai": "^4.3.6", "mocha": "^10.2.0", - "sandboxed-module": "^2.0.4" + "sandboxed-module": "^2.0.4", + "typescript": "^5.0.4" } } diff --git a/libraries/access-token-encryptor/tsconfig.json b/libraries/access-token-encryptor/tsconfig.json new file mode 100644 index 0000000000..d43bb2470a --- /dev/null +++ b/libraries/access-token-encryptor/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] +} diff --git a/libraries/fetch-utils/package.json b/libraries/fetch-utils/package.json index 09f1daaa60..2dddd54fc1 100644 --- a/libraries/fetch-utils/package.json +++ b/libraries/fetch-utils/package.json @@ -3,14 +3,17 @@ "version": "0.1.0", "description": "utilities for node-fetch", "main": "index.js", + "types": "types/index.js", "scripts": { - "test": "npm run lint && npm run format && npm run test:unit", - "test:unit": "mocha", - "lint": "eslint --max-warnings 0 --format unix .", - "lint:fix": "eslint --fix .", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "test:ci": "npm run test:unit" + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "test:ci": "npm run test:unit", + "typecheck": "tsc --noEmit", + "test:unit": "mocha --exit test/**/*.{js,cjs}", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" }, "author": "Overleaf (https://www.overleaf.com)", "license": "AGPL-3.0-only", @@ -19,7 +22,8 @@ "chai": "^4.3.6", "chai-as-promised": "^7.1.1", "express": "^4.18.2", - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" }, "dependencies": { "@overleaf/o-error": "*", diff --git a/libraries/fetch-utils/tsconfig.json b/libraries/fetch-utils/tsconfig.json new file mode 100644 index 0000000000..d43bb2470a --- /dev/null +++ b/libraries/fetch-utils/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] +} diff --git a/libraries/logger/package.json b/libraries/logger/package.json index 92981d0c36..02f443adb6 100644 --- a/libraries/logger/package.json +++ b/libraries/logger/package.json @@ -6,15 +6,20 @@ "type": "git", "url": "https://github.com/overleaf/overleaf" }, + "main": "index.js", + "types": "types/index.js", "license": "AGPL-3.0-only", "version": "3.1.1", "scripts": { - "test": "mocha --grep=$MOCHA_GREP test/**/*.js", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "lint": "eslint --max-warnings 0 --format unix .", - "lint:fix": "eslint --fix .", - "test:ci": "npm run test" + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", + "test:ci": "npm run test:unit", + "typecheck": "tsc --noEmit", + "test:unit": "mocha --exit test/**/*.{js,cjs}", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" }, "dependencies": { "@google-cloud/logging-bunyan": "^5.0.0", @@ -28,7 +33,8 @@ "mocha": "^10.2.0", "sandboxed-module": "^2.0.4", "sinon": "^9.2.4", - "sinon-chai": "^3.7.0" + "sinon-chai": "^3.7.0", + "typescript": "^5.0.4" }, "peerDependencies": { "@overleaf/metrics": "*" diff --git a/libraries/logger/tsconfig.json b/libraries/logger/tsconfig.json new file mode 100644 index 0000000000..d43bb2470a --- /dev/null +++ b/libraries/logger/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] +} diff --git a/libraries/metrics/package.json b/libraries/metrics/package.json index bf6478792f..cc38518ba4 100644 --- a/libraries/metrics/package.json +++ b/libraries/metrics/package.json @@ -6,6 +6,8 @@ "type": "git", "url": "https://github.com/overleaf/metrics-module.git" }, + "main": "index.js", + "types": "types/index.js", "dependencies": { "@google-cloud/opentelemetry-cloud-trace-exporter": "^2.1.0", "@google-cloud/profiler": "^6.0.0", @@ -24,17 +26,20 @@ "chai": "^4.3.6", "mocha": "^10.2.0", "sandboxed-module": "^2.0.4", - "sinon": "^9.2.4" + "sinon": "^9.2.4", + "typescript": "^5.0.4" }, "scripts": { - "lint": "eslint --max-warnings 0 --format unix .", - "lint:fix": "eslint --fix .", - "test:unit": "mocha --reporter spec --recursive --exit --grep=$MOCHA_GREP test/unit", + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", + "test:unit": "mocha --exit test/**/*.{js,cjs}", "test:acceptance": "mocha --reporter spec --recursive --exit --grep=$MOCHA_GREP test/acceptance", - "test": "npm run test:unit && npm run test:acceptance", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "test:ci": "npm run test" + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "test:ci": "npm run test:unit", + "typecheck": "tsc --noEmit", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" }, "peerDependencies": { "@overleaf/logger": "*" diff --git a/libraries/metrics/tsconfig.json b/libraries/metrics/tsconfig.json new file mode 100644 index 0000000000..d43bb2470a --- /dev/null +++ b/libraries/metrics/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] +} diff --git a/libraries/o-error/package.json b/libraries/o-error/package.json index 6f8c876831..6d20b2bd59 100644 --- a/libraries/o-error/package.json +++ b/libraries/o-error/package.json @@ -13,6 +13,7 @@ "verror" ], "main": "index.cjs", + "types": "types/index.cjs", "files": [ "index.cjs", "index.d.ts" @@ -21,15 +22,17 @@ "build": "npm run --silent typecheck && npm run --silent test && npm run --silent declaration:build && npm run --silent update-readme", "declaration:build": "rm -f index.d.ts && tsc --allowJs --declaration --emitDeclarationOnly --moduleResolution node --target ES6 index.js", "declaration:check": "git diff --exit-code -- index.d.ts", - "lint": "eslint --max-warnings 0 --format unix .", - "lint:fix": "eslint --fix .", + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", "prepublishOnly": "npm run --silent declaration:build && npm run --silent declaration:check", - "test": "mocha", - "typecheck": "tsc --allowJs --checkJs --noEmit --skipLibCheck --moduleResolution node --strict --target ES6 *.cjs test/**/*.js", + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "typecheck": "tsc --noEmit", "update-readme": "doc/update-readme.js", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "test:ci": "npm run typecheck && npm run test" + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "test:ci": "npm run test:unit", + "test:unit": "mocha --exit test/**/*.{js,cjs}", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" }, "author": "Overleaf (https://www.overleaf.com)", "license": "MIT", diff --git a/libraries/o-error/tsconfig.json b/libraries/o-error/tsconfig.json new file mode 100644 index 0000000000..d43bb2470a --- /dev/null +++ b/libraries/o-error/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] +} diff --git a/libraries/object-persistor/package.json b/libraries/object-persistor/package.json index 403596f2de..67e48597e7 100644 --- a/libraries/object-persistor/package.json +++ b/libraries/object-persistor/package.json @@ -3,14 +3,17 @@ "version": "1.0.2", "description": "Module for storing objects in multiple backends, with fallback on 404 to assist migration between them", "main": "index.js", + "types": "types/index.js", "scripts": { - "test": "npm run lint && npm run format && npm run test:unit", - "test:unit": "mocha", - "lint": "eslint --max-warnings 0 --format unix .", - "lint:fix": "eslint --fix .", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "test:ci": "npm run test:unit" + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "test:unit": "mocha --exit test/**/*.{js,cjs}", + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "test:ci": "npm run test:unit", + "typecheck": "tsc --noEmit", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" }, "repository": { "type": "git", @@ -39,6 +42,7 @@ "mongodb": "^6.1.0", "sandboxed-module": "^2.0.4", "sinon": "^9.2.4", - "sinon-chai": "^3.7.0" + "sinon-chai": "^3.7.0", + "typescript": "^5.0.4" } } diff --git a/libraries/object-persistor/tsconfig.json b/libraries/object-persistor/tsconfig.json new file mode 100644 index 0000000000..d43bb2470a --- /dev/null +++ b/libraries/object-persistor/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] +} diff --git a/libraries/overleaf-editor-core/package.json b/libraries/overleaf-editor-core/package.json index 5e4d39d08d..78bf8bc5e1 100644 --- a/libraries/overleaf-editor-core/package.json +++ b/libraries/overleaf-editor-core/package.json @@ -3,13 +3,17 @@ "version": "1.0.0", "description": "Library shared between the editor server and clients.", "main": "index.js", + "types": "types/index.js", "scripts": { - "test": "mocha", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "lint": "eslint --max-warnings 0 --format unix lib test && tsc", - "lint:fix": "eslint --fix lib test", - "test:ci": "npm run test" + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", + "test:ci": "npm run test:unit", + "typecheck": "tsc --noEmit", + "test:unit": "mocha --exit test/**/*.{js,cjs}", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" }, "author": "team@overleaf.com", "license": "Proprietary", diff --git a/libraries/overleaf-editor-core/test/operation.test.js b/libraries/overleaf-editor-core/test/operation.test.js index 7e03025c98..0fc90774bc 100644 --- a/libraries/overleaf-editor-core/test/operation.test.js +++ b/libraries/overleaf-editor-core/test/operation.test.js @@ -62,8 +62,8 @@ describe('Operation', function () { return { snapshot: snapshotA, - operations: operations, - primeOperations: primeOperations, + operations, + primeOperations, log() { console.log(this) diff --git a/libraries/overleaf-editor-core/tsconfig.json b/libraries/overleaf-editor-core/tsconfig.json index 9b963217fd..d43bb2470a 100644 --- a/libraries/overleaf-editor-core/tsconfig.json +++ b/libraries/overleaf-editor-core/tsconfig.json @@ -1,14 +1,7 @@ { - "compilerOptions": { - "allowJs": true, - "allowSyntheticDefaultImports": true, - "checkJs": true, - "esModuleInterop": true, - "lib": ["es2022"], - "module": "commonjs", - "noEmit": true, - "resolveJsonModule": true, - "skipLibCheck": true - }, - "include": ["lib/**/*", "typings/**/*"] + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] } diff --git a/libraries/promise-utils/package.json b/libraries/promise-utils/package.json index 92a2da1cb5..f84d1c712e 100644 --- a/libraries/promise-utils/package.json +++ b/libraries/promise-utils/package.json @@ -4,20 +4,23 @@ "description": "utilities to help working with promises", "main": "index.js", "scripts": { - "test": "npm run lint && npm run format && npm run test:unit", - "test:unit": "mocha", - "lint": "eslint --max-warnings 0 --format unix .", - "lint:fix": "eslint --fix .", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "test:ci": "npm run test:unit" + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "test:unit": "mocha --exit test/**/*.{js,cjs}", + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "test:ci": "npm run test:unit", + "typecheck": "tsc --noEmit", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" }, "author": "Overleaf (https://www.overleaf.com)", "license": "AGPL-3.0-only", "devDependencies": { "chai": "^4.3.10", "chai-as-promised": "^7.1.1", - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" }, "dependencies": { "p-limit": "^2.3.0" diff --git a/libraries/promise-utils/tsconfig.json b/libraries/promise-utils/tsconfig.json new file mode 100644 index 0000000000..d43bb2470a --- /dev/null +++ b/libraries/promise-utils/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] +} diff --git a/libraries/ranges-tracker/package.json b/libraries/ranges-tracker/package.json index a882562b88..1733bd0359 100644 --- a/libraries/ranges-tracker/package.json +++ b/libraries/ranges-tracker/package.json @@ -8,14 +8,18 @@ "author": "Overleaf (https://www.overleaf.com)", "private": true, "scripts": { - "lint": "eslint --max-warnings 0 --format unix .", - "lint:fix": "eslint --fix .", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "test": "mocha --recursive test/unit/src/", - "test:ci": "npm run test" + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "test:ci": "npm run test:unit", + "typecheck": "tsc --noEmit", + "test:unit": "mocha --exit test/**/*.{js,cjs}", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" }, "devDependencies": { - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" } } diff --git a/libraries/ranges-tracker/test/notests.js b/libraries/ranges-tracker/test/notests.js new file mode 100644 index 0000000000..62307e456d --- /dev/null +++ b/libraries/ranges-tracker/test/notests.js @@ -0,0 +1 @@ +// There are no tests yet diff --git a/libraries/ranges-tracker/tsconfig.json b/libraries/ranges-tracker/tsconfig.json new file mode 100644 index 0000000000..d43bb2470a --- /dev/null +++ b/libraries/ranges-tracker/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] +} diff --git a/libraries/redis-wrapper/package.json b/libraries/redis-wrapper/package.json index cbb04dc816..f491cdcdfc 100644 --- a/libraries/redis-wrapper/package.json +++ b/libraries/redis-wrapper/package.json @@ -13,12 +13,15 @@ "repository": "github:overleaf/redis-wrapper", "license": "ISC", "scripts": { - "lint": "eslint --max-warnings 0 --format unix .", - "lint:fix": "eslint --fix .", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "test": "mocha --recursive test/unit/src/", - "test:ci": "npm run test" + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "test:ci": "npm run test:unit", + "typecheck": "tsc --noEmit", + "test:unit": "mocha --exit test/**/*.{js,cjs}", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" }, "peerDependencies": { "@overleaf/logger": "*", @@ -35,6 +38,7 @@ "chai": "^4.3.6", "mocha": "^10.2.0", "sandboxed-module": "^2.0.4", - "sinon": "^9.2.4" + "sinon": "^9.2.4", + "typescript": "^5.0.4" } } diff --git a/libraries/redis-wrapper/tsconfig.json b/libraries/redis-wrapper/tsconfig.json new file mode 100644 index 0000000000..d43bb2470a --- /dev/null +++ b/libraries/redis-wrapper/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] +} diff --git a/libraries/settings/package.json b/libraries/settings/package.json index 43da444bbf..07788d9776 100644 --- a/libraries/settings/package.json +++ b/libraries/settings/package.json @@ -4,11 +4,18 @@ "version": "3.0.0", "repository": "overleaf/settings-module", "scripts": { - "lint": "eslint --max-warnings 0 --format unix .", - "lint:fix": "eslint --fix .", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "test": "echo noop", - "test:ci": "echo noop" + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "test:ci": "npm run test:unit", + "typecheck": "tsc --noEmit", + "test:unit": "mocha --exit test/**/*.{js,cjs}", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" + }, + "devDependencies": { + "mocha": "^10.2.0", + "typescript": "^5.0.4" } } diff --git a/libraries/settings/test/notests.js b/libraries/settings/test/notests.js new file mode 100644 index 0000000000..62307e456d --- /dev/null +++ b/libraries/settings/test/notests.js @@ -0,0 +1 @@ +// There are no tests yet diff --git a/libraries/settings/tsconfig.json b/libraries/settings/tsconfig.json new file mode 100644 index 0000000000..d43bb2470a --- /dev/null +++ b/libraries/settings/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] +} diff --git a/libraries/stream-utils/package.json b/libraries/stream-utils/package.json index f9beee688f..33198fbb13 100644 --- a/libraries/stream-utils/package.json +++ b/libraries/stream-utils/package.json @@ -3,20 +3,24 @@ "version": "0.1.0", "description": "stream handling utilities", "main": "index.js", + "types": "types/index.js", "scripts": { - "test": "npm run lint && npm run format && npm run test:unit", - "test:unit": "mocha", - "lint": "eslint --max-warnings 0 --format unix .", - "lint:fix": "eslint --fix .", - "format": "prettier --list-different $PWD/'**/*.js'", - "format:fix": "prettier --write $PWD/'**/*.js'", - "test:ci": "npm run test:unit" + "test": "npm run lint && npm run format && npm run typecheck && npm run test:unit", + "test:unit": "mocha --exit test/**/*.{js,cjs}", + "lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .", + "lint:fix": "eslint --fix --ext .js --ext .cjs .", + "format": "prettier --list-different $PWD/'**/*.{js,cjs}'", + "format:fix": "prettier --write $PWD/'**/*.{js,cjs}'", + "test:ci": "npm run test:unit", + "typecheck": "tsc --noEmit", + "update-types": "rm -rf types && tsc --emitDeclarationOnly" }, "author": "Overleaf (https://www.overleaf.com)", "license": "AGPL-3.0-only", - "devDependencies":{ + "devDependencies": { "chai": "^4.3.6", "chai-as-promised": "^7.1.1", - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" } } diff --git a/libraries/stream-utils/tsconfig.json b/libraries/stream-utils/tsconfig.json new file mode 100644 index 0000000000..d43bb2470a --- /dev/null +++ b/libraries/stream-utils/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.backend.json", + "include": [ + "**/*.js", + "**/*.cjs" + ] +} diff --git a/package-lock.json b/package-lock.json index 49761db270..e0b4db5619 100644 --- a/package-lock.json +++ b/package-lock.json @@ -86,7 +86,8 @@ "devDependencies": { "chai": "^4.3.6", "mocha": "^10.2.0", - "sandboxed-module": "^2.0.4" + "sandboxed-module": "^2.0.4", + "typescript": "^5.0.4" }, "peerDependencies": { "mongodb": "*" @@ -117,7 +118,8 @@ "chai": "^4.3.6", "chai-as-promised": "^7.1.1", "express": "^4.18.2", - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" } }, "libraries/fetch-utils/node_modules/body-parser": { @@ -284,7 +286,8 @@ "mocha": "^10.2.0", "sandboxed-module": "^2.0.4", "sinon": "^9.2.4", - "sinon-chai": "^3.7.0" + "sinon-chai": "^3.7.0", + "typescript": "^5.0.4" }, "peerDependencies": { "@overleaf/metrics": "*" @@ -311,7 +314,8 @@ "chai": "^4.3.6", "mocha": "^10.2.0", "sandboxed-module": "^2.0.4", - "sinon": "^9.2.4" + "sinon": "^9.2.4", + "typescript": "^5.0.4" }, "peerDependencies": { "@overleaf/logger": "*" @@ -359,7 +363,8 @@ "mongodb": "^6.1.0", "sandboxed-module": "^2.0.4", "sinon": "^9.2.4", - "sinon-chai": "^3.7.0" + "sinon-chai": "^3.7.0", + "typescript": "^5.0.4" }, "peerDependencies": { "@overleaf/logger": "*" @@ -509,7 +514,8 @@ "license": "Proprietary", "devDependencies": { "chai": "^4.3.6", - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" } }, "libraries/promise-utils": { @@ -522,7 +528,8 @@ "devDependencies": { "chai": "^4.3.10", "chai-as-promised": "^7.1.1", - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" } }, "libraries/promise-utils/node_modules/chai": { @@ -572,7 +579,8 @@ "libraries/ranges-tracker": { "name": "@overleaf/ranges-tracker", "devDependencies": { - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" } }, "libraries/redis-wrapper": { @@ -589,7 +597,8 @@ "chai": "^4.3.6", "mocha": "^10.2.0", "sandboxed-module": "^2.0.4", - "sinon": "^9.2.4" + "sinon": "^9.2.4", + "typescript": "^5.0.4" }, "peerDependencies": { "@overleaf/logger": "*", @@ -599,7 +608,11 @@ }, "libraries/settings": { "name": "@overleaf/settings", - "version": "3.0.0" + "version": "3.0.0", + "devDependencies": { + "mocha": "^10.2.0", + "typescript": "^5.0.4" + } }, "libraries/stream-utils": { "name": "@overleaf/stream-utils", @@ -608,7 +621,8 @@ "devDependencies": { "chai": "^4.3.6", "chai-as-promised": "^7.1.1", - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -53677,7 +53691,8 @@ "chai": "^4.3.6", "lodash": "^4.17.21", "mocha": "^10.2.0", - "sandboxed-module": "^2.0.4" + "sandboxed-module": "^2.0.4", + "typescript": "^5.0.4" } }, "@overleaf/analytics": { @@ -54173,7 +54188,8 @@ "express": "^4.18.2", "lodash": "^4.17.21", "mocha": "^10.2.0", - "node-fetch": "^2.6.11" + "node-fetch": "^2.6.11", + "typescript": "^5.0.4" }, "dependencies": { "body-parser": { @@ -54474,7 +54490,8 @@ "mocha": "^10.2.0", "sandboxed-module": "^2.0.4", "sinon": "^9.2.4", - "sinon-chai": "^3.7.0" + "sinon-chai": "^3.7.0", + "typescript": "^5.0.4" } }, "@overleaf/metrics": { @@ -54495,6 +54512,7 @@ "prom-client": "^14.1.1", "sandboxed-module": "^2.0.4", "sinon": "^9.2.4", + "typescript": "^5.0.4", "yn": "^3.1.1" }, "dependencies": { @@ -54583,7 +54601,8 @@ "sandboxed-module": "^2.0.4", "sinon": "^9.2.4", "sinon-chai": "^3.7.0", - "tiny-async-pool": "^1.1.0" + "tiny-async-pool": "^1.1.0", + "typescript": "^5.0.4" }, "dependencies": { "bson": { @@ -54621,7 +54640,8 @@ "version": "file:libraries/piece-table", "requires": { "chai": "^4.3.6", - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" } }, "@overleaf/project-history": { @@ -54770,7 +54790,8 @@ "chai": "^4.3.10", "chai-as-promised": "^7.1.1", "mocha": "^10.2.0", - "p-limit": "^2.3.0" + "p-limit": "^2.3.0", + "typescript": "^5.0.4" }, "dependencies": { "chai": { @@ -54810,7 +54831,8 @@ "@overleaf/ranges-tracker": { "version": "file:libraries/ranges-tracker", "requires": { - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" } }, "@overleaf/real-time": { @@ -54879,7 +54901,8 @@ "ioredis": "~4.27.1", "mocha": "^10.2.0", "sandboxed-module": "^2.0.4", - "sinon": "^9.2.4" + "sinon": "^9.2.4", + "typescript": "^5.0.4" } }, "@overleaf/references": { @@ -54907,7 +54930,11 @@ } }, "@overleaf/settings": { - "version": "file:libraries/settings" + "version": "file:libraries/settings", + "requires": { + "mocha": "^10.2.0", + "typescript": "^5.0.4" + } }, "@overleaf/spelling": { "version": "file:services/spelling", @@ -54943,7 +54970,8 @@ "requires": { "chai": "^4.3.6", "chai-as-promised": "^7.1.1", - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "typescript": "^5.0.4" } }, "@overleaf/templates": {