Skip to content

Commit ad0cb68

Browse files
toger5hughns
andauthored
Add prettier config (#123)
Co-authored-by: Hugh Nimmo-Smith <[email protected]>
1 parent 70326db commit ad0cb68

36 files changed

+1842
-2015
lines changed

Diff for: .babelrc

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
{
22
"sourceMaps": true,
3-
"presets": [
4-
"@babel/preset-env",
5-
"@babel/preset-typescript"
6-
],
7-
"plugins": [
8-
"@babel/plugin-proposal-class-properties"
9-
]
3+
"presets": ["@babel/preset-env", "@babel/preset-typescript"],
4+
"plugins": ["@babel/plugin-proposal-class-properties"]
105
}

Diff for: .eslintrc.js

+26-24
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
module.exports = {
2-
plugins: [
3-
"matrix-org",
4-
],
5-
extends: [
6-
"plugin:matrix-org/babel",
7-
],
2+
plugins: ["matrix-org"],
3+
extends: ["plugin:matrix-org/babel"],
84
parserOptions: {
95
project: ["./tsconfig-dev.json"],
106
},
@@ -19,32 +15,38 @@ module.exports = {
1915
"padded-blocks": ["warn"],
2016
"no-extend-native": ["warn"],
2117
"camelcase": ["warn"],
22-
"no-multi-spaces": ["error", { "ignoreEOLComments": true }],
23-
"space-before-function-paren": ["error", {
24-
"anonymous": "never",
25-
"named": "never",
26-
"asyncArrow": "always",
27-
}],
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+
],
2827
"arrow-parens": "off",
2928
"prefer-promise-reject-errors": "off",
3029
"quotes": "off",
3130
"indent": "off",
3231
"no-constant-condition": "off",
3332
"no-async-promise-executor": "off",
3433
},
35-
overrides: [{
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",
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",
4141

42-
"quotes": "off",
42+
"quotes": "off",
43+
},
4344
},
44-
}, {
45-
"files": ["src/interfaces/**/*.ts"],
46-
"rules": {
47-
"@typescript-eslint/no-empty-object-type": "off",
45+
{
46+
files: ["src/interfaces/**/*.ts"],
47+
rules: {
48+
"@typescript-eslint/no-empty-object-type": "off",
49+
},
4850
},
49-
}],
51+
],
5052
};

Diff for: .github/workflows/build.yaml

+36-33
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
11
name: Build and test
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
88

99
jobs:
10-
build:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v4
14-
15-
- name: Setup Node.js
16-
uses: actions/setup-node@v4
17-
with:
18-
cache: 'yarn'
19-
20-
- name: Install NPM packages
21-
run: yarn install --frozen-lockfile
22-
23-
- name: Check Linting Rules and Types
24-
run: yarn lint
25-
26-
- name: test
27-
run: yarn test --coverage
28-
29-
- name: Upload coverage
30-
uses: actions/upload-artifact@v4
31-
with:
32-
name: coverage
33-
path: |
34-
coverage
35-
!coverage/lcov-report
36-
37-
- name: build
38-
run: yarn build
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
cache: "yarn"
19+
20+
- name: Install NPM packages
21+
run: yarn install --frozen-lockfile
22+
23+
- name: Check Linting Rules and Types
24+
run: yarn lint
25+
26+
- name: Check Formatting
27+
run: yarn prettier:check
28+
29+
- name: test
30+
run: yarn test --coverage
31+
32+
- name: Upload coverage
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: coverage
36+
path: |
37+
coverage
38+
!coverage/lcov-report
39+
40+
- name: build
41+
run: yarn build

Diff for: .github/workflows/release.yaml

+48-48
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
name: Release Automation
22
on:
3-
workflow_dispatch:
4-
inputs:
5-
version-bump:
6-
description: The scale of the version bump required for semver compatibility
7-
required: true
8-
default: patch
9-
type: choice
10-
options:
11-
- patch
12-
- minor
13-
- major
3+
workflow_dispatch:
4+
inputs:
5+
version-bump:
6+
description: The scale of the version bump required for semver compatibility
7+
required: true
8+
default: patch
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
1414
concurrency: release
1515
permissions:
16-
contents: write
16+
contents: write
1717
jobs:
18-
release:
19-
name: "Release & Publish"
20-
runs-on: ubuntu-latest
21-
steps:
22-
- name: 🧮 Checkout code
23-
uses: actions/checkout@v4
24-
with:
25-
token: ${{ secrets.ELEMENT_BOT_TOKEN }}
18+
release:
19+
name: "Release & Publish"
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: 🧮 Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
token: ${{ secrets.ELEMENT_BOT_TOKEN }}
2626

