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

Latest App UI Kit version, monthly dependency updates and improvement to i18n linting rules and extraction scripts #43

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
# Changelog

## 2024-11-13

### 🧰 Added

- Added tests for the `TableWrapper` sdk, `utils/tests/table_wrapper.tests.ts`.
- `eslint`

- Added arguments to formatjs eslint rules to require string literals for defaultMessage and description.
Having variables for defaultMessage and description should not be used because it means formatjs can't generate message ids, and can't extract messages.

```jsx
// ❌ Not recommended, messages cannot be extracted, and cannot have ids auto-generated.
<FormattedMessage defaultMessage={myMessage} .../>
// ~~~~~~~~~~~
// error: "defaultMessage" must be:
// - a string literal or
// - template literal without variable eslintformatjs/enforce-default-message

// βœ… Recommended, messages can be extracted, and have ids auto-generated.
<FormattedMessage defaultMessage="My static message" description="My static description"/>
```

NOTE: If your `FormattedMessage` text should change based on the value of some data,
see [this docs section for an example](https://www.canva.dev/docs/apps/localization/#preferred-frontend-localization).

### 🐞 Fixed

- Update `package.json` extract script to use a better file path pattern (`\"src/**/*.{ts,tsx}\"`). The previous path pattern (`src/**/*.{ts,tsx}`) would miss some files.

### πŸ”§ Changed

- Dependencies audit bringing modules up to date:

```text
@canva/design 2.1.0 β†’ 2.2.1
@eslint/js 9.12.0 β†’ 9.14.0
@formatjs/cli 6.2.12 β†’ 6.3.8
@formatjs/ts-transformer 3.13.14 β†’ 3.13.22
@types/jest 29.5.13 β†’ 29.5.14
@types/react 18.3.11 β†’ 18.3.12
@typescript-eslint/eslint-plugin 8.9.0 β†’ 8.13.0
@typescript-eslint/parser 8.9.0 β†’ 8.13.0
eslint 9.12.0 β†’ 9.14.0
eslint-plugin-formatjs 5.0.0 β†’ 5.2.2
eslint-plugin-jest 28.8.3 β†’ 28.9.0
eslint-plugin-react 7.37.1 β†’ 7.37.2
globals 15.11.0 β†’ 15.12.0
mini-css-extract-plugin 2.9.1 β†’ 2.9.2
ts-jest 29.2.4 β†’ 29.2.5
webpack 5.95.0 β†’ 5.96.1
```

- `@canva/app-ui-kit`
- Upgraded `app-ui-kit` to version `4.3.0`. Please see the [changelog](https://www.canva.dev/docs/apps/app-ui-kit/changelog/) for the list of changes.
- Updated snapshots in `examples/ui_test`.

## 2024-10-30

### πŸ”§ Changed
Expand Down
4 changes: 2 additions & 2 deletions conf/eslint-i18n.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default [
},
},
],
"formatjs/enforce-description": "error",
"formatjs/enforce-default-message": "error",
"formatjs/enforce-description": ["error", "literal"],
"formatjs/enforce-default-message": ["error", "literal"],
"formatjs/enforce-placeholders": "error",
"formatjs/no-id": "error",
"formatjs/no-emoji": "error",
Expand Down
2 changes: 1 addition & 1 deletion examples/design_editing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"author": "Canva Pty Ltd.",
"license": "Please refer to the LICENSE.md file in the root directory",
"dependencies": {
"@canva/design": "^2.2.0-beta.1"
"@canva/design": "^2.2.1-beta.1"
}
}
2 changes: 1 addition & 1 deletion examples/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "Canva Pty Ltd.",
"license": "Please refer to the LICENSE.md file in the root directory",
"scripts": {
"extract": "formatjs extract **/*.{ts,tsx} --out-file dist/messages_en.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'",
"extract": "formatjs extract \"**/*.{ts,tsx}\" --out-file dist/messages_en.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'",
"test": "jest --no-cache --config='../../jest.config.js'",
"test:watch": "jest --no-cache --watch --config='../../jest.config.js'",
"test:update": "npm run test -- -u"
Expand Down
2 changes: 1 addition & 1 deletion examples/text_query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"author": "Canva Pty Ltd.",
"license": "Please refer to the LICENSE.md file in the root directory",
"dependencies": {
"@canva/design": "^2.2.0-beta.1"
"@canva/design": "^2.2.1-beta.1"
}
}
4 changes: 2 additions & 2 deletions examples/ui_test/tests/__snapshots__/app.tests.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ exports[`app Renders πŸŽ‰ 1`] = `
class="scrollContainer"
>
<div
class="x6XCCg"
style="--69qs7g: 16px;"
class="jv_R6g"
style="--NZu1Zw: 16px;"
>
<p
class="fFOiLQ _5Ob_nQ fM_HdA"
Expand Down
Loading
Loading