From 90ef5505bb28af271f9f1832a2b902a19b90c398 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Fri, 9 Dec 2022 14:34:25 -0500 Subject: [PATCH] Apply Prettier to the entire project This ensures that our tests will be formatted by Prettier, among other things. --- .eslintrc.cjs | 64 +++++++++++--------------- .github/ISSUE_TEMPLATE/bug.yml | 8 ++-- .github/workflows/lint.yaml | 2 +- .github/workflows/netlify-main.yaml | 2 +- .github/workflows/triage-incoming.yaml | 12 ++--- .vscode/settings.json | 8 ++-- CONTRIBUTING.md | 3 +- i18next-parser.config.js | 12 +++-- package.json | 4 +- public/index.html | 33 +++++++------ test/mocks/olmMock.ts | 2 +- tsconfig.json | 2 +- 12 files changed, 72 insertions(+), 80 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index cb2ead0..f410710 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,42 +1,34 @@ module.exports = { - plugins: [ - "matrix-org", - ], - extends: [ + plugins: ["matrix-org"], + extends: ["plugin:matrix-org/react", "plugin:matrix-org/a11y", "prettier"], + env: { + browser: true, + node: true, + }, + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + }, + rules: { + "jsx-a11y/media-has-caption": ["off"], + }, + overrides: [ + { + files: ["src/**/*.{ts,tsx}"], + extends: [ + "plugin:matrix-org/typescript", "plugin:matrix-org/react", - "plugin:matrix-org/a11y", "prettier", - ], - env: { - browser: true, - node: true, + ], + rules: { + // We're aiming to convert this code to strict mode + "@typescript-eslint/no-non-null-assertion": "off", + }, }, - parserOptions: { - "ecmaVersion": "latest", - "sourceType": "module", - }, - rules: { - "jsx-a11y/media-has-caption": ["off"], - }, - overrides: [ - { - files: [ - "src/**/*.{ts,tsx}", - ], - extends: [ - "plugin:matrix-org/typescript", - "plugin:matrix-org/react", - "prettier", - ], - rules: { - // We're aiming to convert this code to strict mode - "@typescript-eslint/no-non-null-assertion": "off", - }, - }, - ], - settings: { - react: { - version: "detect", - }, + ], + settings: { + react: { + version: "detect", }, + }, }; diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 490f356..10def3a 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -42,7 +42,7 @@ body: id: browser attributes: label: Browser information - description: Which browser are you using? Which version? + description: Which browser are you using? Which version? placeholder: e.g. Chromium Version 92.0.4515.131 validations: required: false @@ -58,10 +58,10 @@ body: id: rageshake attributes: label: Will you send logs? - description: | + description: | To send them, press the 'Submit Feedback' button and check 'Include Debug Logs'. Please link to this issue in the description field. options: - - 'Yes' - - 'No' + - "Yes" + - "No" validations: required: true diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 2241165..a929863 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -11,7 +11,7 @@ jobs: - name: Yarn cache uses: actions/setup-node@v3 with: - cache: 'yarn' + cache: "yarn" - name: Install dependencies run: "yarn install" - name: Prettier diff --git a/.github/workflows/netlify-main.yaml b/.github/workflows/netlify-main.yaml index a272a00..f281a04 100644 --- a/.github/workflows/netlify-main.yaml +++ b/.github/workflows/netlify-main.yaml @@ -21,7 +21,7 @@ jobs: env: main-branch-cd ref: ${{ github.event.workflow_run.head_sha }} - - name: 'Download artifact' + - name: "Download artifact" uses: actions/github-script@v3.1.0 with: script: | diff --git a/.github/workflows/triage-incoming.yaml b/.github/workflows/triage-incoming.yaml index 50419c6..3e1d665 100644 --- a/.github/workflows/triage-incoming.yaml +++ b/.github/workflows/triage-incoming.yaml @@ -2,7 +2,7 @@ name: Move new issues into triage board on: issues: - types: [ opened ] + types: [opened] jobs: add-to-project: @@ -13,13 +13,13 @@ jobs: with: headers: '{"GraphQL-Features": "projects_next_graphql"}' query: | - mutation add_to_project($projectid:ID!,$contentid:ID!) { - addProjectV2ItemById(input: {projectId: $projectid contentId: $contentid}) { - item { - id - } + mutation add_to_project($projectid:ID!,$contentid:ID!) { + addProjectV2ItemById(input: {projectId: $projectid contentId: $contentid}) { + item { + id } } + } projectid: ${{ env.PROJECT_ID }} contentid: ${{ github.event.issue.node_id }} env: diff --git a/.vscode/settings.json b/.vscode/settings.json index fe488f6..7fa064e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,18 +5,18 @@ "editor.tabSize": 2, "[typescriptreact]": { "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[javascriptreact]": { "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[typescript]": { "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[javascript]": { "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.defaultFormatter": "esbenp.prettier-vscode" } } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e14c75d..0a4a6ac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,3 @@ -Contributing code to Element -============================ +# Contributing code to Element Element follows the same pattern as the [matrix-js-sdk](https://github.com/matrix-org/matrix-js-sdk/blob/develop/CONTRIBUTING.md). diff --git a/i18next-parser.config.js b/i18next-parser.config.js index b2d5842..a12797e 100644 --- a/i18next-parser.config.js +++ b/i18next-parser.config.js @@ -6,11 +6,13 @@ export default { createOldCatalogs: false, defaultNamespace: "app", lexers: { - ts: [{ - lexer: "JavascriptLexer", - functions: ["t", "translatedError"], - functionsNamespace: ["useTranslation", "withTranslation"], - }], + ts: [ + { + lexer: "JavascriptLexer", + functions: ["t", "translatedError"], + functionsNamespace: ["useTranslation", "withTranslation"], + }, + ], }, locales: ["en-GB"], output: "public/locales/$LOCALE/$NAMESPACE.json", diff --git a/package.json b/package.json index 185d23c..90e02c3 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "serve": "vite preview", "storybook": "start-storybook -p 6006", "build-storybook": "build-storybook", - "prettier:check": "prettier -c src", - "prettier:format": "prettier -w src", + "prettier:check": "prettier -c .", + "prettier:format": "prettier -w .", "lint": "yarn lint:types && yarn lint:js", "lint:js": "eslint --max-warnings 0 src", "lint:types": "tsc", diff --git a/public/index.html b/public/index.html index c6ddea7..3f58206 100644 --- a/public/index.html +++ b/public/index.html @@ -1,20 +1,19 @@ + + + + + <%- title %> + + - - - - - - <%- title %> - - - - - -
- - - \ No newline at end of file + +
+ + diff --git a/test/mocks/olmMock.ts b/test/mocks/olmMock.ts index 8bc7429..2c18fde 100644 --- a/test/mocks/olmMock.ts +++ b/test/mocks/olmMock.ts @@ -1 +1 @@ -module.exports = { loadOlm: jest.fn(async () => {}) } +module.exports = { loadOlm: jest.fn(async () => {}) }; diff --git a/tsconfig.json b/tsconfig.json index e517276..47d1bdb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,7 @@ ] }, "include": [ - "./src/**/*.ts", + "./src/**/*.ts", "./src/**/*.tsx", "./test/**/*.ts", "./test/**/*.tsx"