From 8de2ebdaad9b09b8ea7b8cb7599b5dfd6afa919b Mon Sep 17 00:00:00 2001 From: Valentyne Stigloher Date: Fri, 19 Jan 2024 13:20:00 +0100 Subject: [PATCH 01/11] (ts) install TypeScript Co-authored-by: tecc --- nuxt.config.js | 1 - package.json | 14 ++++ tsconfig.json | 26 +++++++ yarn.lock | 208 ++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 247 insertions(+), 2 deletions(-) create mode 100644 tsconfig.json diff --git a/nuxt.config.js b/nuxt.config.js index 4d48a2bd1..17f7ab301 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -170,7 +170,6 @@ export default { { src: '~/plugins/browserDetect.js' }, ], components: true, - buildModules: [], modules: [ '@privyid/nuxt-csrf', '@nuxtjs/pwa', diff --git a/package.json b/package.json index e3f2a7994..9f15204a3 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,19 @@ "devDependencies": { "@fortawesome/fontawesome-pro": "git+ssh://git@gitlab.com:Avris/FontAwesomePro.git", "@stylistic/eslint-plugin-js": "^1.5.1", + "@types/autoprefixer": "^10.2.0", + "@types/cookie-parser": "^1.4.6", + "@types/express-session": "^1.17.10", + "@types/js-md5": "^0.7.2", + "@types/jsonwebtoken": "^8.5.9", + "@types/luxon": "^1.27.1", + "@types/node": "^20.11.5", + "@types/node-fetch": "^2.6.11", + "@types/nodemailer": "^6.4.14", + "@types/papaparse": "^5.3.14", + "@types/rtlcss": "^3.1.2", + "@types/speakeasy": "^2.0.10", + "@types/webpack": "^4.41.38", "avris-daemonise": "^0.0.2", "bootstrap": "^5.3.1", "clipboard": "^2.0.6", @@ -107,6 +120,7 @@ "sharp": "^0.31.3", "string-replace-loader": "^2.3.0", "suml-loader": "^0.1.1", + "typescript": "^5.3.3", "webpack": "^4.47.0", "yaml-loader": "^0.8.0" }, diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..18da21544 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "ES2018", + "module": "ESNext", + "moduleResolution": "Node", + "resolveJsonModule": true, + "lib": [ + "ESNext", + "ESNext.AsyncIterable", + "DOM" + ], + "skipLibCheck": true, + "esModuleInterop": true, + "allowImportingTsExtensions": true, + "allowJs": true, + "strict": true, + "sourceMap": true, + "noEmit": true + }, + "exclude": [ + "dist", + "new", + "node_modules", + ".nuxt" + ] +} diff --git a/yarn.lock b/yarn.lock index 72cdd1b4a..e64b68c75 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2329,6 +2329,13 @@ resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad" integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA== +"@types/autoprefixer@^10.2.0": + version "10.2.0" + resolved "https://registry.yarnpkg.com/@types/autoprefixer/-/autoprefixer-10.2.0.tgz#cb6cd67f00337607433b17ebf2cee511db957b9e" + integrity sha512-ClU0uw3HhUra890K4xcf2IQxD6w0WOjPIaKb8jrRXYPHvvUW1P5dGufPlDtTo5gtWPWH+4L6tSBAoAKVf93uBQ== + dependencies: + autoprefixer "*" + "@types/babel__core@^7.1.14": version "7.20.5" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017" @@ -2362,11 +2369,60 @@ dependencies: "@babel/types" "^7.20.7" +"@types/body-parser@*": + version "1.19.5" + resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.5.tgz#04ce9a3b677dc8bd681a17da1ab9835dc9d3ede4" + integrity sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg== + dependencies: + "@types/connect" "*" + "@types/node" "*" + +"@types/connect@*": + version "3.4.38" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858" + integrity sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug== + dependencies: + "@types/node" "*" + +"@types/cookie-parser@^1.4.6": + version "1.4.6" + resolved "https://registry.yarnpkg.com/@types/cookie-parser/-/cookie-parser-1.4.6.tgz#002643c514cccf883a65cbe044dbdc38c0b92ade" + integrity sha512-KoooCrD56qlLskXPLGUiJxOMnv5l/8m7cQD2OxJ73NPMhuSz9PmvwRD6EpjDyKBVrdJDdQ4bQK7JFNHnNmax0w== + dependencies: + "@types/express" "*" + "@types/cookie@^0.3.3": version "0.3.3" resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.3.3.tgz#85bc74ba782fb7aa3a514d11767832b0e3bc6803" integrity sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow== +"@types/express-serve-static-core@^4.17.33": + version "4.17.41" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz#5077defa630c2e8d28aa9ffc2c01c157c305bef6" + integrity sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA== + dependencies: + "@types/node" "*" + "@types/qs" "*" + "@types/range-parser" "*" + "@types/send" "*" + +"@types/express-session@^1.17.10": + version "1.17.10" + resolved "https://registry.yarnpkg.com/@types/express-session/-/express-session-1.17.10.tgz#3a9394f1f314a4c657af3fb1cdb52f00fc207fd2" + integrity sha512-U32bC/s0ejXijw5MAzyaV4tuZopCh/K7fPoUDyNbsRXHvPSeymygYD1RFL99YOLhF5PNOkzswvOTRaVHdL1zMw== + dependencies: + "@types/express" "*" + +"@types/express@*": + version "4.17.21" + resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.21.tgz#c26d4a151e60efe0084b23dc3369ebc631ed192d" + integrity sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ== + dependencies: + "@types/body-parser" "*" + "@types/express-serve-static-core" "^4.17.33" + "@types/qs" "*" + "@types/serve-static" "*" + "@types/graceful-fs@^4.1.3": version "4.1.9" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" @@ -2379,6 +2435,11 @@ resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-5.1.2.tgz#693b316ad323ea97eed6b38ed1a3cc02b1672b57" integrity sha512-h4lTMgMJctJybDp8CQrxTUiiYmedihHWkjnF/8Pxseu2S6Nlfcy8kwboQ8yejh456rP2yWoEVm1sS/FVsfM48w== +"@types/http-errors@*": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.4.tgz#7eb47726c391b7345a6ec35ad7f4de469cf5ba4f" + integrity sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA== + "@types/http-proxy@^1.17.5": version "1.17.11" resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.11.tgz#0ca21949a5588d55ac2b659b69035c84bd5da293" @@ -2405,6 +2466,11 @@ dependencies: "@types/istanbul-lib-report" "*" +"@types/js-md5@^0.7.2": + version "0.7.2" + resolved "https://registry.yarnpkg.com/@types/js-md5/-/js-md5-0.7.2.tgz#9766e8763dfbe23d146053535d4a2c06006b49b2" + integrity sha512-IwcFIov1JbiEToo3DgrVEwkMUR1BVlVyLjk245AzGHyyOlyddDFIeSIZO+WlhTortOa4P1PdCS8cDrTl7RW1HA== + "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": version "7.0.12" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.12.tgz#d70faba7039d5fca54c83c7dbab41051d2b6f6cb" @@ -2415,16 +2481,67 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== +"@types/jsonwebtoken@^8.5.9": + version "8.5.9" + resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-8.5.9.tgz#2c064ecb0b3128d837d2764aa0b117b0ff6e4586" + integrity sha512-272FMnFGzAVMGtu9tkr29hRL6bZj4Zs1KZNeHLnKqAvp06tAIcarTMwOh8/8bz4FmKRcMxZhZNeUAQsNLoiPhg== + dependencies: + "@types/node" "*" + "@types/lodash@^4.14.175": version "4.14.197" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.197.tgz#e95c5ddcc814ec3e84c891910a01e0c8a378c54b" integrity sha512-BMVOiWs0uNxHVlHBgzTIqJYmj+PgCo4euloGF+5m4okL3rEYzM2EEv78mw8zWSMM57dM7kVIgJ2QDvwHSoCI5g== +"@types/luxon@^1.27.1": + version "1.27.1" + resolved "https://registry.yarnpkg.com/@types/luxon/-/luxon-1.27.1.tgz#aceeb2d5be8fccf541237e184e37ecff5faa9096" + integrity sha512-cPiXpOvPFDr2edMnOXlz3UBDApwUfR+cpizvxCy0n3vp9bz/qe8BWzHPIEFcy+ogUOyjKuCISgyq77ELZPmkkg== + +"@types/mime@*": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.4.tgz#2198ac274de6017b44d941e00261d5bc6a0e0a45" + integrity sha512-iJt33IQnVRkqeqC7PzBHPTC6fDlRNRW8vjrgqtScAhrmMwe8c4Eo7+fUGTa+XdWrpEgpyKWMYmi2dIwMAYRzPw== + +"@types/mime@^1": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690" + integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w== + +"@types/node-fetch@^2.6.11": + version "2.6.11" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.11.tgz#9b39b78665dae0e82a08f02f4967d62c66f95d24" + integrity sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g== + dependencies: + "@types/node" "*" + form-data "^4.0.0" + "@types/node@*": version "20.5.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.5.1.tgz#178d58ee7e4834152b0e8b4d30cbfab578b9bb30" integrity sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg== +"@types/node@^20.11.5": + version "20.11.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.5.tgz#be10c622ca7fcaa3cf226cf80166abc31389d86e" + integrity sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w== + dependencies: + undici-types "~5.26.4" + +"@types/nodemailer@^6.4.14": + version "6.4.14" + resolved "https://registry.yarnpkg.com/@types/nodemailer/-/nodemailer-6.4.14.tgz#5c81a5e856db7f8ede80013e6dbad7c5fb2283e2" + integrity sha512-fUWthHO9k9DSdPCSPRqcu6TWhYyxTBg382vlNIttSe9M7XfsT06y0f24KHXtbnijPGGRIcVvdKHTNikOI6qiHA== + dependencies: + "@types/node" "*" + +"@types/papaparse@^5.3.14": + version "5.3.14" + resolved "https://registry.yarnpkg.com/@types/papaparse/-/papaparse-5.3.14.tgz#345cc2a675a90106ff1dc33b95500dfb30748031" + integrity sha512-LxJ4iEFcpqc6METwp9f6BV6VVc43m6MfH0VqFosHvrUgfXiFe6ww7R3itkOQ+TCK6Y+Iv/+RnnvtRZnkc5Kc9g== + dependencies: + "@types/node" "*" + "@types/parse-json@^4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" @@ -2437,11 +2554,52 @@ dependencies: "@types/node" "*" +"@types/qs@*": + version "6.9.11" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.11.tgz#208d8a30bc507bd82e03ada29e4732ea46a6bbda" + integrity sha512-oGk0gmhnEJK4Yyk+oI7EfXsLayXatCWPHary1MtcmbAifkobT9cM9yutG/hZKIseOU0MqbIwQ/u2nn/Gb+ltuQ== + +"@types/range-parser@*": + version "1.2.7" + resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb" + integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ== + +"@types/rtlcss@^3.1.2": + version "3.5.4" + resolved "https://registry.yarnpkg.com/@types/rtlcss/-/rtlcss-3.5.4.tgz#8db1e02fe911cf5b71f4cb42dafce8ccaef8e1e1" + integrity sha512-MgGlOoTwu0SjpqBqVr9vwwezysD+ZoM0q6eS3ULAYuoKDYBlJMVz73Du/paSER9AOxv/UepGfcAzeO5otP72aQ== + dependencies: + postcss "^8.2.x" + +"@types/send@*": + version "0.17.4" + resolved "https://registry.yarnpkg.com/@types/send/-/send-0.17.4.tgz#6619cd24e7270793702e4e6a4b958a9010cfc57a" + integrity sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA== + dependencies: + "@types/mime" "^1" + "@types/node" "*" + +"@types/serve-static@*": + version "1.15.5" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.15.5.tgz#15e67500ec40789a1e8c9defc2d32a896f05b033" + integrity sha512-PDRk21MnK70hja/YF8AHfC7yIsiQHn1rcXx7ijCFBX/k+XQJhQT/gw3xekXKJvx+5SXaMMS8oqQy09Mzvz2TuQ== + dependencies: + "@types/http-errors" "*" + "@types/mime" "*" + "@types/node" "*" + "@types/source-list-map@*": version "0.1.2" resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" integrity sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA== +"@types/speakeasy@^2.0.10": + version "2.0.10" + resolved "https://registry.yarnpkg.com/@types/speakeasy/-/speakeasy-2.0.10.tgz#a1f0e474696abd165e544478b9b02549778fa4e2" + integrity sha512-QVRlDW5r4yl7p7xkNIbAIC/JtyOcClDIIdKfuG7PWdDT1MmyhtXSANsildohy0K+Lmvf/9RUtLbNLMacvrVwxA== + dependencies: + "@types/node" "*" + "@types/stack-utils@^2.0.0": version "2.0.3" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" @@ -2468,6 +2626,18 @@ "@types/source-list-map" "*" source-map "^0.7.3" +"@types/webpack@^4.41.38": + version "4.41.38" + resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.38.tgz#5a40ac81bdd052bf405e8bdcf3e1236f6db6dc26" + integrity sha512-oOW7E931XJU1mVfCnxCVgv8GLFL768pDO5u2Gzk82i8yTIgX6i7cntyZOkZYb/JtYM8252SN9bQp9tgkVDSsRw== + dependencies: + "@types/node" "*" + "@types/tapable" "^1" + "@types/uglify-js" "*" + "@types/webpack-sources" "*" + anymatch "^3.0.0" + source-map "^0.6.0" + "@types/webpack@^4.41.8": version "4.41.33" resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.33.tgz#16164845a5be6a306bcbe554a8e67f9cac215ffc" @@ -3210,6 +3380,18 @@ atob@^2.1.2: resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== +autoprefixer@*: + version "10.4.17" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.17.tgz#35cd5695cbbe82f536a50fa025d561b01fdec8be" + integrity sha512-/cpVNRLSfhOtcGflT13P2794gVSgmPgTR+erw5ifnMLZb0UnSlkK4tquLmkd3BhA+nLo5tX8Cu0upUsGKvKbmg== + dependencies: + browserslist "^4.22.2" + caniuse-lite "^1.0.30001578" + fraction.js "^4.3.7" + normalize-range "^0.1.2" + picocolors "^1.0.0" + postcss-value-parser "^4.2.0" + autoprefixer@^10.4.16: version "10.4.16" resolved "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.16.tgz#fad1411024d8670880bdece3970aa72e3572feb8" @@ -3884,6 +4066,11 @@ caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001517, caniuse-lite@^1.0.30001520, can resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001587.tgz" integrity sha512-HMFNotUmLXn71BQxg8cijvqxnIAofforZOwGsxyXJ0qugTdspUF4sPSJ2vhgprHCB996tIDzEq1ubumPDV8ULA== +caniuse-lite@^1.0.30001578: + version "1.0.30001579" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001579.tgz#45c065216110f46d6274311a4b3fcf6278e0852a" + integrity sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA== + canvas@^2.11.2: version "2.11.2" resolved "https://registry.npmjs.org/canvas/-/canvas-2.11.2.tgz#553d87b1e0228c7ac0fc72887c3adbac4abbd860" @@ -6264,7 +6451,7 @@ fraction.js@^4.2.0: resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.2.1.tgz#14b4cc886575a5684f8d5fd5759c5db376bb7bb8" integrity sha512-/KxoyCnPM0GwYI4NN0Iag38Tqt+od3/mLuguepLgCAKPn0ZhC544nssAW0tG2/00zXEYl9W+7hwAIpLHo6Oc7Q== -fraction.js@^4.3.6: +fraction.js@^4.3.6, fraction.js@^4.3.7: version "4.3.7" resolved "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz#06ca0085157e42fda7f9e726e79fefc4068840f7" integrity sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew== @@ -10883,6 +11070,15 @@ postcss@^8.2.1, postcss@^8.2.15, postcss@^8.3.11, postcss@^8.4.14: picocolors "^1.0.0" source-map-js "^1.0.2" +postcss@^8.2.x: + version "8.4.33" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.33.tgz#1378e859c9f69bf6f638b990a0212f43e2aaa742" + integrity sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg== + dependencies: + nanoid "^3.3.7" + picocolors "^1.0.0" + source-map-js "^1.0.2" + postcss@^8.4.31: version "8.4.32" resolved "https://registry.npmjs.org/postcss/-/postcss-8.4.32.tgz#1dac6ac51ab19adb21b8b34fd2d93a86440ef6c9" @@ -13041,6 +13237,11 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== +typescript@^5.3.3: + version "5.3.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37" + integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw== + ua-parser-js@^1.0.36: version "1.0.37" resolved "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.37.tgz#b5dc7b163a5c1f0c510b08446aed4da92c46373f" @@ -13091,6 +13292,11 @@ unbzip2-stream@^1.3.3: buffer "^5.2.1" through "^2.3.8" +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + unfetch@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-5.0.0.tgz#8a5b6e5779ebe4dde0049f7d7a81d4a1af99d142" From d06361344b4c1cbce59ad646b95e63477c9684d0 Mon Sep 17 00:00:00 2001 From: Valentyne Stigloher Date: Fri, 19 Jan 2024 19:44:55 +0100 Subject: [PATCH 02/11] (ts)(ci) add CI job for type checking via TypeScript --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a5f19f18..f13ca0cb5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,6 +35,10 @@ check: - make switch LANG=en - end_section + - start_section "Type checking" + - yarn tsc || record_failure + - end_section + - start_section "Unit Tests" - > yarn test --ci --reporters=default --reporters=jest-junit From 0399a62291338c32c358a582df3145138682cdb6 Mon Sep 17 00:00:00 2001 From: Valentyne Stigloher Date: Fri, 19 Jan 2024 13:38:10 +0100 Subject: [PATCH 03/11] (ts)(lint) enable TypeScript linting replace @stylistic/js with @stylistic to use same rules for .js and .ts --- .eslintrc.json | 160 +++++++++++++++++----------- .vscode/settings.json | 2 +- package.json | 7 +- server/routes/profile.js | 1 - yarn.lock | 224 ++++++++++++++++++++++++++++++++++++--- 5 files changed, 314 insertions(+), 80 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index c399b0af7..5eb08f635 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,19 +6,28 @@ "root": true, "extends": [ "eslint:recommended", + "plugin:@typescript-eslint/recommended", "plugin:import/recommended", + "plugin:import/typescript", "plugin:jsonc/recommended-with-json", "plugin:yml/standard", "plugin:vue/recommended" ], "plugins": [ - "@stylistic/js" + "@stylistic", + "@stylistic/ts" ], "ignorePatterns": ["data", "dist", "new", "static", "census", "keys"], "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, + "settings": { + "import/resolver": { + "node": true, + "typescript": true + } + }, "rules": { "camelcase": ["warn", { "properties": "never" }], "curly": "warn", @@ -29,72 +38,78 @@ "no-irregular-whitespace": "warn", "no-prototype-builtins": "warn", "no-template-curly-in-string": "warn", - "no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }], "no-useless-escape": "warn", "no-useless-rename": "warn", "object-shorthand": "warn", "prefer-const": "warn", "prefer-template": "warn", "import/extensions": ["error", "always"], + "import/consistent-type-specifier-style": ["warn", "prefer-top-level"], "import/no-cycle": "warn", "import/no-self-import": "error", "import/no-useless-path-segments": "error", - "@stylistic/js/array-bracket-newline": ["warn", "consistent"], - "@stylistic/js/array-bracket-spacing": "warn", - "@stylistic/js/array-element-newline": ["warn", "consistent"], - "@stylistic/js/arrow-parens": "warn", - "@stylistic/js/arrow-spacing": "warn", - "@stylistic/js/block-spacing": "warn", - "@stylistic/js/brace-style": "warn", - "@stylistic/js/comma-dangle": ["warn", "always-multiline"], - "@stylistic/js/comma-spacing": "warn", - "@stylistic/js/comma-style": "warn", - "@stylistic/js/computed-property-spacing": "warn", - "@stylistic/js/dot-location": ["warn", "property"], - "@stylistic/js/eol-last": "warn", - "@stylistic/js/function-call-argument-newline": ["warn", "consistent"], - "@stylistic/js/function-call-spacing": "warn", - "@stylistic/js/function-paren-newline": "warn", - "@stylistic/js/implicit-arrow-linebreak": "warn", - "@stylistic/js/indent": ["warn", 4, { "SwitchCase": 1 }], - "@stylistic/js/key-spacing": "warn", - "@stylistic/js/keyword-spacing": "warn", - "@stylistic/js/linebreak-style": "warn", - "@stylistic/js/lines-between-class-members": "warn", - "@stylistic/js/max-len": ["warn", { "code": 120 }], - "@stylistic/js/max-statements-per-line": "warn", - "@stylistic/js/multiline-ternary": ["warn", "always-multiline"], - "@stylistic/js/new-parens": "warn", - "@stylistic/js/newline-per-chained-call": "warn", - "@stylistic/js/no-extra-parens": "warn", - "@stylistic/js/no-extra-semi": "warn", - "@stylistic/js/no-multi-spaces": "warn", - "@stylistic/js/no-multiple-empty-lines": ["warn", { "max": 2, "maxEOF": 0, "maxBOF": 0 }], - "@stylistic/js/no-tabs": "warn", - "@stylistic/js/no-trailing-spaces": "warn", - "@stylistic/js/no-whitespace-before-property": "warn", - "@stylistic/js/object-curly-newline": "warn", - "@stylistic/js/object-curly-spacing": ["warn", "always"], - "@stylistic/js/object-property-newline": ["warn", { "allowAllPropertiesOnSameLine": true }], - "@stylistic/js/one-var-declaration-per-line": "warn", - "@stylistic/js/operator-linebreak": "warn", - "@stylistic/js/padded-blocks": ["warn", "never"], - "@stylistic/js/quote-props": ["warn", "as-needed"], - "@stylistic/js/quotes": ["warn", "single"], - "@stylistic/js/rest-spread-spacing": "warn", - "@stylistic/js/semi": "warn", - "@stylistic/js/semi-spacing": "warn", - "@stylistic/js/space-before-blocks": "warn", - "@stylistic/js/space-before-function-paren": ["warn", { "named": "never" }], - "@stylistic/js/space-in-parens": "warn", - "@stylistic/js/space-infix-ops": "warn", - "@stylistic/js/space-unary-ops": "warn", - "@stylistic/js/spaced-comment": "warn", - "@stylistic/js/switch-colon-spacing": "warn", - "@stylistic/js/template-curly-spacing": "warn", - "@stylistic/js/template-tag-spacing": "warn", - "@stylistic/js/wrap-iife": "warn", - "@stylistic/js/yield-star-spacing": "warn", + "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }], + "@typescript-eslint/no-explicit-any": "warn", + "@typescript-eslint/no-this-alias": "warn", + "@stylistic/array-bracket-newline": ["warn", "consistent"], + "@stylistic/array-bracket-spacing": "warn", + "@stylistic/array-element-newline": ["warn", "consistent"], + "@stylistic/arrow-parens": "warn", + "@stylistic/arrow-spacing": "warn", + "@stylistic/block-spacing": "warn", + "@stylistic/brace-style": "warn", + "@stylistic/comma-dangle": ["warn", "always-multiline"], + "@stylistic/comma-spacing": "warn", + "@stylistic/comma-style": "warn", + "@stylistic/computed-property-spacing": "warn", + "@stylistic/dot-location": ["warn", "property"], + "@stylistic/eol-last": "warn", + "@stylistic/function-call-argument-newline": ["warn", "consistent"], + "@stylistic/function-call-spacing": "warn", + "@stylistic/function-paren-newline": ["warn", "multiline-arguments"], + "@stylistic/implicit-arrow-linebreak": "warn", + "@stylistic/indent": ["warn", 4, { "SwitchCase": 1 }], + "@stylistic/key-spacing": "warn", + "@stylistic/keyword-spacing": "warn", + "@stylistic/linebreak-style": "warn", + "@stylistic/lines-between-class-members": ["warn", { "enforce": [ + { "blankLine": "never", "prev": "field", "next": "field" }, + { "blankLine": "always", "prev": "*", "next": "method" } + ] }], + "@stylistic/max-len": ["warn", { "code": 120 }], + "@stylistic/max-statements-per-line": "warn", + "@stylistic/multiline-ternary": ["warn", "always-multiline"], + "@stylistic/new-parens": "warn", + "@stylistic/newline-per-chained-call": "warn", + "@stylistic/no-extra-parens": "warn", + "@stylistic/no-extra-semi": "warn", + "@stylistic/no-multi-spaces": "warn", + "@stylistic/no-multiple-empty-lines": ["warn", { "max": 2, "maxEOF": 0, "maxBOF": 0 }], + "@stylistic/no-tabs": "warn", + "@stylistic/no-trailing-spaces": "warn", + "@stylistic/no-whitespace-before-property": "warn", + "@stylistic/object-curly-newline": "warn", + "@stylistic/object-curly-spacing": ["warn", "always"], + "@stylistic/object-property-newline": ["warn", { "allowAllPropertiesOnSameLine": true }], + "@stylistic/one-var-declaration-per-line": "warn", + "@stylistic/operator-linebreak": "warn", + "@stylistic/padded-blocks": ["warn", "never"], + "@stylistic/quote-props": ["warn", "as-needed"], + "@stylistic/quotes": ["warn", "single"], + "@stylistic/rest-spread-spacing": "warn", + "@stylistic/semi": "warn", + "@stylistic/semi-spacing": "warn", + "@stylistic/space-before-blocks": "warn", + "@stylistic/space-before-function-paren": ["warn", { "named": "never" }], + "@stylistic/space-in-parens": "warn", + "@stylistic/space-infix-ops": "warn", + "@stylistic/space-unary-ops": "warn", + "@stylistic/spaced-comment": "warn", + "@stylistic/switch-colon-spacing": "warn", + "@stylistic/template-curly-spacing": "warn", + "@stylistic/template-tag-spacing": "warn", + "@stylistic/wrap-iife": "warn", + "@stylistic/yield-star-spacing": "warn", "jsonc/array-bracket-newline": ["warn", "consistent"], "jsonc/array-bracket-spacing": "warn", "jsonc/array-element-newline": ["warn", "consistent"], @@ -156,6 +171,29 @@ "vue/template-curly-spacing": "warn" }, "overrides": [ + { + "files": ["*.ts"], + "rules": { + // rules which require type information need to be listed separately + "@typescript-eslint/await-thenable": "error", + "@typescript-eslint/adjacent-overload-signatures": "warn", + "@typescript-eslint/array-type": "warn", + "@typescript-eslint/consistent-indexed-object-style": "warn", + "@typescript-eslint/consistent-type-assertions": "warn", + "@typescript-eslint/consistent-type-definitions": "warn", + "@typescript-eslint/consistent-type-imports": "warn", + "@typescript-eslint/consistent-type-exports": "warn", + "@typescript-eslint/explicit-function-return-type": "warn", + "@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn", + "@typescript-eslint/no-unnecessary-type-arguments": "warn", + "@typescript-eslint/no-unnecessary-type-assertion": "warn", + "@stylistic/ts/type-annotation-spacing": "warn" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": true + } + }, { "files": ["*.json"], "parser": "jsonc-eslint-parser" @@ -170,8 +208,12 @@ "files": ["*.suml", "*.yml"], "parser": "yaml-eslint-parser", "rules": { - "@stylistic/js/spaced-comment": "off" + "@stylistic/spaced-comment": "off" } + }, + { + "files": ["*.vue"], + "parser": "vue-eslint-parser" } ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 977ac79e1..a1bf4a798 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,7 +4,7 @@ "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" }, - "eslint.validate": ["javascript", "json", "jsonc", "yaml"], + "eslint.validate": ["javascript", "json", "jsonc", "ts", "yaml"], "files.associations": { "*.suml": "yaml" }, diff --git a/package.json b/package.json index 9f15204a3..1cde5c562 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "start": "nuxt start", "export": "nuxt export", "serve": "nuxt serve", - "lint": "eslint --ext .js,.json,.suml,.yml,.vue --fix .", + "lint": "eslint --ext .js,.json,.suml,.ts,.yml,.vue --fix .", "test": "node --experimental-vm-modules $(yarn bin jest)" }, "dependencies": { @@ -81,7 +81,7 @@ }, "devDependencies": { "@fortawesome/fontawesome-pro": "git+ssh://git@gitlab.com:Avris/FontAwesomePro.git", - "@stylistic/eslint-plugin-js": "^1.5.1", + "@stylistic/eslint-plugin": "^1.5.4", "@types/autoprefixer": "^10.2.0", "@types/cookie-parser": "^1.4.6", "@types/express-session": "^1.17.10", @@ -95,6 +95,8 @@ "@types/rtlcss": "^3.1.2", "@types/speakeasy": "^2.0.10", "@types/webpack": "^4.41.38", + "@typescript-eslint/eslint-plugin": "^6.19.0", + "@typescript-eslint/parser": "^6.19.0", "avris-daemonise": "^0.0.2", "bootstrap": "^5.3.1", "clipboard": "^2.0.6", @@ -102,6 +104,7 @@ "csv-loader": "^3.0.3", "eslint": "^8.55.0", "eslint-formatter-gitlab": "^5.1.0", + "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.29.0", "eslint-plugin-jsonc": "^2.11.2", "eslint-plugin-vue": "^9.19.2", diff --git a/server/routes/profile.js b/server/routes/profile.js index 1b6aada49..d93e9b60b 100644 --- a/server/routes/profile.js +++ b/server/routes/profile.js @@ -89,7 +89,6 @@ export class ProfileOptions { enabled: true, default_value: true, }; - locale_specific_props = {}; constructor(query_obj, locales) { diff --git a/yarn.lock b/yarn.lock index e64b68c75..16325daeb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1547,7 +1547,7 @@ dependencies: eslint-visitor-keys "^3.3.0" -"@eslint-community/regexpp@^4.6.1": +"@eslint-community/regexpp@^4.5.1", "@eslint-community/regexpp@^4.6.1": version "4.10.0" resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.10.0.tgz#548f6de556857c8bb73bbee70c35dc82a2e74d63" integrity sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA== @@ -2304,16 +2304,49 @@ dependencies: "@sinonjs/commons" "^3.0.0" -"@stylistic/eslint-plugin-js@^1.5.1": - version "1.5.1" - resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-js/-/eslint-plugin-js-1.5.1.tgz#888a63128f95d4d2d6be6d67df077bb4823f6c24" - integrity sha512-iZF0rF+uOhAmOJYOJx1Yvmm3CZ1uz9n0SRd9dpBYHA3QAvfABUORh9LADWwZCigjHJkp2QbCZelGFJGwGz7Siw== +"@stylistic/eslint-plugin-js@1.5.4", "@stylistic/eslint-plugin-js@^1.5.4": + version "1.5.4" + resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-js/-/eslint-plugin-js-1.5.4.tgz#8636ddfc75f40e94721ecc96fb564b0641bd31cf" + integrity sha512-3ctWb3NvJNV1MsrZN91cYp2EGInLPSoZKphXIbIRx/zjZxKwLDr9z4LMOWtqjq14li/OgqUUcMq5pj8fgbLoTw== dependencies: - acorn "^8.11.2" + acorn "^8.11.3" escape-string-regexp "^4.0.0" eslint-visitor-keys "^3.4.3" espree "^9.6.1" +"@stylistic/eslint-plugin-jsx@1.5.4": + version "1.5.4" + resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-jsx/-/eslint-plugin-jsx-1.5.4.tgz#be661004e7a775c3ca60b4cf4fa1bfe4d2df1f0a" + integrity sha512-JUfrpCkeBCqt1IZ4QsP4WgxGza4PhK4LPbc0VnCjHKygl+rgqoDAovqOuzFJ49wJ4Ix3r6OIHFuwiBGswZEVvg== + dependencies: + "@stylistic/eslint-plugin-js" "^1.5.4" + estraverse "^5.3.0" + +"@stylistic/eslint-plugin-plus@1.5.4": + version "1.5.4" + resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-plus/-/eslint-plugin-plus-1.5.4.tgz#39a4a6245fa56c3f8fa9ececd44cf3dbd0d16b7c" + integrity sha512-dI0Cs5vYX/0uMhQDY+NK0cKQ0Pe9B6jWYxd0Ndud+mNloDaVLrsmJocK4zn+YfhGEDs1E4Nk5uAPZEumIpDuSg== + dependencies: + "@typescript-eslint/utils" "^6.19.0" + +"@stylistic/eslint-plugin-ts@1.5.4": + version "1.5.4" + resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-1.5.4.tgz#d90141ab6f45b03dfe9d4c3750dd94a2fe27d4ca" + integrity sha512-NZDFVIlVNjuPvhT+0Cidm5IS3emtx338xbJTqs2xfOVRDGTpYwRHhNVEGa1rFOpYHmv0sAj6+OXbMDn7ul0K/g== + dependencies: + "@stylistic/eslint-plugin-js" "1.5.4" + "@typescript-eslint/utils" "^6.19.0" + +"@stylistic/eslint-plugin@^1.5.4": + version "1.5.4" + resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin/-/eslint-plugin-1.5.4.tgz#e39d940023be47f79b45e849a5a16a40551c8517" + integrity sha512-zWPXr+O67GC9KDAFkbL1U9UVqE6Iv69YMKhkIECCmE0GvClUJwdfsimm4XebEDondV7kfjMrTDZaYfrI5aS0Jg== + dependencies: + "@stylistic/eslint-plugin-js" "1.5.4" + "@stylistic/eslint-plugin-jsx" "1.5.4" + "@stylistic/eslint-plugin-plus" "1.5.4" + "@stylistic/eslint-plugin-ts" "1.5.4" + "@tootallnate/once@1": version "1.1.2" resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" @@ -2471,6 +2504,11 @@ resolved "https://registry.yarnpkg.com/@types/js-md5/-/js-md5-0.7.2.tgz#9766e8763dfbe23d146053535d4a2c06006b49b2" integrity sha512-IwcFIov1JbiEToo3DgrVEwkMUR1BVlVyLjk245AzGHyyOlyddDFIeSIZO+WlhTortOa4P1PdCS8cDrTl7RW1HA== +"@types/json-schema@^7.0.12": + version "7.0.15" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" + integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== + "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": version "7.0.12" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.12.tgz#d70faba7039d5fca54c83c7dbab41051d2b6f6cb" @@ -2571,6 +2609,11 @@ dependencies: postcss "^8.2.x" +"@types/semver@^7.5.0": + version "7.5.6" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.6.tgz#c65b2bfce1bec346582c07724e3f8c1017a20339" + integrity sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A== + "@types/send@*": version "0.17.4" resolved "https://registry.yarnpkg.com/@types/send/-/send-0.17.4.tgz#6619cd24e7270793702e4e6a4b958a9010cfc57a" @@ -2669,6 +2712,92 @@ dependencies: "@types/node" "*" +"@typescript-eslint/eslint-plugin@^6.19.0": + version "6.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.19.1.tgz#bb0676af940bc23bf299ca58dbdc6589c2548c2e" + integrity sha512-roQScUGFruWod9CEyoV5KlCYrubC/fvG8/1zXuT0WTcxX87GnMMmnksMwSg99lo1xiKrBzw2icsJPMAw1OtKxg== + dependencies: + "@eslint-community/regexpp" "^4.5.1" + "@typescript-eslint/scope-manager" "6.19.1" + "@typescript-eslint/type-utils" "6.19.1" + "@typescript-eslint/utils" "6.19.1" + "@typescript-eslint/visitor-keys" "6.19.1" + debug "^4.3.4" + graphemer "^1.4.0" + ignore "^5.2.4" + natural-compare "^1.4.0" + semver "^7.5.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/parser@^6.19.0": + version "6.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.19.1.tgz#68a87bb21afaf0b1689e9cdce0e6e75bc91ada78" + integrity sha512-WEfX22ziAh6pRE9jnbkkLGp/4RhTpffr2ZK5bJ18M8mIfA8A+k97U9ZyaXCEJRlmMHh7R9MJZWXp/r73DzINVQ== + dependencies: + "@typescript-eslint/scope-manager" "6.19.1" + "@typescript-eslint/types" "6.19.1" + "@typescript-eslint/typescript-estree" "6.19.1" + "@typescript-eslint/visitor-keys" "6.19.1" + debug "^4.3.4" + +"@typescript-eslint/scope-manager@6.19.1": + version "6.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.19.1.tgz#2f527ee30703a6169a52b31d42a1103d80acd51b" + integrity sha512-4CdXYjKf6/6aKNMSly/BP4iCSOpvMmqtDzRtqFyyAae3z5kkqEjKndR5vDHL8rSuMIIWP8u4Mw4VxLyxZW6D5w== + dependencies: + "@typescript-eslint/types" "6.19.1" + "@typescript-eslint/visitor-keys" "6.19.1" + +"@typescript-eslint/type-utils@6.19.1": + version "6.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.19.1.tgz#6a130e3afe605a4898e043fa9f72e96309b54935" + integrity sha512-0vdyld3ecfxJuddDjACUvlAeYNrHP/pDeQk2pWBR2ESeEzQhg52DF53AbI9QCBkYE23lgkhLCZNkHn2hEXXYIg== + dependencies: + "@typescript-eslint/typescript-estree" "6.19.1" + "@typescript-eslint/utils" "6.19.1" + debug "^4.3.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/types@6.19.1": + version "6.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.19.1.tgz#2d4c9d492a63ede15e7ba7d129bdf7714b77f771" + integrity sha512-6+bk6FEtBhvfYvpHsDgAL3uo4BfvnTnoge5LrrCj2eJN8g3IJdLTD4B/jK3Q6vo4Ql/Hoip9I8aB6fF+6RfDqg== + +"@typescript-eslint/typescript-estree@6.19.1": + version "6.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.19.1.tgz#796d88d88882f12e85bb33d6d82d39e1aea54ed1" + integrity sha512-aFdAxuhzBFRWhy+H20nYu19+Km+gFfwNO4TEqyszkMcgBDYQjmPJ61erHxuT2ESJXhlhrO7I5EFIlZ+qGR8oVA== + dependencies: + "@typescript-eslint/types" "6.19.1" + "@typescript-eslint/visitor-keys" "6.19.1" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + minimatch "9.0.3" + semver "^7.5.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/utils@6.19.1", "@typescript-eslint/utils@^6.19.0": + version "6.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.19.1.tgz#df93497f9cfddde2bcc2a591da80536e68acd151" + integrity sha512-JvjfEZuP5WoMqwh9SPAPDSHSg9FBHHGhjPugSRxu5jMfjvBpq5/sGTD+9M9aQ5sh6iJ8AY/Kk/oUYVEMAPwi7w== + dependencies: + "@eslint-community/eslint-utils" "^4.4.0" + "@types/json-schema" "^7.0.12" + "@types/semver" "^7.5.0" + "@typescript-eslint/scope-manager" "6.19.1" + "@typescript-eslint/types" "6.19.1" + "@typescript-eslint/typescript-estree" "6.19.1" + semver "^7.5.4" + +"@typescript-eslint/visitor-keys@6.19.1": + version "6.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.1.tgz#2164073ed4fc34a5ff3b5e25bb5a442100454c4c" + integrity sha512-gkdtIO+xSO/SmI0W68DBg4u1KElmIUo3vXzgHyGPs6cxgB0sa3TlptRAAE0hUY1hM6FcDKEv7aIwiTGm76cXfQ== + dependencies: + "@typescript-eslint/types" "6.19.1" + eslint-visitor-keys "^3.4.1" + "@ungap/structured-clone@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406" @@ -2996,7 +3125,7 @@ acorn@^8.0.4, acorn@^8.1.0, acorn@^8.8.2: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== -acorn@^8.11.2, acorn@^8.5.0: +acorn@^8.11.3, acorn@^8.5.0: version "8.11.3" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== @@ -5543,6 +5672,14 @@ enhanced-resolve@^4.1.1, enhanced-resolve@^4.5.0: memory-fs "^0.5.0" tapable "^1.0.0" +enhanced-resolve@^5.12.0: + version "5.15.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz#1af946c7d93603eb88e9896cee4904dc012e9c35" + integrity sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg== + dependencies: + graceful-fs "^4.2.4" + tapable "^2.2.0" + entities@1.0: version "1.0.0" resolved "https://registry.yarnpkg.com/entities/-/entities-1.0.0.tgz#b2987aa3821347fcde642b24fdfc9e4fb712bf26" @@ -5772,7 +5909,20 @@ eslint-import-resolver-node@^0.3.9: is-core-module "^2.13.0" resolve "^1.22.4" -eslint-module-utils@^2.8.0: +eslint-import-resolver-typescript@^3.6.1: + version "3.6.1" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.6.1.tgz#7b983680edd3f1c5bce1a5829ae0bc2d57fe9efa" + integrity sha512-xgdptdoi5W3niYeuQxKmzVDTATvLYqhpwmykwsh7f6HIOStGWEIL9iqZgQDF9u9OEzrRwR8no5q2VT+bjAujTg== + dependencies: + debug "^4.3.4" + enhanced-resolve "^5.12.0" + eslint-module-utils "^2.7.4" + fast-glob "^3.3.1" + get-tsconfig "^4.5.0" + is-core-module "^2.11.0" + is-glob "^4.0.3" + +eslint-module-utils@^2.7.4, eslint-module-utils@^2.8.0: version "2.8.0" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz#e439fee65fc33f6bba630ff621efc38ec0375c49" integrity sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw== @@ -5936,7 +6086,7 @@ estraverse@^4.1.1: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== -estraverse@^5.1.0, estraverse@^5.2.0: +estraverse@^5.1.0, estraverse@^5.2.0, estraverse@^5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== @@ -6187,6 +6337,17 @@ fast-glob@^3.2.9: merge2 "^1.3.0" micromatch "^4.0.4" +fast-glob@^3.3.1: + version "3.3.2" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" + integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" @@ -6727,6 +6888,13 @@ get-symbol-description@^1.0.0: call-bind "^1.0.2" get-intrinsic "^1.1.1" +get-tsconfig@^4.5.0: + version "4.7.2" + resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.7.2.tgz#0dcd6fb330391d46332f4c6c1bf89a6514c2ddce" + integrity sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A== + dependencies: + resolve-pkg-maps "^1.0.0" + get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" @@ -6833,7 +7001,7 @@ globalthis@^1.0.3: dependencies: define-properties "^1.1.3" -globby@^11.0.4: +globby@^11.0.4, globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== @@ -7564,6 +7732,13 @@ is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.7: resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== +is-core-module@^2.11.0, is-core-module@^2.13.1: + version "2.13.1" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384" + integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw== + dependencies: + hasown "^2.0.0" + is-core-module@^2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.0.tgz#bb52aa6e2cbd49a30c2ba68c42bf3435ba6072db" @@ -7571,13 +7746,6 @@ is-core-module@^2.13.0: dependencies: has "^1.0.3" -is-core-module@^2.13.1: - version "2.13.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384" - integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw== - dependencies: - hasown "^2.0.0" - is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -9211,6 +9379,13 @@ minimalistic-crypto-utils@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== +minimatch@9.0.3: + version "9.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825" + integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg== + dependencies: + brace-expansion "^2.0.1" + minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" @@ -11703,6 +11878,11 @@ resolve-from@^5.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== +resolve-pkg-maps@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz#616b3dc2c57056b5588c31cdf4b3d64db133720f" + integrity sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw== + resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" @@ -12838,6 +13018,11 @@ tapable@^1.0.0, tapable@^1.0.0-beta.5, tapable@^1.1.3: resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2" integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== +tapable@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" + integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== + tar-fs@^2.0.0, tar-fs@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.1.tgz#489a15ab85f1f0befabb370b7de4f9eb5cbe8784" @@ -13103,6 +13288,11 @@ trim-repeated@^1.0.0: dependencies: escape-string-regexp "^1.0.2" +ts-api-utils@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.0.3.tgz#f12c1c781d04427313dbac808f453f050e54a331" + integrity sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg== + ts-pnp@^1.1.6: version "1.2.0" resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92" From 0787dc1fef61448652318a520f5e803ad7d78af2 Mon Sep 17 00:00:00 2001 From: Valentyne Stigloher Date: Fri, 19 Jan 2024 15:31:49 +0100 Subject: [PATCH 04/11] (ts)(test) use ts-jest --- jest.config.js | 8 ---- jest.config.ts | 23 ++++++++++ package.json | 2 + yarn.lock | 119 ++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 137 insertions(+), 15 deletions(-) delete mode 100644 jest.config.js create mode 100644 jest.config.ts diff --git a/jest.config.js b/jest.config.js deleted file mode 100644 index 62f22f843..000000000 --- a/jest.config.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - globals: { - // define the config global here, but fill its properties later in the individual tests - config: {}, - }, - testPathIgnorePatterns: ['.yarn', 'node_modules'], - transform: {}, -}; diff --git a/jest.config.ts b/jest.config.ts new file mode 100644 index 000000000..a6b37747c --- /dev/null +++ b/jest.config.ts @@ -0,0 +1,23 @@ +import type { Config } from 'jest'; + +const config: Config = { + extensionsToTreatAsEsm: ['.ts'], + globals: { + // define the config global here, but fill its properties later in the individual tests + config: {}, + }, + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, + testEnvironment: 'node', + testPathIgnorePatterns: ['.yarn', 'node_modules'], + transform: { + '^.+\\.ts$': ['ts-jest', { + // use isolated modules to speed up test execution; type checking happens separately + isolatedModules: true, + useESM: true, + }], + }, +}; + +export default config; diff --git a/package.json b/package.json index 1cde5c562..fe2a5ee0f 100644 --- a/package.json +++ b/package.json @@ -123,6 +123,8 @@ "sharp": "^0.31.3", "string-replace-loader": "^2.3.0", "suml-loader": "^0.1.1", + "ts-jest": "^29.1.1", + "ts-node": "^10.9.2", "typescript": "^5.3.3", "webpack": "^4.47.0", "yaml-loader": "^0.8.0" diff --git a/yarn.lock b/yarn.lock index 16325daeb..1606f0e97 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1272,6 +1272,13 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@cspotcode/source-map-support@^0.8.0": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== + dependencies: + "@jridgewell/trace-mapping" "0.3.9" + "@csstools/cascade-layer-name-parser@^1.0.5": version "1.0.5" resolved "https://registry.npmjs.org/@csstools/cascade-layer-name-parser/-/cascade-layer-name-parser-1.0.5.tgz#c4d276e32787651df0007af22c9fa70d9c9ca3c2" @@ -1817,7 +1824,7 @@ "@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/trace-mapping" "^0.3.9" -"@jridgewell/resolve-uri@^3.1.0": +"@jridgewell/resolve-uri@^3.0.3", "@jridgewell/resolve-uri@^3.1.0": version "3.1.1" resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721" integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA== @@ -1840,6 +1847,14 @@ resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== +"@jridgewell/trace-mapping@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.18": version "0.3.20" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz#72e45707cf240fa6b081d0366f8265b0cd10197f" @@ -2362,6 +2377,26 @@ resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad" integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA== +"@tsconfig/node10@^1.0.7": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" + integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== + +"@tsconfig/node12@^1.0.7": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" + integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== + +"@tsconfig/node14@^1.0.0": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" + integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== + +"@tsconfig/node16@^1.0.2": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" + integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== + "@types/autoprefixer@^10.2.0": version "10.2.0" resolved "https://registry.yarnpkg.com/@types/autoprefixer/-/autoprefixer-10.2.0.tgz#cb6cd67f00337607433b17ebf2cee511db957b9e" @@ -3115,6 +3150,11 @@ acorn-walk@^8.0.0, acorn-walk@^8.0.2: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== +acorn-walk@^8.1.1: + version "8.3.2" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.2.tgz#7703af9415f1b6db9315d6895503862e231d34aa" + integrity sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A== + acorn@^6.4.1: version "6.4.2" resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.2.tgz#35866fd710528e92de10cf06016498e47e39e1e6" @@ -3125,7 +3165,7 @@ acorn@^8.0.4, acorn@^8.1.0, acorn@^8.8.2: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== -acorn@^8.11.3, acorn@^8.5.0: +acorn@^8.11.3, acorn@^8.4.1, acorn@^8.5.0: version "8.11.3" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== @@ -3306,6 +3346,11 @@ are-we-there-yet@^3.0.0: delegates "^1.0.0" readable-stream "^3.6.0" +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + arg@^5.0.2: version "5.0.2" resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.2.tgz#c81433cc427c92c4dcf4865142dbca6f15acd59c" @@ -3976,6 +4021,13 @@ browserslist@^4.22.2: node-releases "^2.0.14" update-browserslist-db "^1.0.13" +bs-logger@0.x: + version "0.2.6" + resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8" + integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog== + dependencies: + fast-json-stable-stringify "2.x" + bser@2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/bser/-/bser-2.1.1.tgz#e6787da20ece9d07998533cfd9de6f5c38f4bc05" @@ -4800,7 +4852,7 @@ create-jest@^29.7.0: jest-util "^29.7.0" prompts "^2.0.1" -create-require@^1.1.1: +create-require@^1.1.0, create-require@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== @@ -5384,6 +5436,11 @@ diff-sequences@^29.6.3: resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.6.3.tgz#4deaf894d11407c51efc8418012f9e70b84ea921" integrity sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q== +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + diffie-hellman@^5.0.0: version "5.0.3" resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" @@ -6348,7 +6405,7 @@ fast-glob@^3.3.1: merge2 "^1.3.0" micromatch "^4.0.4" -fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: +fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== @@ -8416,7 +8473,7 @@ jest-snapshot@^29.7.0: pretty-format "^29.7.0" semver "^7.5.3" -jest-util@^29.7.0: +jest-util@^29.0.0, jest-util@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.7.0.tgz#23c2b62bfb22be82b44de98055802ff3710fc0bc" integrity sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA== @@ -8939,7 +8996,7 @@ lodash.kebabcase@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36" integrity sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g== -lodash.memoize@^4.1.2: +lodash.memoize@4.x, lodash.memoize@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag== @@ -9073,6 +9130,11 @@ make-dir@^4.0.0: dependencies: semver "^7.5.3" +make-error@1.x, make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + make-fetch-happen@^9.1.0: version "9.1.0" resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-9.1.0.tgz#53085a09e7971433e6765f7971bf63f4e05cb968" @@ -13293,6 +13355,39 @@ ts-api-utils@^1.0.1: resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.0.3.tgz#f12c1c781d04427313dbac808f453f050e54a331" integrity sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg== +ts-jest@^29.1.1: + version "29.1.1" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.1.1.tgz#f58fe62c63caf7bfcc5cc6472082f79180f0815b" + integrity sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA== + dependencies: + bs-logger "0.x" + fast-json-stable-stringify "2.x" + jest-util "^29.0.0" + json5 "^2.2.3" + lodash.memoize "4.x" + make-error "1.x" + semver "^7.5.3" + yargs-parser "^21.0.1" + +ts-node@^10.9.2: + version "10.9.2" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" + integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ== + dependencies: + "@cspotcode/source-map-support" "^0.8.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + v8-compile-cache-lib "^3.0.1" + yn "3.1.1" + ts-pnp@^1.1.6: version "1.2.0" resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92" @@ -13738,6 +13833,11 @@ uuid@^8.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== +v8-compile-cache-lib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + v8-to-istanbul@^9.0.1: version "9.2.0" resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.2.0.tgz#2ed7644a245cddd83d4e087b9b33b3e62dfd10ad" @@ -14333,7 +14433,7 @@ yargs-parser@^11.1.1: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^21.1.1: +yargs-parser@^21.0.1, yargs-parser@^21.1.1: version "21.1.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== @@ -14377,6 +14477,11 @@ yauzl@^2.10.0: buffer-crc32 "~0.2.3" fd-slicer "~1.1.0" +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" From 210fc736556a5202249017f79d8986fa39f4ddfb Mon Sep 17 00:00:00 2001 From: Valentyne Stigloher Date: Fri, 19 Jan 2024 19:22:09 +0100 Subject: [PATCH 05/11] (ts) use TypeScript in Nuxt --- .eslintrc.json | 18 ++- README.md | 14 +- locale/config.ts | 2 + locale/tsconfig.json | 4 + nuxt.config.js => nuxt.config.ts | 71 ++++++---- package.json | 2 + server/global.d.ts | 21 +++ server/{index.js => index.ts} | 30 +++-- server/{no-ssr.js => no-ssr.ts} | 6 +- shims.d.ts | 4 + tsconfig.json | 7 +- yarn.lock | 224 +++++++++++++++++++++++++++++-- 12 files changed, 341 insertions(+), 62 deletions(-) create mode 100644 locale/config.ts create mode 100644 locale/tsconfig.json rename nuxt.config.js => nuxt.config.ts (91%) create mode 100644 server/global.d.ts rename server/{index.js => index.ts} (83%) rename server/{no-ssr.js => no-ssr.ts} (78%) create mode 100644 shims.d.ts diff --git a/.eslintrc.json b/.eslintrc.json index 5eb08f635..f3a4b1079 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -172,7 +172,7 @@ }, "overrides": [ { - "files": ["*.ts"], + "files": ["*.ts", "*.vue"], "rules": { // rules which require type information need to be listed separately "@typescript-eslint/await-thenable": "error", @@ -194,12 +194,19 @@ "project": true } }, + { + "files": ["*.d.ts"], + "rules": { + // var is needed for globalThis declaration + "no-var": "off" + } + }, { "files": ["*.json"], "parser": "jsonc-eslint-parser" }, { - "files": [".eslintrc.json"], + "files": [".eslintrc.json", "tsconfig.json"], "rules": { "jsonc/no-comments": "off" } @@ -213,7 +220,12 @@ }, { "files": ["*.vue"], - "parser": "vue-eslint-parser" + "parser": "vue-eslint-parser", + "parserOptions": { + "parser": "@typescript-eslint/parser", + "extraFileExtensions": [".vue"], + "project": true + } } ] } diff --git a/README.md b/README.md index 8f07aebdf..b2d7182c6 100644 --- a/README.md +++ b/README.md @@ -176,9 +176,10 @@ Remember to also set `MAILER_OVERWRITE` to your own address ### Troubleshooting -If you're having issues with [HRM](https://webpack.js.org/concepts/hot-module-replacement/) (Hot Module Replacement) not reloading automatically: +#### Hot Module Replacement in Nuxt development mode +If you're having issues with [HMR](https://webpack.js.org/concepts/hot-module-replacement/) not reloading automatically: - The modules within `package.json` are matching the repo's `package.json`. -- `nuxt.config.js` has the following option: +- `nuxt.config.ts` has the following option: ```js watchers: { webpack: { @@ -188,6 +189,15 @@ If you're having issues with [HRM](https://webpack.js.org/concepts/hot-module-re } ``` +#### Out-of-Memory in Nuxt development mode +If you experience a `JavaScript heap out of memory` error, it may help to disable typechecking (you can still typecheck via your editor or `yarn vue-ts`): +- add to `nuxt.config.ts`: + ```js + typescript: { + typeCheck: false, + }, + ``` + ## Translation ### Contributing to an existing language version diff --git a/locale/config.ts b/locale/config.ts new file mode 100644 index 000000000..3c7dc66c4 --- /dev/null +++ b/locale/config.ts @@ -0,0 +1,2 @@ +// TODO: replace with concrete type +export type Config = any; diff --git a/locale/tsconfig.json b/locale/tsconfig.json new file mode 100644 index 000000000..c11bc3863 --- /dev/null +++ b/locale/tsconfig.json @@ -0,0 +1,4 @@ +{ + // necessary for a peculiar edge case where the symlinked locale to data/ yields an error with ESLint + "extends": "../tsconfig.json" +} diff --git a/nuxt.config.js b/nuxt.config.ts similarity index 91% rename from nuxt.config.js rename to nuxt.config.ts index 17f7ab301..9bf30b753 100644 --- a/nuxt.config.js +++ b/nuxt.config.ts @@ -5,6 +5,10 @@ import autoprefixer from 'autoprefixer'; import fs from 'fs'; import path from 'path'; import rtlcss from 'rtlcss'; +import type { NuxtConfig } from '@nuxt/types'; +import type { IncomingMessage } from 'connect'; +import type { ServerResponse } from 'http'; +import type { Plugin as PostcssPlugin } from 'postcss'; import { buildDict, buildList } from './src/helpers.js'; import buildLocaleList from './src/buildLocaleList.js'; import formatError from './src/error.js'; @@ -44,15 +48,15 @@ const allVersionsUrls = buildList(function*() { yield 'https://test.pronouns.page'; } else { yield 'https://pronouns.page'; - for (const loc in locales) { - yield locales[loc].url; + for (const localeDescription of Object.values(locales)) { + yield localeDescription.url; } } }); process.env.ALL_LOCALES_URLS = allVersionsUrls.join(','); const buildFlags = () => { - const flags = []; + const flags: [string, string][] = []; for (const flag of fs.readdirSync(`${__dirname}/static/flags/`)) { let flagDisplay = flag .replace(new RegExp('\.png$'), '') @@ -87,17 +91,15 @@ const buildFlags = () => { }); }; -const postCssPlugins = [ - autoprefixer, +const postCssPlugins: PostcssPlugin[] = [ + autoprefixer(), ]; if (config.dir === 'rtl') { - postCssPlugins.push(rtlcss); + postCssPlugins.push(rtlcss() as PostcssPlugin); } -const getAllFiles = function (dirPath, arrayOfFiles) { - arrayOfFiles = arrayOfFiles || []; - +const getAllFiles = (dirPath: string, arrayOfFiles: string[] = []): string[] => { fs.readdirSync(dirPath).forEach(function (file) { if (fs.statSync(`${dirPath}/${file}`).isDirectory()) { arrayOfFiles = getAllFiles(`${dirPath}/${file}`, arrayOfFiles); @@ -108,18 +110,18 @@ const getAllFiles = function (dirPath, arrayOfFiles) { return arrayOfFiles; }; -const jsons = {}; +const jsons: Record = {}; for (const file of getAllFiles(`${__dirname}/data/docs`)) { if (!file.endsWith('.json')) { continue; } - jsons[path.relative(`${__dirname}/data/docs`, file)] = JSON.parse(fs.readFileSync(file)); + jsons[path.relative(`${__dirname}/data/docs`, file)] = JSON.parse(fs.readFileSync(file).toString()); } const hostname = process.env.HOST ?? '0.0.0.0'; const port = parseInt(process.env.PORT ?? '3000'); -export default { +const nuxtConfig: NuxtConfig = { server: { host: hostname, // listen on any host name port, @@ -170,6 +172,14 @@ export default { { src: '~/plugins/browserDetect.js' }, ], components: true, + buildModules: [ + '@nuxt/typescript-build', + ], + loaders: { + ts: { + configFile: path.resolve(__dirname, 'tsconfig.json'), + }, + }, modules: [ '@privyid/nuxt-csrf', '@nuxtjs/pwa', @@ -226,7 +236,7 @@ export default { }, }, extend(config) { - config.module.rules.push({ + config.module!.rules.push({ test: /\.csv|\.tsv$/, loader: 'csv-loader', options: { @@ -236,19 +246,19 @@ export default { delimiter: '\t', }, }); - config.module.rules.push({ + config.module!.rules.push({ test: /\.suml$/, loader: 'suml-loader', }); - config.module.rules.push({ + config.module!.rules.push({ test: /\.md$/, use: ['html-loader', 'markdown-loader'], }); - config.module.rules.push({ + config.module!.rules.push({ test: /\.ya?ml$/, use: 'yaml-loader', }); - config.module.rules.push({ + config.module!.rules.push({ test: /\.js$/, loader: 'string-replace-loader', options: { @@ -275,32 +285,35 @@ export default { transpile: ['markdown-it'], }, env: { - ENV: process.env.ENV, - BASE_URL: process.env.BASE_URL, + ENV: process.env.ENV!, + BASE_URL: process.env.BASE_URL!, HOME_URL: process.env.HOME_URL || 'https://pronouns.page', TITLE: title, PUBLIC_KEY: fs.readFileSync(`${__dirname}/keys/public.pem`).toString(), CONFIG: config, LOCALE: config.locale, + // @ts-expect-error: Nuxt checks for string, but object works fine LOCALES: locales, + // @ts-expect-error: Nuxt checks for string, but string[] works fine FLAGS: buildFlags(), + // @ts-expect-error: Nuxt checks for string, but string[] works fine FLAGS_ASTERISK: ['Heteroromantic', 'Heterosexual', 'Monoamorous', 'Monogamous', 'Cis Ally', 'Straight Ally'], BUCKET: `https://${process.env.AWS_S3_BUCKET}.s3-${process.env.AWS_REGION}.amazonaws.com`, - CLOUDFRONT: process.env.CLOUDFRONT, - STATS_FILE: process.env.STATS_FILE, - TURNSTILE_SITEKEY: process.env.TURNSTILE_SITEKEY, + CLOUDFRONT: process.env.CLOUDFRONT!, + STATS_FILE: process.env.STATS_FILE!, + TURNSTILE_SITEKEY: process.env.TURNSTILE_SITEKEY!, ALL_LOCALES_URLS: process.env.ALL_LOCALES_URLS, LOGO: logo, MIN_AGE: config.ageLimit || 13, JSONS: JSON.stringify(jsons), - PLAUSIBLE_API_HOST: process.env.PLAUSIBLE_API_HOST, - HEARTBEAT_LINK: process.env.HEARTBEAT_LINK, - VERSION: version, + PLAUSIBLE_API_HOST: process.env.PLAUSIBLE_API_HOST!, + HEARTBEAT_LINK: process.env.HEARTBEAT_LINK!, + VERSION: version!, KEYWORDS: keywords, }, serverMiddleware: [ - '~/server/no-ssr.js', - '~/server/index.js', + '~/server/no-ssr.ts', + '~/server/index.ts', ], axios: { baseURL: `${process.env.BASE_URL}/api`, @@ -458,7 +471,7 @@ export default { hooks: { render: { errorMiddleware(app) { - app.use((err, req, res, next) => { + app.use((err: any, req: IncomingMessage, res: ServerResponse, next: (err?: any) => void) => { if (err) { console.error(formatError(err, req)); } @@ -468,3 +481,5 @@ export default { }, }, }; + +export default nuxtConfig; diff --git a/package.json b/package.json index fe2a5ee0f..3243409cf 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,8 @@ }, "devDependencies": { "@fortawesome/fontawesome-pro": "git+ssh://git@gitlab.com:Avris/FontAwesomePro.git", + "@nuxt/types": "2.17.2", + "@nuxt/typescript-build": "^3.0.2", "@stylistic/eslint-plugin": "^1.5.4", "@types/autoprefixer": "^10.2.0", "@types/cookie-parser": "^1.4.6", diff --git a/server/global.d.ts b/server/global.d.ts new file mode 100644 index 000000000..c41e1cc44 --- /dev/null +++ b/server/global.d.ts @@ -0,0 +1,21 @@ +import type { LazyDatabase } from './index.ts'; +import type { Config } from '../locale/config.ts'; + +declare global { + namespace Express { + export interface Request { + rawUser: any; + user: any | null; + isGranted: (area: string, locale: string) => boolean; + locales: Record; + db: LazyDatabase; + isUserAllowedToPost: () => Promise; + } + + export interface Response { + spa?: boolean; + } + } + + var config: Config; +} diff --git a/server/index.js b/server/index.ts similarity index 83% rename from server/index.js rename to server/index.ts index d7ec028c3..778b22a9b 100644 --- a/server/index.js +++ b/server/index.ts @@ -1,6 +1,8 @@ import '../src/dotenv.js'; import express from 'express'; +import type { Request, Response, NextFunction } from 'express'; +import type { Database as SqliteDatabase, ISqlite } from 'sqlite'; import authenticate from '../src/authenticate.js'; import dbConnection from './db.js'; import cookieParser from 'cookie-parser'; @@ -53,7 +55,7 @@ app.use(express.json({ app.use(express.urlencoded({ extended: true })); app.use(cookieParser()); app.use(session({ - secret: process.env.SECRET, + secret: process.env.SECRET!, cookie: cookieSettings, resave: false, saveUninitialized: false, @@ -64,12 +66,14 @@ app.use(session({ // app.use(csurf({ cookie: true })); // app.use(csrfHandleError()) -class LazyDatabase { +export class LazyDatabase { + db: SqliteDatabase | null; + constructor() { this.db = null; } - async init() { + async init(): Promise { if (this.db === null) { this.db = await dbConnection(); // await this.db.get('PRAGMA journal_mode = WAL;'); @@ -78,17 +82,17 @@ class LazyDatabase { } } - async get(...args) { + async get(sql: ISqlite.SqlType, ...args: unknown[]): Promise { await this.init(); - return this.db.get(...args); + return this.db!.get(sql, ...args); } - async all(...args) { + async all(sql: ISqlite.SqlType, ...args: unknown[]): Promise { await this.init(); - return this.db.all(...args); + return this.db!.all(sql, ...args); } - async close() { + async close(): Promise { if (this.db !== null) { try { await this.db.close(); @@ -101,11 +105,13 @@ app.use(async function (req, res, next) { try { req.rawUser = authenticate(req); req.user = req.rawUser && req.rawUser.authenticated ? req.rawUser : null; - req.isGranted = (area = '', locale = global.config.locale) => req.user && isGranted(req.user, locale, area); + req.isGranted = (area = '', locale = global.config.locale): boolean => { + return req.user && isGranted(req.user, locale, area); + }; req.locales = buildLocaleList(global.config.locale, global.config.locale === '_'); req.db = new LazyDatabase(); - req.isUserAllowedToPost = async () => { - const user = await req.db.get(SQL`SELECT bannedReason FROM users WHERE id = ${req.user.id}`); + req.isUserAllowedToPost = async (): Promise => { + const user = await req.db.get(SQL`SELECT bannedReason FROM users WHERE id = ${req.user.id}`) as any; return user && !user.bannedReason; }; res.on('finish', async () => { @@ -142,7 +148,7 @@ app.use(calendarRoute); app.use(translationsRoute); app.use(subscriptionRoute); -app.use(function (err, req, res, _next) { +app.use((err: unknown, req: Request, res: Response, _next: NextFunction) => { console.error(formatError(err, req)); res.status(500).send('Unexpected server error'); req.db.close(); diff --git a/server/no-ssr.js b/server/no-ssr.ts similarity index 78% rename from server/no-ssr.js rename to server/no-ssr.ts index e22918c0b..a653b9018 100644 --- a/server/no-ssr.js +++ b/server/no-ssr.ts @@ -1,9 +1,11 @@ +import type { Request, Response, NextFunction } from 'express'; + import isHighLoadTime from './overload.js'; const USER_AGENT_BOTS = /bot|crawler|baiduspider|80legs|ia_archiver|voyager|curl|wget|yahoo! slurp|mediapartners-google|facebookexternalhit|twitterbot|whatsapp|php|python|mastodon/; const USER_AGENT_BROWSERS = /mozilla|msie|gecko|firefox|edge|opera|safari|netscape|konqueror|android/; -const isBrowser = (userAgent) => { +const isBrowser = (userAgent: string | undefined): boolean => { if (!userAgent) { return false; } @@ -13,7 +15,7 @@ const isBrowser = (userAgent) => { return isProbablyBrowser && !isProbablyBot; }; -export default function (req, res, next) { +export default function (req: Request, res: Response, next: NextFunction): void { if (process.env.NODE_ENV === 'production' && !req.url.startsWith('/card/@')) { res.spa = isBrowser(req.headers['user-agent']) || isHighLoadTime(process.env.LOCALE); } diff --git a/shims.d.ts b/shims.d.ts new file mode 100644 index 000000000..1a9f5b5f1 --- /dev/null +++ b/shims.d.ts @@ -0,0 +1,4 @@ +declare module '*.vue' { + import Vue from 'vue'; + export default Vue; +} diff --git a/tsconfig.json b/tsconfig.json index 18da21544..b23ec3f87 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,12 @@ "allowJs": true, "strict": true, "sourceMap": true, - "noEmit": true + "noEmit": true, + "types": [ + "@nuxt/types", + "@nuxt/typescript-build", + "@types/node" + ] }, "exclude": [ "dist", diff --git a/yarn.lock b/yarn.lock index 1606f0e97..f32f7af4a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23,7 +23,7 @@ "@babel/highlight" "^7.22.10" chalk "^2.4.2" -"@babel/code-frame@^7.12.13", "@babel/code-frame@^7.22.13", "@babel/code-frame@^7.23.5": +"@babel/code-frame@^7.12.13", "@babel/code-frame@^7.22.13", "@babel/code-frame@^7.23.5", "@babel/code-frame@^7.8.3": version "7.23.5" resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz#9009b69a8c602293476ad598ff53e4562e15c244" integrity sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA== @@ -2136,6 +2136,37 @@ rc9 "^2.0.1" std-env "^3.3.1" +"@nuxt/types@2.17.2": + version "2.17.2" + resolved "https://registry.yarnpkg.com/@nuxt/types/-/types-2.17.2.tgz#1fa1d7019cdfeafb6f2eb74553a67f76e11e70de" + integrity sha512-0aAOe7CLfuVTGpP9OQhIUoGhut5kuChD6MkMtXpLXesjLzSWT9uu+uHi3y3+gPBdyRINXbFN+ETdDhhECAt3Kg== + dependencies: + "@types/babel__core" "7.20.3" + "@types/compression" "1.7.4" + "@types/connect" "3.4.37" + "@types/etag" "1.8.2" + "@types/file-loader" "5.0.3" + "@types/html-minifier" "4.0.4" + "@types/less" "3.0.5" + "@types/node" "^16" + "@types/optimize-css-assets-webpack-plugin" "5.0.7" + "@types/pug" "2.0.8" + "@types/serve-static" "1.15.4" + "@types/terser-webpack-plugin" "4.2.1" + "@types/webpack" "^4.41.35" + "@types/webpack-bundle-analyzer" "3.9.5" + "@types/webpack-hot-middleware" "2.25.5" + +"@nuxt/typescript-build@^3.0.2": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@nuxt/typescript-build/-/typescript-build-3.0.2.tgz#3bc9db607c83207f8dcbd8790a579710eb87469b" + integrity sha512-IFSznjafW5xm0XHg9Q9aHVW7i9J2pAYfyorh3ro3Pf0OnCbS0acmwBnp2juza+DqNhZa1DhNentmUsgiYp730g== + dependencies: + consola "^3.0.0" + defu "^6.0.0" + fork-ts-checker-webpack-plugin "6.5.3" + ts-loader "8.4.0" + "@nuxt/utils@2.17.2": version "2.17.2" resolved "https://registry.npmjs.org/@nuxt/utils/-/utils-2.17.2.tgz#000d560ce0622882231659be4ca773a2d5769cb7" @@ -2404,6 +2435,17 @@ dependencies: autoprefixer "*" +"@types/babel__core@7.20.3": + version "7.20.3" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.3.tgz#d5625a50b6f18244425a1359a858c73d70340778" + integrity sha512-54fjTSeSHwfan8AyHWrKbfBWiEUrNTZsUwPTDSNaaP1QDQIZbeNUg3a59E9D+375MzUw/x1vx2/0F5LBz+AeYA== + dependencies: + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" + "@types/babel__generator" "*" + "@types/babel__template" "*" + "@types/babel__traverse" "*" + "@types/babel__core@^7.1.14": version "7.20.5" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017" @@ -2445,6 +2487,21 @@ "@types/connect" "*" "@types/node" "*" +"@types/clean-css@*": + version "4.2.11" + resolved "https://registry.yarnpkg.com/@types/clean-css/-/clean-css-4.2.11.tgz#3f170dedd8d096fe7e7bd1c8dda0c8314217cbe6" + integrity sha512-Y8n81lQVTAfP2TOdtJJEsCoYl1AnOkqDqMvXb9/7pfgZZ7r8YrEyurrAvAoAjHOGXKRybay+5CsExqIH6liccw== + dependencies: + "@types/node" "*" + source-map "^0.6.0" + +"@types/compression@1.7.4": + version "1.7.4" + resolved "https://registry.yarnpkg.com/@types/compression/-/compression-1.7.4.tgz#c1af4a0f2d72ea6c96300ae58b9842aa87d77b6e" + integrity sha512-sdFVnQJRkQBX83ydsLCBm4A39p45y0QkxdAR689yOtAFNbbS9Acrp86RZWJj6BHRXyZH9tX4t1dU7XDiGdY3nA== + dependencies: + "@types/express" "*" + "@types/connect@*": version "3.4.38" resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858" @@ -2452,6 +2509,13 @@ dependencies: "@types/node" "*" +"@types/connect@3.4.37": + version "3.4.37" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.37.tgz#c66a96689fd3127c8772eb3e9e5c6028ec1a9af5" + integrity sha512-zBUSRqkfZ59OcwXon4HVxhx5oWCJmc0OtBTK05M+p0dYjgN6iTwIL2T/WbsQZrEsdnwaF9cWQ+azOnpPvIqY3Q== + dependencies: + "@types/node" "*" + "@types/cookie-parser@^1.4.6": version "1.4.6" resolved "https://registry.yarnpkg.com/@types/cookie-parser/-/cookie-parser-1.4.6.tgz#002643c514cccf883a65cbe044dbdc38c0b92ade" @@ -2464,6 +2528,13 @@ resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.3.3.tgz#85bc74ba782fb7aa3a514d11767832b0e3bc6803" integrity sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow== +"@types/etag@1.8.2": + version "1.8.2" + resolved "https://registry.yarnpkg.com/@types/etag/-/etag-1.8.2.tgz#c5714da83dcd0dd51f25e527daf36d0df051ea6c" + integrity sha512-z8Pbo2e+EZWMpuRPYSjhSivp2OEkqrMZBUfEAWlJC31WUCKveZ8ioWXHAC5BXRZfwxCBfYRhPij1YJHK1W6oDA== + dependencies: + "@types/node" "*" + "@types/express-serve-static-core@^4.17.33": version "4.17.41" resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz#5077defa630c2e8d28aa9ffc2c01c157c305bef6" @@ -2491,6 +2562,13 @@ "@types/qs" "*" "@types/serve-static" "*" +"@types/file-loader@5.0.3": + version "5.0.3" + resolved "https://registry.yarnpkg.com/@types/file-loader/-/file-loader-5.0.3.tgz#3ebe78567f7fbaa80e91f5147e1ea52961bea755" + integrity sha512-g9CX1svLDYL5Nnaa0Dj+XdGuGHfXVcsxpKsfBn3sQ/8X8RZPg1gCCwlhzEnfrXdyYB5hoKAsXOohZAd8iDBd/g== + dependencies: + "@types/webpack" "^4" + "@types/graceful-fs@^4.1.3": version "4.1.9" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" @@ -2503,6 +2581,15 @@ resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-5.1.2.tgz#693b316ad323ea97eed6b38ed1a3cc02b1672b57" integrity sha512-h4lTMgMJctJybDp8CQrxTUiiYmedihHWkjnF/8Pxseu2S6Nlfcy8kwboQ8yejh456rP2yWoEVm1sS/FVsfM48w== +"@types/html-minifier@4.0.4": + version "4.0.4" + resolved "https://registry.yarnpkg.com/@types/html-minifier/-/html-minifier-4.0.4.tgz#4d8501885918af2f74d9fbfb86acabca44af7306" + integrity sha512-kvzPbhN6CM+zFdOmLaGKF1DUnn9oYZteTiltHRFhsnj3vcnCZj1qVA0x1E7FTZvLT8e4WsHTSXk/0YV2NgOWOw== + dependencies: + "@types/clean-css" "*" + "@types/relateurl" "*" + "@types/uglify-js" "*" + "@types/http-errors@*": version "2.0.4" resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.4.tgz#7eb47726c391b7345a6ec35ad7f4de469cf5ba4f" @@ -2539,7 +2626,7 @@ resolved "https://registry.yarnpkg.com/@types/js-md5/-/js-md5-0.7.2.tgz#9766e8763dfbe23d146053535d4a2c06006b49b2" integrity sha512-IwcFIov1JbiEToo3DgrVEwkMUR1BVlVyLjk245AzGHyyOlyddDFIeSIZO+WlhTortOa4P1PdCS8cDrTl7RW1HA== -"@types/json-schema@^7.0.12": +"@types/json-schema@^7.0.12", "@types/json-schema@^7.0.4": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== @@ -2561,6 +2648,11 @@ dependencies: "@types/node" "*" +"@types/less@3.0.5": + version "3.0.5" + resolved "https://registry.yarnpkg.com/@types/less/-/less-3.0.5.tgz#8b219a7af34d4356934d5cdb31d5ed184b2766cc" + integrity sha512-OdhItUN0/Cx9+sWumdb3dxASoA0yStnZahvKcaSQmSR5qd7hZ6zhSriSQGUU3F8GkzFpIILKzut4xn9/GvhusA== + "@types/lodash@^4.14.175": version "4.14.197" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.197.tgz#e95c5ddcc814ec3e84c891910a01e0c8a378c54b" @@ -2594,6 +2686,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-20.5.1.tgz#178d58ee7e4834152b0e8b4d30cbfab578b9bb30" integrity sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg== +"@types/node@^16": + version "16.18.76" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.76.tgz#deecdf6b71b9ef45ceda63fec7220ddf2354d7a1" + integrity sha512-/GsO2uv1Z6R42lBr59dtem56gVF/yHKQaScggwU+gLU6DXE25sDmOar4c4IfWb3h+X/7OYZznPOFk7oGF3jQSA== + "@types/node@^20.11.5": version "20.11.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.5.tgz#be10c622ca7fcaa3cf226cf80166abc31389d86e" @@ -2608,6 +2705,13 @@ dependencies: "@types/node" "*" +"@types/optimize-css-assets-webpack-plugin@5.0.7": + version "5.0.7" + resolved "https://registry.yarnpkg.com/@types/optimize-css-assets-webpack-plugin/-/optimize-css-assets-webpack-plugin-5.0.7.tgz#56c9418ada90d3c38e43f338c8b20a85e087e45a" + integrity sha512-LcYr4KifgRzN4fdKvPlPWYvrKJdLUey1Qq1DUvyhaV8DVrEsTxCKGLeocPrxinzlehC0Z30U9Ea9Dc1cd0FmUg== + dependencies: + "@types/webpack" "^4" + "@types/papaparse@^5.3.14": version "5.3.14" resolved "https://registry.yarnpkg.com/@types/papaparse/-/papaparse-5.3.14.tgz#345cc2a675a90106ff1dc33b95500dfb30748031" @@ -2620,6 +2724,11 @@ resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== +"@types/pug@2.0.8": + version "2.0.8" + resolved "https://registry.yarnpkg.com/@types/pug/-/pug-2.0.8.tgz#1a85ecb760f7472d9ec3bab19bfe17454c69499d" + integrity sha512-QzhsZ1dMGyJbn/D9V80zp4GIA4J4rfAjCCxc3MP+new0E8dyVdSkR735Lx+n3LIaHNFcjHL5+TbziccuT+fdoQ== + "@types/puppeteer@^5.4.3": version "5.4.7" resolved "https://registry.yarnpkg.com/@types/puppeteer/-/puppeteer-5.4.7.tgz#b8804737c62c6e236de0c03fa74f91c174bf96b6" @@ -2637,6 +2746,11 @@ resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb" integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ== +"@types/relateurl@*": + version "0.2.33" + resolved "https://registry.yarnpkg.com/@types/relateurl/-/relateurl-0.2.33.tgz#fa174c30100d91e88d7b0ba60cefd7e8c532516f" + integrity sha512-bTQCKsVbIdzLqZhLkF5fcJQreE4y1ro4DIyVrlDNSCJRRwHhB8Z+4zXXa8jN6eDvc2HbRsEYgbvrnGvi54EpSw== + "@types/rtlcss@^3.1.2": version "3.5.4" resolved "https://registry.yarnpkg.com/@types/rtlcss/-/rtlcss-3.5.4.tgz#8db1e02fe911cf5b71f4cb42dafce8ccaef8e1e1" @@ -2666,6 +2780,15 @@ "@types/mime" "*" "@types/node" "*" +"@types/serve-static@1.15.4": + version "1.15.4" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.15.4.tgz#44b5895a68ca637f06c229119e1c774ca88f81b2" + integrity sha512-aqqNfs1XTF0HDrFdlY//+SGUxmdSUbjeRXb5iaZc3x0/vMbYmdw9qvOgHWOyyLFxSSRnUuP5+724zBgfw8/WAw== + dependencies: + "@types/http-errors" "*" + "@types/mime" "*" + "@types/node" "*" + "@types/source-list-map@*": version "0.1.2" resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" @@ -2688,6 +2811,14 @@ resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.8.tgz#b94a4391c85666c7b73299fd3ad79d4faa435310" integrity sha512-ipixuVrh2OdNmauvtT51o3d8z12p6LtFW9in7U79der/kwejjdNchQC5UMn5u/KxNoM7VHHOs/l8KS8uHxhODQ== +"@types/terser-webpack-plugin@4.2.1": + version "4.2.1" + resolved "https://registry.yarnpkg.com/@types/terser-webpack-plugin/-/terser-webpack-plugin-4.2.1.tgz#cbeccec2b011ad12a9ddcd60b4089c9e138a313a" + integrity sha512-x688KsgQKJF8PPfv4qSvHQztdZNHLlWJdolN9/ptAGimHVy3rY+vHdfglQDFh1Z39h7eMWOd6fQ7ke3PKQcdyA== + dependencies: + "@types/webpack" "^4" + terser "^4.6.13" + "@types/uglify-js@*": version "3.17.1" resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.17.1.tgz#e0ffcef756476410e5bce2cb01384ed878a195b5" @@ -2695,6 +2826,21 @@ dependencies: source-map "^0.6.1" +"@types/webpack-bundle-analyzer@3.9.5": + version "3.9.5" + resolved "https://registry.yarnpkg.com/@types/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.9.5.tgz#65e53dd10931babc55da739d4adad764e20fe1e8" + integrity sha512-QlyDyX7rsOIJHASzXWlih8DT9fR+XCG9cwIV/4pKrtScdHv4XFshdEf/7iiqLqG0lzWcoBdzG8ylMHQ5XLNixw== + dependencies: + "@types/webpack" "^4" + +"@types/webpack-hot-middleware@2.25.5": + version "2.25.5" + resolved "https://registry.yarnpkg.com/@types/webpack-hot-middleware/-/webpack-hot-middleware-2.25.5.tgz#b42c7a00fa3e508b3fb9809cd7261f6dbe01355f" + integrity sha512-/eRWWMgZteNzl17qLCRdRmtKPZuWy984b11Igz9+BAU5a99Hc2AJinnMohMPVahGRSHby4XwsnjlgIt9m0Ce3g== + dependencies: + "@types/connect" "*" + "@types/webpack" "^4" + "@types/webpack-sources@*": version "3.2.0" resolved "https://registry.yarnpkg.com/@types/webpack-sources/-/webpack-sources-3.2.0.tgz#16d759ba096c289034b26553d2df1bf45248d38b" @@ -2704,7 +2850,7 @@ "@types/source-list-map" "*" source-map "^0.7.3" -"@types/webpack@^4.41.38": +"@types/webpack@^4", "@types/webpack@^4.41.35", "@types/webpack@^4.41.38": version "4.41.38" resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.38.tgz#5a40ac81bdd052bf405e8bdcf3e1236f6db6dc26" integrity sha512-oOW7E931XJU1mVfCnxCVgv8GLFL768pDO5u2Gzk82i8yTIgX6i7cntyZOkZYb/JtYM8252SN9bQp9tgkVDSsRw== @@ -3226,7 +3372,7 @@ ajv-keywords@^5.1.0: dependencies: fast-deep-equal "^3.1.3" -ajv@^6.1.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: +ajv@^6.1.0, ajv@^6.10.2, ajv@^6.12.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -4329,7 +4475,7 @@ child_process@^1.0.2: resolved "https://registry.yarnpkg.com/child_process/-/child_process-1.0.2.tgz#b1f7e7fc73d25e7fd1d455adc94e143830182b5a" integrity sha512-Wmza/JzL0SiWz7kl6MhIKT5ceIlnFPJX+lwUGj7Clhy5MMldsSoJR0+uvRzOS5Kv45Mq7t1PoE8TsOA9bzvb6g== -"chokidar@>=3.0.0 <4.0.0", chokidar@^3.4.1, chokidar@^3.5.2, chokidar@^3.5.3: +"chokidar@>=3.0.0 <4.0.0", chokidar@^3.4.1, chokidar@^3.4.2, chokidar@^3.5.2, chokidar@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== @@ -4636,7 +4782,7 @@ consola@^2.15.0, consola@^2.15.3, consola@^2.6.0: resolved "https://registry.yarnpkg.com/consola/-/consola-2.15.3.tgz#2e11f98d6a4be71ff72e0bdf07bd23e12cb61550" integrity sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw== -consola@^3.2.3: +consola@^3.0.0, consola@^3.2.3: version "3.2.3" resolved "https://registry.yarnpkg.com/consola/-/consola-3.2.3.tgz#0741857aa88cfa0d6fd53f1cff0375136e98502f" integrity sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ== @@ -4785,6 +4931,17 @@ core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== +cosmiconfig@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-6.0.0.tgz#da4fee853c52f6b1e6935f41c1a2fc50bd4a9982" + integrity sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg== + dependencies: + "@types/parse-json" "^4.0.0" + import-fresh "^3.1.0" + parse-json "^5.0.0" + path-type "^4.0.0" + yaml "^1.7.2" + cosmiconfig@^7.0.0: version "7.1.0" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.1.0.tgz#1443b9afa596b670082ea46cbd8f6a62b84635f6" @@ -5720,7 +5877,7 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0, end-of-stream@^1.4.1: dependencies: once "^1.4.0" -enhanced-resolve@^4.1.1, enhanced-resolve@^4.5.0: +enhanced-resolve@^4.0.0, enhanced-resolve@^4.1.1, enhanced-resolve@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.5.0.tgz#2f3cfd84dbe3b487f18f2db2ef1e064a571ca5ec" integrity sha512-Nv9m36S/vxpsI+Hc4/ZGRs0n9mXqSWGGq49zxb/cJfPAQMbUtttJAlNPS4AQzaBdw/pKskw5bMbekT/Y7W/Wlg== @@ -6641,6 +6798,25 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" integrity sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw== +fork-ts-checker-webpack-plugin@6.5.3: + version "6.5.3" + resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-6.5.3.tgz#eda2eff6e22476a2688d10661688c47f611b37f3" + integrity sha512-SbH/l9ikmMWycd5puHJKTkZJKddF4iRLyW3DeZ08HTI7NGyLS38MXd/KGgeWumQO7YNQbW2u/NtPT2YowbPaGQ== + dependencies: + "@babel/code-frame" "^7.8.3" + "@types/json-schema" "^7.0.5" + chalk "^4.1.0" + chokidar "^3.4.2" + cosmiconfig "^6.0.0" + deepmerge "^4.2.2" + fs-extra "^9.0.0" + glob "^7.1.6" + memfs "^3.1.2" + minimatch "^3.0.4" + schema-utils "2.7.0" + semver "^7.3.2" + tapable "^1.0.0" + form-data@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" @@ -6717,7 +6893,7 @@ fs-extra@^8.1.0: jsonfile "^4.0.0" universalify "^0.1.0" -fs-extra@^9.1.0: +fs-extra@^9.0.0, fs-extra@^9.1.0: version "9.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ== @@ -7016,7 +7192,7 @@ glob-to-regexp@^0.4.1: resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== -glob@^7.1.3, glob@^7.1.4, glob@^7.1.7, glob@^7.2.0: +glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.1.7, glob@^7.2.0: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -7590,7 +7766,7 @@ ignore@^5.2.0, ignore@^5.2.4: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== -import-fresh@^3.2.1: +import-fresh@^3.1.0, import-fresh@^3.2.1: version "3.3.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== @@ -9280,7 +9456,7 @@ mem@^4.0.0: mimic-fn "^2.0.0" p-is-promise "^2.0.0" -memfs@^3.4.3: +memfs@^3.1.2, memfs@^3.4.3: version "3.6.0" resolved "https://registry.yarnpkg.com/memfs/-/memfs-3.6.0.tgz#d7a2110f86f79dd950a8b6df6d57bc984aa185f6" integrity sha512-EGowvkkgbMcIChjMTMkESFDbZeSh8xZ7kNSF0hAiAN4Jh6jgHCRS0Ga/+C8y6Au+oqpezRHCfPsmJ2+DwAgiwQ== @@ -9373,7 +9549,7 @@ micromatch@^3.1.10, micromatch@^3.1.4: snapdragon "^0.8.1" to-regex "^3.0.2" -micromatch@^4.0.2, micromatch@^4.0.4: +micromatch@^4.0.0, micromatch@^4.0.2, micromatch@^4.0.4: version "4.0.5" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== @@ -12150,6 +12326,15 @@ saxes@^6.0.0: dependencies: xmlchars "^2.2.0" +schema-utils@2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.0.tgz#17151f76d8eae67fbbf77960c33c676ad9f4efc7" + integrity sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A== + dependencies: + "@types/json-schema" "^7.0.4" + ajv "^6.12.2" + ajv-keywords "^3.4.1" + schema-utils@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-1.0.0.tgz#0b79a93204d7b600d4b2850d1f66c2a34951c770" @@ -13148,7 +13333,7 @@ terser-webpack-plugin@^4.2.3: terser "^5.3.4" webpack-sources "^1.4.3" -terser@^4.1.2, terser@^4.6.3: +terser@^4.1.2, terser@^4.6.13, terser@^4.6.3: version "4.8.1" resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.1.tgz#a00e5634562de2239fd404c649051bf6fc21144f" integrity sha512-4GnLC0x667eJG0ewJTa6z/yXrbLGv80D9Ru6HIpCQmO+Q4PfEtBFi0ObSckqwL6VyQv/7ENJieXHo2ANmdQwgw== @@ -13369,6 +13554,17 @@ ts-jest@^29.1.1: semver "^7.5.3" yargs-parser "^21.0.1" +ts-loader@8.4.0: + version "8.4.0" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.4.0.tgz#e845ea0f38d140bdc3d7d60293ca18d12ff2720f" + integrity sha512-6nFY3IZ2//mrPc+ImY3hNWx1vCHyEhl6V+wLmL4CZcm6g1CqX7UKrkc6y0i4FwcfOhxyMPCfaEvh20f4r9GNpw== + dependencies: + chalk "^4.1.0" + enhanced-resolve "^4.0.0" + loader-utils "^2.0.0" + micromatch "^4.0.0" + semver "^7.3.4" + ts-node@^10.9.2: version "10.9.2" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" @@ -14415,7 +14611,7 @@ yaml-loader@^0.8.0: loader-utils "^2.0.0" yaml "^2.0.0" -yaml@^1.10.0, yaml@^1.10.2: +yaml@^1.10.0, yaml@^1.10.2, yaml@^1.7.2: version "1.10.2" resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== From 8d527429408c10d391ed4446ea56c5426db61dc2 Mon Sep 17 00:00:00 2001 From: Valentyne Stigloher Date: Fri, 19 Jan 2024 15:33:46 +0100 Subject: [PATCH 06/11] (jwt) possible behavioral changes in jwt (suggested by TypeScript) --- server/social.js | 1 + src/helpers.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/server/social.js b/server/social.js index c3c7b9d04..afe23ffd8 100644 --- a/server/social.js +++ b/server/social.js @@ -2,6 +2,7 @@ import jwt from 'jsonwebtoken'; const getAppleClientSecret = () => { const headers = { + alg: 'ES256', kid: process.env.APPLE_KEY_ID, typ: undefined, }; diff --git a/src/helpers.js b/src/helpers.js index c2431880a..515afbebe 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -424,7 +424,7 @@ export const isValidLink = (url) => { export const parseUserJwt = (token) => { try { return jwt.verify(token, process.env.PUBLIC_KEY, { - algorithm: 'RS256', + algorithms: ['RS256'], audience: process.env.ALL_LOCALES_URLS.split(','), issuer: process.env.ALL_LOCALES_URLS.split(','), }); From 2364e2543c52ad7e0608ba0e21ea7774c20940a5 Mon Sep 17 00:00:00 2001 From: Valentyne Stigloher Date: Fri, 19 Jan 2024 15:16:03 +0100 Subject: [PATCH 07/11] (ts) convert locale/locales.ts to TypeScript --- README.md | 6 +- components/Roles.vue | 2 +- locale/locales.js | 28 --------- locale/locales.ts | 59 +++++++++++++++++++ nuxt.config.ts | 2 +- server/calendarBot.js | 2 +- server/cards.js | 2 +- server/index.ts | 2 +- server/routes/admin.js | 4 +- server/routes/home.js | 2 +- server/routes/profile.js | 2 +- server/routes/user.js | 2 +- server/stats.js | 2 +- ...{buildLocaleList.js => buildLocaleList.ts} | 11 ++-- test/locales/data.test.js | 4 +- test/locales/translations.test.js | 4 +- 16 files changed, 83 insertions(+), 51 deletions(-) delete mode 100644 locale/locales.js create mode 100644 locale/locales.ts rename src/{buildLocaleList.js => buildLocaleList.ts} (64%) diff --git a/README.md b/README.md index b2d7182c6..3ac8a1673 100644 --- a/README.md +++ b/README.md @@ -212,14 +212,14 @@ To check for missing translations, you can use the `admin/translations/missing` ### Creating a new language version Read [this](https://en.pronouns.page/new-version) first. \ -When you add a new language, remember to modify the file `./locale/locales.js` to add your language: +When you add a new language, remember to modify the file `./locale/locales.ts` to add your language: ```js // Add an object according to the following format: -{ code: 'xx', name: 'xx', url: 'https://xx.pronouns.page', published: false, symbol: 'x', family: 'xxx' } +new LocaleDescription('xx', 'xx', 'https://xx.pronouns.page', false, 'x', 'xxx'), // Setting 'published' to true means that the language was published onto the main site. // For example: -{ code: 'pt', name: 'Portuguรชs', url: 'https://pt.pronouns.page', published: true, symbol: 'รฃ', family: 'romance' } +new LocaleDescription('pt', 'Portuguรชs', 'https://pt.pronouns.page', true, 'รฃ', 'romance'), ``` ### Current translations being worked on diff --git a/components/Roles.vue b/components/Roles.vue index 86e46cecf..08c4d2d7b 100644 --- a/components/Roles.vue +++ b/components/Roles.vue @@ -24,7 +24,7 @@