Apply Prettier to the entire project

This ensures that our tests will be formatted by Prettier, among other things.
This commit is contained in:
Robin Townsend 2022-12-09 14:34:25 -05:00
parent e6e18dd3f9
commit 90ef5505bb
12 changed files with 72 additions and 80 deletions

View File

@ -1,42 +1,34 @@
module.exports = { module.exports = {
plugins: [ plugins: ["matrix-org"],
"matrix-org", extends: ["plugin:matrix-org/react", "plugin:matrix-org/a11y", "prettier"],
], env: {
extends: [ 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/react",
"plugin:matrix-org/a11y",
"prettier", "prettier",
], ],
env: { rules: {
browser: true, // We're aiming to convert this code to strict mode
node: true, "@typescript-eslint/no-non-null-assertion": "off",
},
}, },
parserOptions: { ],
"ecmaVersion": "latest", settings: {
"sourceType": "module", react: {
}, version: "detect",
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",
},
}, },
},
}; };

View File

@ -42,7 +42,7 @@ body:
id: browser id: browser
attributes: attributes:
label: Browser information 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 placeholder: e.g. Chromium Version 92.0.4515.131
validations: validations:
required: false required: false
@ -58,10 +58,10 @@ body:
id: rageshake id: rageshake
attributes: attributes:
label: Will you send logs? 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. To send them, press the 'Submit Feedback' button and check 'Include Debug Logs'. Please link to this issue in the description field.
options: options:
- 'Yes' - "Yes"
- 'No' - "No"
validations: validations:
required: true required: true

View File

@ -11,7 +11,7 @@ jobs:
- name: Yarn cache - name: Yarn cache
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
cache: 'yarn' cache: "yarn"
- name: Install dependencies - name: Install dependencies
run: "yarn install" run: "yarn install"
- name: Prettier - name: Prettier

View File

@ -21,7 +21,7 @@ jobs:
env: main-branch-cd env: main-branch-cd
ref: ${{ github.event.workflow_run.head_sha }} ref: ${{ github.event.workflow_run.head_sha }}
- name: 'Download artifact' - name: "Download artifact"
uses: actions/github-script@v3.1.0 uses: actions/github-script@v3.1.0
with: with:
script: | script: |

View File

@ -2,7 +2,7 @@ name: Move new issues into triage board
on: on:
issues: issues:
types: [ opened ] types: [opened]
jobs: jobs:
add-to-project: add-to-project:
@ -13,13 +13,13 @@ jobs:
with: with:
headers: '{"GraphQL-Features": "projects_next_graphql"}' headers: '{"GraphQL-Features": "projects_next_graphql"}'
query: | query: |
mutation add_to_project($projectid:ID!,$contentid:ID!) { mutation add_to_project($projectid:ID!,$contentid:ID!) {
addProjectV2ItemById(input: {projectId: $projectid contentId: $contentid}) { addProjectV2ItemById(input: {projectId: $projectid contentId: $contentid}) {
item { item {
id id
}
} }
} }
}
projectid: ${{ env.PROJECT_ID }} projectid: ${{ env.PROJECT_ID }}
contentid: ${{ github.event.issue.node_id }} contentid: ${{ github.event.issue.node_id }}
env: env:

View File

@ -5,18 +5,18 @@
"editor.tabSize": 2, "editor.tabSize": 2,
"[typescriptreact]": { "[typescriptreact]": {
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode"
}, },
"[javascriptreact]": { "[javascriptreact]": {
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode"
}, },
"[typescript]": { "[typescript]": {
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode"
}, },
"[javascript]": { "[javascript]": {
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode"
} }
} }

View File

@ -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). Element follows the same pattern as the [matrix-js-sdk](https://github.com/matrix-org/matrix-js-sdk/blob/develop/CONTRIBUTING.md).

View File

@ -6,11 +6,13 @@ export default {
createOldCatalogs: false, createOldCatalogs: false,
defaultNamespace: "app", defaultNamespace: "app",
lexers: { lexers: {
ts: [{ ts: [
lexer: "JavascriptLexer", {
functions: ["t", "translatedError"], lexer: "JavascriptLexer",
functionsNamespace: ["useTranslation", "withTranslation"], functions: ["t", "translatedError"],
}], functionsNamespace: ["useTranslation", "withTranslation"],
},
],
}, },
locales: ["en-GB"], locales: ["en-GB"],
output: "public/locales/$LOCALE/$NAMESPACE.json", output: "public/locales/$LOCALE/$NAMESPACE.json",

View File

@ -7,8 +7,8 @@
"serve": "vite preview", "serve": "vite preview",
"storybook": "start-storybook -p 6006", "storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook", "build-storybook": "build-storybook",
"prettier:check": "prettier -c src", "prettier:check": "prettier -c .",
"prettier:format": "prettier -w src", "prettier:format": "prettier -w .",
"lint": "yarn lint:types && yarn lint:js", "lint": "yarn lint:types && yarn lint:js",
"lint:js": "eslint --max-warnings 0 src", "lint:js": "eslint --max-warnings 0 src",
"lint:types": "tsc", "lint:types": "tsc",

View File

@ -1,20 +1,19 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.png" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0"
/>
<title><%- title %></title>
<script>
window.global = window;
</script>
</head>
<head> <body>
<meta charset="UTF-8" /> <div id="root"></div>
<link rel="icon" type="image/svg+xml" href="favicon.png" /> </body>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> </html>
<title>
<%- title %>
</title>
<script>
window.global = window;
</script>
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@ -1 +1 @@
module.exports = { loadOlm: jest.fn(async () => {}) } module.exports = { loadOlm: jest.fn(async () => {}) };

View File

@ -18,7 +18,7 @@
] ]
}, },
"include": [ "include": [
"./src/**/*.ts", "./src/**/*.ts",
"./src/**/*.tsx", "./src/**/*.tsx",
"./test/**/*.ts", "./test/**/*.ts",
"./test/**/*.tsx" "./test/**/*.tsx"