Skip to content

Commit 8368650

Browse files
committed
use shared config
1 parent 5e9810f commit 8368650

35 files changed

+2272
-1837
lines changed

.eslintrc.js

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,56 @@
11
module.exports = {
2-
plugins: ["matrix-org"],
3-
extends: ["plugin:matrix-org/babel"],
4-
parserOptions: {
5-
project: ["./tsconfig-dev.json"],
6-
},
7-
env: {
8-
browser: true,
2+
plugins: ["matrix-org"],
3+
extends: [
4+
"plugin:matrix-org/babel",
5+
"plugin:matrix-org/typescript",
6+
"prettier",
7+
],
8+
parserOptions: {
9+
project: ["./tsconfig-dev.json"],
10+
},
11+
env: {
12+
browser: true,
13+
},
14+
rules: {
15+
"no-var": ["warn"],
16+
"prefer-rest-params": ["warn"],
17+
"prefer-spread": ["warn"],
18+
"one-var": ["warn"],
19+
"padded-blocks": ["warn"],
20+
"no-extend-native": ["warn"],
21+
camelcase: ["warn"],
22+
"no-multi-spaces": ["error", { ignoreEOLComments: true }],
23+
"space-before-function-paren": [
24+
"error",
25+
{
26+
anonymous: "never",
27+
named: "never",
28+
asyncArrow: "always",
29+
},
30+
],
31+
"arrow-parens": "off",
32+
"prefer-promise-reject-errors": "off",
33+
quotes: "off",
34+
indent: "off",
35+
"no-constant-condition": "off",
36+
"no-async-promise-executor": "off",
37+
},
38+
overrides: [
39+
{
40+
files: ["src/**/*.ts", "test/**/*.ts"],
41+
extends: ["plugin:matrix-org/typescript"],
42+
rules: {
43+
// TypeScript has its own version of this
44+
"babel/no-invalid-this": "off",
45+
46+
quotes: "off",
47+
},
948
},
10-
rules: {
11-
"no-var": ["warn"],
12-
"prefer-rest-params": ["warn"],
13-
"prefer-spread": ["warn"],
14-
"one-var": ["warn"],
15-
"padded-blocks": ["warn"],
16-
"no-extend-native": ["warn"],
17-
"camelcase": ["warn"],
18-
"no-multi-spaces": ["error", { ignoreEOLComments: true }],
19-
"space-before-function-paren": [
20-
"error",
21-
{
22-
anonymous: "never",
23-
named: "never",
24-
asyncArrow: "always",
25-
},
26-
],
27-
"arrow-parens": "off",
28-
"prefer-promise-reject-errors": "off",
29-
"quotes": "off",
30-
"indent": "off",
31-
"no-constant-condition": "off",
32-
"no-async-promise-executor": "off",
49+
{
50+
files: ["src/interfaces/**/*.ts"],
51+
rules: {
52+
"@typescript-eslint/no-empty-object-type": "off",
53+
},
3354
},
34-
overrides: [
35-
{
36-
files: ["src/**/*.ts", "test/**/*.ts"],
37-
extends: ["plugin:matrix-org/typescript"],
38-
rules: {
39-
// TypeScript has its own version of this
40-
"babel/no-invalid-this": "off",
41-
42-
"quotes": "off",
43-
},
44-
},
45-
{
46-
files: ["src/interfaces/**/*.ts"],
47-
rules: {
48-
"@typescript-eslint/no-empty-object-type": "off",
49-
},
50-
},
51-
],
55+
],
5256
};

.github/workflows/sonarqube.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
name: SonarQube
22
on:
3-
workflow_run:
4-
workflows: ["Build and test"]
5-
types:
6-
- completed
3+
workflow_run:
4+
workflows: ["Build and test"]
5+
types:
6+
- completed
77
concurrency:
8-
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}
9-
cancel-in-progress: true
8+
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}
9+
cancel-in-progress: true
1010
jobs:
11-
sonarqube:
12-
name: 🩻 SonarQube
13-
uses: matrix-org/matrix-js-sdk/.github/workflows/sonarcloud.yml@develop
14-
secrets:
15-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
16-
ELEMENT_BOT_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
11+
sonarqube:
12+
name: 🩻 SonarQube
13+
uses: matrix-org/matrix-js-sdk/.github/workflows/sonarcloud.yml@develop
14+
secrets:
15+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
16+
ELEMENT_BOT_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,22 @@ api.requestCapability(MatrixCapabilities.Screenshots);
4444
api.requestCapabilities(StickerpickerCapabilities);
4545

