Skip to content

Commit

Permalink
chore: add lint-staged with husky pre-commit hook (solidcouch#144)
Browse files Browse the repository at this point in the history
- extract and compile strings for localization
- run prettier, eslint, knip
  • Loading branch information
mrkvon authored Feb 26, 2025
1 parent e5fef59 commit 2a74e6a
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 46 deletions.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint-staged
10 changes: 10 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// eslint-disable-next-line import/no-default-export
export default {
'*': [
() => 'yarn i18n:extract',
() => 'yarn i18n:compile',
'prettier --write --ignore-unknown',
() => 'knip',
],
'*.{js,jsx,ts,tsx}': 'eslint --max-warnings 0 --no-warn-ignored',
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Implement i18n with [lingui](https://lingui.dev).
- Localize wikidata interests.
- Add popover to interests.
- Add lint-staged with husky pre-commit hook.

### Changed

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"cy:dev:app": "VITE_COMMUNITY=http://localhost:4000/test-community/community#us VITE_EMAIL_NOTIFICATIONS_SERVICE=http://localhost:3005 VITE_ENABLE_DEV_CLIENT_ID=true VITE_EMAIL_NOTIFICATIONS_IDENTITY=http://localhost:4000/mailbot/profile/card#me VITE_EMAIL_NOTIFICATIONS_TYPE=simple VITE_GEOINDEX= yarn build --watch",
"cy:dev:css": "community-solid-server -p 4000 -c ./cypress/css-config-no-log.json",
"cy:dev:open": "cypress open",
"knip": "knip"
"knip": "knip",
"prepare": "husky"
},
"browserslist": {
"production": [
Expand Down Expand Up @@ -120,7 +121,9 @@
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.16",
"globals": "^15.14.0",
"husky": "^9.1.7",
"knip": "^5.41.1",
"lint-staged": "^15.4.3",
"prettier": "^3.4.2",
"sass-embedded": "^1.83.0",
"typescript": "^5.7.2",
Expand Down
10 changes: 4 additions & 6 deletions src/components/Header/MainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const MainMenu = () => {

const theme = useAppSelector(selectTheme)

const messageCount = newMessages.length

return (
<Menu
menuButton={
Expand All @@ -40,14 +42,10 @@ export const MainMenu = () => {
<MenuItem>
<Link to="messages">
<Trans>messages</Trans>
{newMessages?.length ? (
{messageCount ? (
<>
{' '}
<Plural
value={newMessages.length}
one="(# new)"
other="(# new)"
/>
<Plural value={messageCount} one="(# new)" other="(# new)" />
</>
) : null}
</Link>
Expand Down
27 changes: 13 additions & 14 deletions src/locales/cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ msgstr ""
"Language-Team: \n"
"Plural-Forms: \n"

#. placeholder {0}: newMessages.length
#: src/pages/Home.tsx:26
#: src/components/Header/MainMenu.tsx:46
msgid "{0, plural, one {(# new)} other {(# new)}}"
msgstr "{0, plural, one {(# nová)} few {(# nové)} other {(# nových)}}"

#: src/pages/EditProfile/EditInterests.tsx:59
msgid "{label} added to interests"
msgstr "{label} byl přidán do zájmů"

#: src/pages/Home.tsx:28
#: src/components/Header/MainMenu.tsx:48
msgid "{messageCount, plural, one {(# new)} other {(# new)}}"
msgstr "{messageCount, plural, one {(# nová)} few {(# nové)} other {(# nových)}}"

#: src/components/Join/Join.tsx:240
msgid "<0>Ask for help in our project spaces</0> or write us email to <1>\"support at solidcouch dot org\"</1>"
msgstr "<0>Požádejte o pomoc v našich projektových prostorech</0> nebo nám napište e-mail na <1>\"support at solidcouch dot org\"</1>"
Expand Down Expand Up @@ -134,7 +133,7 @@ msgid "Contact request sent"
msgstr "Pozvánka odeslána"

#: src/pages/Profile/Profile.tsx:49
#: src/components/Header/MainMenu.tsx:57
#: src/components/Header/MainMenu.tsx:55
msgid "contacts"
msgstr "kontakty"

Expand Down Expand Up @@ -193,7 +192,7 @@ msgid "Edit"
msgstr "Upravit"

#: src/pages/Profile/Profile.tsx:40
#: src/components/Header/MainMenu.tsx:37
#: src/components/Header/MainMenu.tsx:39
msgid "edit profile"
msgstr "upravit profil"

Expand Down Expand Up @@ -262,7 +261,7 @@ msgstr "Hospex dokument nebyl nalezen"
msgid "Hospex not set up (should not happen)"
msgstr "Hospex není nastaven (nemělo by se to stát)"

#: src/pages/Home.tsx:19
#: src/pages/Home.tsx:21
msgid "host"
msgstr "hostit"

Expand Down Expand Up @@ -348,8 +347,8 @@ msgstr "logo {name}"
msgid "Message was created"
msgstr "Zpráva byla vytvořena"

#: src/pages/Home.tsx:22
#: src/components/Header/MainMenu.tsx:42
#: src/pages/Home.tsx:24
#: src/components/Header/MainMenu.tsx:44
msgid "messages"
msgstr "zprávy"

Expand All @@ -370,7 +369,7 @@ msgstr "více"
msgid "My Accommodation Offers"
msgstr "Moje nabídky ubytování"

#: src/components/Header/MainMenu.tsx:62
#: src/components/Header/MainMenu.tsx:60
msgid "my hosting"
msgstr "mé ubytování"

Expand Down Expand Up @@ -448,7 +447,7 @@ msgstr "Soukromý index typu není nastaven (nemělo by se to stát)."
msgid "process"
msgstr "zpracování"

#: src/components/Header/MainMenu.tsx:33
#: src/components/Header/MainMenu.tsx:35
msgid "profile"
msgstr "profil"

Expand Down Expand Up @@ -606,7 +605,7 @@ msgstr "K dokončení procesu musíte prokázat, že WebID na vaší doméně v
msgid "To join {communityName}, you need a <0>Solid Pod</0>."
msgstr "Pro připojení k {communityName} potřebujete <0>Solid Pod</0>."

#: src/pages/Home.tsx:16
#: src/pages/Home.tsx:18
msgid "travel"
msgstr "cestovat"

Expand Down
2 changes: 1 addition & 1 deletion src/locales/cs.ts

Large diffs are not rendered by default.

27 changes: 13 additions & 14 deletions src/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ msgstr ""
"Language-Team: \n"
"Plural-Forms: \n"

#. placeholder {0}: newMessages.length
#: src/pages/Home.tsx:26
#: src/components/Header/MainMenu.tsx:46
msgid "{0, plural, one {(# new)} other {(# new)}}"
msgstr "{0, plural, one {(# new)} other {(# new)}}"

#: src/pages/EditProfile/EditInterests.tsx:59
msgid "{label} added to interests"
msgstr "{label} added to interests"

#: src/pages/Home.tsx:28
#: src/components/Header/MainMenu.tsx:48
msgid "{messageCount, plural, one {(# new)} other {(# new)}}"
msgstr "{messageCount, plural, one {(# new)} other {(# new)}}"

#: src/components/Join/Join.tsx:240
msgid "<0>Ask for help in our project spaces</0> or write us email to <1>\"support at solidcouch dot org\"</1>"
msgstr "<0>Ask for help in our project spaces</0> or write us email to <1>\"support at solidcouch dot org\"</1>"
Expand Down Expand Up @@ -134,7 +133,7 @@ msgid "Contact request sent"
msgstr "Contact request sent"

#: src/pages/Profile/Profile.tsx:49
#: src/components/Header/MainMenu.tsx:57
#: src/components/Header/MainMenu.tsx:55
msgid "contacts"
msgstr "contacts"

Expand Down Expand Up @@ -193,7 +192,7 @@ msgid "Edit"
msgstr "Edit"

#: src/pages/Profile/Profile.tsx:40
#: src/components/Header/MainMenu.tsx:37
#: src/components/Header/MainMenu.tsx:39
msgid "edit profile"
msgstr "edit profile"

Expand Down Expand Up @@ -262,7 +261,7 @@ msgstr "Hospex document not found"
msgid "Hospex not set up (should not happen)"
msgstr "Hospex not set up (should not happen)"

#: src/pages/Home.tsx:19
#: src/pages/Home.tsx:21
msgid "host"
msgstr "host"

Expand Down Expand Up @@ -348,8 +347,8 @@ msgstr "logo of {name}"
msgid "Message was created"
msgstr "Message was created"

#: src/pages/Home.tsx:22
#: src/components/Header/MainMenu.tsx:42
#: src/pages/Home.tsx:24
#: src/components/Header/MainMenu.tsx:44
msgid "messages"
msgstr "messages"

Expand All @@ -370,7 +369,7 @@ msgstr "more"
msgid "My Accommodation Offers"
msgstr "My Accommodation Offers"

#: src/components/Header/MainMenu.tsx:62
#: src/components/Header/MainMenu.tsx:60
msgid "my hosting"
msgstr "my hosting"

Expand Down Expand Up @@ -448,7 +447,7 @@ msgstr "Private type index not set up (should not happen)"
msgid "process"
msgstr "process"

#: src/components/Header/MainMenu.tsx:33
#: src/components/Header/MainMenu.tsx:35
msgid "profile"
msgstr "profile"

Expand Down Expand Up @@ -606,7 +605,7 @@ msgstr "To complete the process, you must prove that the WebID on your domain be
msgid "To join {communityName}, you need a <0>Solid Pod</0>."
msgstr "To join {communityName}, you need a <0>Solid Pod</0>."

#: src/pages/Home.tsx:16
#: src/pages/Home.tsx:18
msgid "travel"
msgstr "travel"

Expand Down
Loading

0 comments on commit 2a74e6a

Please sign in to comment.