Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prettier config #123

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"sourceMaps": true,
"presets": [
"@babel/preset-env",
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
"presets": ["@babel/preset-env", "@babel/preset-typescript"],
"plugins": ["@babel/plugin-proposal-class-properties"]
}
50 changes: 26 additions & 24 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
module.exports = {
plugins: [
"matrix-org",
],
extends: [
"plugin:matrix-org/babel",
],
plugins: ["matrix-org"],
extends: ["plugin:matrix-org/babel"],
parserOptions: {
project: ["./tsconfig-dev.json"],
},
Expand All @@ -19,32 +15,38 @@ module.exports = {
"padded-blocks": ["warn"],
"no-extend-native": ["warn"],
"camelcase": ["warn"],
"no-multi-spaces": ["error", { "ignoreEOLComments": true }],
"space-before-function-paren": ["error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always",
}],
"no-multi-spaces": ["error", { ignoreEOLComments: true }],
"space-before-function-paren": [
"error",
{
anonymous: "never",
named: "never",
asyncArrow: "always",
},
],
"arrow-parens": "off",
"prefer-promise-reject-errors": "off",
"quotes": "off",
"indent": "off",
"no-constant-condition": "off",
"no-async-promise-executor": "off",
},
overrides: [{
"files": ["src/**/*.ts", "test/**/*.ts"],
"extends": ["plugin:matrix-org/typescript"],
"rules": {
// TypeScript has its own version of this
"babel/no-invalid-this": "off",
overrides: [
{
files: ["src/**/*.ts", "test/**/*.ts"],
extends: ["plugin:matrix-org/typescript"],
rules: {
// TypeScript has its own version of this
"babel/no-invalid-this": "off",

"quotes": "off",
"quotes": "off",
},
},
}, {
"files": ["src/interfaces/**/*.ts"],
"rules": {
"@typescript-eslint/no-empty-object-type": "off",
{
files: ["src/interfaces/**/*.ts"],
rules: {
"@typescript-eslint/no-empty-object-type": "off",
},
},
}],
],
};
69 changes: 36 additions & 33 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
name: Build and test

on:
push:
branches:
- master
pull_request:
push:
branches:
- master
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: 'yarn'

- name: Install NPM packages
run: yarn install --frozen-lockfile

- name: Check Linting Rules and Types
run: yarn lint

- name: test
run: yarn test --coverage

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage
path: |
coverage
!coverage/lcov-report

- name: build
run: yarn build
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: "yarn"

- name: Install NPM packages
run: yarn install --frozen-lockfile

- name: Check Linting Rules and Types
run: yarn lint
toger5 marked this conversation as resolved.
Show resolved Hide resolved

- name: Check Formatting
run: yarn prettier:check

- name: test
run: yarn test --coverage

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage
path: |
coverage
!coverage/lcov-report

- name: build
run: yarn build
96 changes: 48 additions & 48 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
name: Release Automation
on:
workflow_dispatch:
inputs:
version-bump:
description: The scale of the version bump required for semver compatibility
required: true
default: patch
type: choice
options:
- patch
- minor
- major
workflow_dispatch:
inputs:
version-bump:
description: The scale of the version bump required for semver compatibility
required: true
default: patch
type: choice
options:
- patch
- minor
- major
concurrency: release
permissions:
contents: write
contents: write
jobs:
release:
name: "Release & Publish"
runs-on: ubuntu-latest
steps:
- name: 🧮 Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.ELEMENT_BOT_TOKEN }}
release:
name: "Release & Publish"
runs-on: ubuntu-latest
steps:
- name: 🧮 Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.ELEMENT_BOT_TOKEN }}

- name: 🔧 Set up node environment
uses: actions/setup-node@v4
with:
cache: 'yarn'
- name: 🔧 Set up node environment
uses: actions/setup-node@v4
with:
cache: "yarn"

- name: 🛠️ Setup
run: yarn install --pure-lockfile
- name: 🛠️ Setup
run: yarn install --pure-lockfile

- name: 👊 Bump version
run: |
yarn version --no-git-tag-version --${{ github.event.inputs.version-bump }}
git config --global user.name 'ElementRobot'
git config --global user.email '[email protected]'
git commit -am "${{ github.event.inputs.version-bump }} version bump"
git push
- name: 👊 Bump version
run: |
yarn version --no-git-tag-version --${{ github.event.inputs.version-bump }}
git config --global user.name 'ElementRobot'
git config --global user.email '[email protected]'
git commit -am "${{ github.event.inputs.version-bump }} version bump"
git push

- name: 📖 Build lib
run: yarn build
- name: 📖 Build lib
run: yarn build

- name: 🚀 Publish to npm
id: npm-publish
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
- name: 🚀 Publish to npm
id: npm-publish
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
access: public

- name: 🧬 Create release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.npm-publish.outputs.version }}
body: ${{ steps.npm-publish.outputs.version }} Release
draft: false
prerelease: false
- name: 🧬 Create release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.npm-publish.outputs.version }}
body: ${{ steps.npm-publish.outputs.version }} Release
draft: false
prerelease: false
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("eslint-plugin-matrix-org/.prettierrc.js");
3 changes: 3 additions & 0 deletions .vscode/settings.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize Element Call has a VSCode settings file too, but I'm not a fan of putting IDE config files in version control, as they can clash with personal development preferences.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(To be clear, the request is to remove this file 🙂)

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": false
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ JavaScript/TypeScript SDK for widgets & clients to communicate.

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

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

## Building

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

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

// Later, do something else (if needed)
api.setAlwaysOnScreen(true);
api.transport.send("com.example.my_action", {isExample: true});
api.transport.send("com.example.my_action", { isExample: true });
```

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

// Eventually, stop the API handling
Expand Down
5 changes: 3 additions & 2 deletions examples/widget/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* limitations under the License.
*/

html, body {
html,
body {
background-color: #ffffff;
color: #000000;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
Expand Down
Loading
Loading