4646
// Add custom action handlers (if needed)
47-
api.on(`action:${WidgetApiToWidgetAction.UpdateVisibility}`, (ev: CustomEvent<IVisibilityActionRequest>) => {
48-
ev.preventDefault(); // we're handling it, so stop the widget API from doing something.
49-
console.log(ev.detail); // custom handling here
50-
api.transport.reply(ev.detail, <IWidgetApiRequestEmptyData>{});
51-
});
52-
api.on("action:com.example.my_action", (ev: CustomEvent<ICustomActionRequest>) => {
53-
ev.preventDefault(); // we're handling it, so stop the widget API from doing something.
54-
console.log(ev.detail); // custom handling here
55-
api.transport.reply(ev.detail, { custom: "reply" });
56-
});
47+
api.on(
48+
`action:${WidgetApiToWidgetAction.UpdateVisibility}`,
49+
(ev: CustomEvent<IVisibilityActionRequest>) => {
50+
ev.preventDefault(); // we're handling it, so stop the widget API from doing something.
51+
console.log(ev.detail); // custom handling here
52+
api.transport.reply(ev.detail, <IWidgetApiRequestEmptyData>{});
53+
},
54+
);
55+
api.on(
56+
"action:com.example.my_action",
57+
(ev: CustomEvent<ICustomActionRequest>) => {
58+
ev.preventDefault(); // we're handling it, so stop the widget API from doing something.
59+
console.log(ev.detail); // custom handling here
60+
api.transport.reply(ev.detail, { custom: "reply" });
61+
},
62+
);
5763

5864
// Start the messaging
5965
api.start();
@@ -82,7 +88,9 @@ const api = new ClientWidgetApi(widget, iframe, driver);
8288

8389
// The API is automatically started, so we just have to wait for a ready before doing something
8490
api.on("ready", () => {
85-
api.updateVisibility(true).then(() => console.log("Widget knows it is visible now"));
91+
api
92+
.updateVisibility(true)
93+
.then(() => console.log("Widget knows it is visible now"));
8694
api.transport.send("com.example.my_action", { isExample: true });
8795
});
8896

examples/widget/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565

6666
// Set up the widget API as soon as possible to avoid problems with the client
6767
const widgetApi = new mxwidgets.WidgetApi(widgetId, targetOrigin);
68-
widgetApi.requestCapability(mxwidgets.MatrixCapabilities.AlwaysOnScreen);
68+
widgetApi.requestCapability(
69+
mxwidgets.MatrixCapabilities.AlwaysOnScreen,
70+
);
6971

7072
widgetApi.on("ready", function () {
7173
// Fill in the basic widget details now that we're allowed to operate.
@@ -91,7 +93,8 @@
9193
}
9294

9395
function updateStickyState() {
94-
document.getElementById("stickyState").innerText = isSticky.toString();
96+
document.getElementById("stickyState").innerText =
97+
isSticky.toString();
9598
}
9699

97100
function sendStickyState() {

examples/widget/utils.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,21 @@
1515
*/
1616

1717
function parseFragment() {
18-
const fragmentString = window.location.hash || "?";
19-
return new URLSearchParams(fragmentString.substring(Math.max(fragmentString.indexOf("?"), 0)));
18+
const fragmentString = window.location.hash || "?";
19+
return new URLSearchParams(
20+
fragmentString.substring(Math.max(fragmentString.indexOf("?"), 0)),
21+
);
2022
}
2123

2224
function assertParam(fragment, name) {
23-
const val = fragment.get(name);
24-
if (!val) throw new Error(`${name} is not present in URL - cannot load widget`);
25-
return val;
25+
const val = fragment.get(name);
26+
if (!val)
27+
throw new Error(`${name} is not present in URL - cannot load widget`);
28+
return val;
2629
}
2730

2831
function handleError(e) {
29-
console.error(e);
30-
document.getElementById("container").innerText = "There was an error with the widget. See JS console for details.";
32+
console.error(e);
33+
document.getElementById("container").innerText =
34+
"There was an error with the widget. See JS console for details.";
3135
}

package.json

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,6 @@
2323
"lint:workflows": "find .github/workflows -type f \\( -iname '*.yaml' -o -iname '*.yml' \\) | xargs -I {} sh -c 'echo \"Linting {}\"; action-validator \"{}\"'",
2424
"test": "jest"
2525
},
26-
"prettier": {
27-
"printWidth": 120,
28-
"tabWidth": 2,
29-
"quoteProps": "consistent",
30-
"trailingComma": "all",
31-
"overrides": [
32-
{
33-
"files": [
34-
"src/**/*.ts",
35-
"*.js",
36-
"test/**/*.ts",
37-
"*.yml"
38-
],
39-
"options": {
40-
"tabWidth": 4
41-
}
42-
}
43-
]
44-
},
4526
"files": [
4627
"src",
4728
"lib",

0 commit comments

Comments
 (0)