Builtin conversejs: using typescript.

This commit is contained in:
John Livingston 2021-05-03 18:30:02 +02:00
parent 5575628e99
commit a74954a0cb
4 changed files with 80 additions and 22 deletions

View File

@ -1,23 +1,40 @@
{
"root": true,
"env": {
"browser": true,
"es6": true
},
"extends": [
"standard"
"root": true,
"env": {
"browser": true,
"es6": true
},
"extends": [
"standard-with-typescript"
],
"globals": {},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"project": [
"./conversejs/tsconfig.json"
]
},
"plugins": [
"@typescript-eslint"
],
"ignorePatterns": [],
"rules": {
"@typescript-eslint/no-unused-vars": [2, {"argsIgnorePattern": "^_"}],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/return-await": [2, "in-try-catch"], // FIXME: correct?
"@typescript-eslint/no-invalid-void-type": "off",
"@typescript-eslint/triple-slash-reference": "off",
"max-len": [
"error",
{
"code": 120,
"comments": 120
}
],
"globals": {},
"plugins": [],
"ignorePatterns": [],
"rules": {
"max-len": [
"error",
{
"code": 120,
"comments": 120
}
],
"no-unused-vars": [2, {"argsIgnorePattern": "^_"}]
}
"no-unused-vars": "off"
}
}

View File

@ -1,4 +1,12 @@
function inIframe () {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Window {
converse: {
initialize: (args: any) => void
}
initConverse: (args: any) => void
}
function inIframe (): boolean {
try {
return window.self !== window.top
} catch (e) {

25
conversejs/tsconfig.json Normal file
View File

@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "es6",
"target": "es5",
"allowJs": true,
"sourceMap": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"alwaysStrict": true, // should already be true because of strict:true
"noImplicitAny": true, // should already be true because of strict:true
"noImplicitThis": true, // should already be true because of strict:true
"noImplicitReturns": true,
"strictBindCallApply": true, // should already be true because of strict:true
"noUnusedLocals": true,
"outDir": "../dist/client",
"paths": {
"shared/*": ["../shared/*"]
}
},
"include": [
"./**/*",
"../shared/**/*"
],
"exclude": []
}

View File

@ -42,8 +42,16 @@ let config = clientFiles.map(f => ({
}))
config.push({
entry: "./conversejs/builtin.js",
entry: "./conversejs/builtin.ts",
devtool: process.env.NODE_ENV === 'dev' ? 'eval-source-map' : false,
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader'
}
]
},
output: {
path: path.resolve(__dirname, "./dist/client/static"),
filename: "./builtin.js"