27-
- name: 🔧 Set up node environment
28-
uses: actions/setup-node@v4
29-
with:
30-
cache: 'yarn'
27+
- name: 🔧 Set up node environment
28+
uses: actions/setup-node@v4
29+
with:
30+
cache: "yarn"
3131

32-
- name: 🛠️ Setup
33-
run: yarn install --pure-lockfile
32+
- name: 🛠️ Setup
33+
run: yarn install --pure-lockfile
3434

35-
- name: 👊 Bump version
36-
run: |
37-
yarn version --no-git-tag-version --${{ github.event.inputs.version-bump }}
38-
git config --global user.name 'ElementRobot'
39-
git config --global user.email '[email protected]'
40-
git commit -am "${{ github.event.inputs.version-bump }} version bump"
41-
git push
35+
- name: 👊 Bump version
36+
run: |
37+
yarn version --no-git-tag-version --${{ github.event.inputs.version-bump }}
38+
git config --global user.name 'ElementRobot'
39+
git config --global user.email '[email protected]'
40+
git commit -am "${{ github.event.inputs.version-bump }} version bump"
41+
git push
4242
43-
- name: 📖 Build lib
44-
run: yarn build
43+
- name: 📖 Build lib
44+
run: yarn build
4545

46-
- name: 🚀 Publish to npm
47-
id: npm-publish
48-
uses: JS-DevTools/npm-publish@v3
49-
with:
50-
token: ${{ secrets.NPM_TOKEN }}
51-
access: public
46+
- name: 🚀 Publish to npm
47+
id: npm-publish
48+
uses: JS-DevTools/npm-publish@v3
49+
with:
50+
token: ${{ secrets.NPM_TOKEN }}
51+
access: public
5252

53-
- name: 🧬 Create release
54-
uses: softprops/action-gh-release@v2
55-
with:
56-
tag_name: v${{ steps.npm-publish.outputs.version }}
57-
body: ${{ steps.npm-publish.outputs.version }} Release
58-
draft: false
59-
prerelease: false
53+
- name: 🧬 Create release
54+
uses: softprops/action-gh-release@v2
55+
with:
56+
tag_name: v${{ steps.npm-publish.outputs.version }}
57+
body: ${{ steps.npm-publish.outputs.version }} Release
58+
draft: false
59+
prerelease: false

Diff for: .prettierrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("eslint-plugin-matrix-org/.prettierrc.js");

Diff for: README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ JavaScript/TypeScript SDK for widgets & clients to communicate.
66

77
For help and support, visit [#matrix-widgets:matrix.org](https://matrix.to/#/#matrix-widgets:matrix.org) on Matrix.
88

9-
*Disclaimer: Widgets are not yet in the Matrix spec, so this library may not work with other implementations.*
9+
_Disclaimer: Widgets are not yet in the Matrix spec, so this library may not work with other implementations._
1010

1111
## Building
1212

@@ -52,7 +52,7 @@ api.on(`action:${WidgetApiToWidgetAction.UpdateVisibility}`, (ev: CustomEvent<IV
5252
api.on("action:com.example.my_action", (ev: CustomEvent<ICustomActionRequest>) => {
5353
ev.preventDefault(); // we're handling it, so stop the widget API from doing something.
5454
console.log(ev.detail); // custom handling here
55-
api.transport.reply(ev.detail, {custom: "reply"});
55+
api.transport.reply(ev.detail, { custom: "reply" });
5656
});
5757

5858
// Start the messaging
@@ -63,7 +63,7 @@ api.sendContentLoaded();
6363

6464
// Later, do something else (if needed)
6565
api.setAlwaysOnScreen(true);
66-
api.transport.send("com.example.my_action", {isExample: true});
66+
api.transport.send("com.example.my_action", { isExample: true });
6767
```
6868

6969
For a more complete example, see the `examples` directory of this repo.
@@ -83,7 +83,7 @@ const api = new ClientWidgetApi(widget, iframe, driver);
8383
// The API is automatically started, so we just have to wait for a ready before doing something
8484
api.on("ready", () => {
8585
api.updateVisibility(true).then(() => console.log("Widget knows it is visible now"));
86-
api.transport.send("com.example.my_action", {isExample: true});
86+
api.transport.send("com.example.my_action", { isExample: true });
8787
});
8888

8989
// Eventually, stop the API handling

Diff for: examples/widget/index.css

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
html, body {
17+
html,
18+
body {
1819
background-color: #ffffff;
1920
color: #000000;
20-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
21+
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
2122
}
2223

2324
body {

0 commit comments

Comments
 (0)