diff --git a/.eslintrc.js b/.eslintrc.js index 0536a49192e..94a8f704e72 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -48,7 +48,7 @@ module.exports = { }, }, { - files: ['@xen-orchestra/{web-core,lite,web}/**/*.{vue,ts}'], + files: ['@vates/**/*.{ts}', '@xen-orchestra/{web-core,lite,web}/**/*.{vue,ts}'], parser: 'vue-eslint-parser', parserOptions: { sourceType: 'module', @@ -79,6 +79,10 @@ module.exports = { XO_LITE_GIT_HEAD: true, }, rules: { + // allow "use strict" + strict: 'off', + // allow "require" + '@typescript-eslint/no-var-requires': 'off', 'import/order': [ 'error', { diff --git a/@vates/parse-duration/package.json b/@vates/parse-duration/package.json index ebe0062a769..1d1d3ce5103 100644 --- a/@vates/parse-duration/package.json +++ b/@vates/parse-duration/package.json @@ -27,6 +27,9 @@ "ms": "^2.1.2" }, "scripts": { - "postversion": "npm publish --access public" - } + "postversion": "npm publish --access public", + "build": "tsc", + "dev": "tsc --watch" + }, + "main": "dist/index.js" } diff --git a/@vates/parse-duration/index.js b/@vates/parse-duration/src/index.ts similarity index 67% rename from @vates/parse-duration/index.js rename to @vates/parse-duration/src/index.ts index 66783a9def9..8233c125ce4 100644 --- a/@vates/parse-duration/index.js +++ b/@vates/parse-duration/src/index.ts @@ -2,11 +2,11 @@ const ms = require('ms') -exports.parseDuration = value => { +exports.parseDuration = (value: number | string): number => { if (typeof value === 'number') { return value } - const duration = ms(value) + const duration: number = ms(value) if (duration === undefined) { throw new TypeError(`not a valid duration: ${value}`) } diff --git a/@vates/parse-duration/tsconfig.json b/@vates/parse-duration/tsconfig.json new file mode 100644 index 00000000000..44a364a09af --- /dev/null +++ b/@vates/parse-duration/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "module": "commonjs", + "moduleResolution": "node", + "newLine": "lf", + "noImplicitAny": true, + "strict": false, + "skipLibCheck": true, + "baseUrl": ".", + "sourceMap": false, + "strictNullChecks": true, + "target": "ES2015", + "outDir": "./dist", + "rootDir": "./src" + }, + "exclude": ["node_modules", "dist"] +} diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 28f167ebf88..d806600e578 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -40,6 +40,7 @@ +- @vates/parse-duration minor - @xen-orchestra/lite minor - @xen-orchestra/web minor - @xen-orchestra/web-core minor