Skip to content

Commit a681b95

Browse files
committed
feat: i18n
1 parent f4bd6f9 commit a681b95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+913
-680
lines changed

.eslintignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ src/serviceWorkerRegistration.ts
122122
src/setupTests.ts
123123
src/reportWebVitals.ts
124124

125-
.eslintrc.js
125+
.eslintrc.json
126+
.prettierrc
126127

127-
functions/search.js
128-
search/search-index.json
128+
.netlify/

.eslintrc.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

.eslintrc.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"parser": "@typescript-eslint/parser", // Specifies the ESLint parser
3+
"extends": [
4+
"plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react
5+
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier.
6+
],
7+
"parserOptions": {
8+
"ecmaVersion": 2018,
9+
"sourceType": "module",
10+
"ecmaFeatures": {
11+
"jsx": true
12+
}
13+
},
14+
"rules": {
15+
"react/prop-types": "off",
16+
"react/display-name": "off",
17+
"@typescript-eslint/explicit-function-return-type": "off",
18+
"@typescript-eslint/ban-ts-ignore": "off",
19+
"@typescript-eslint/no-explicit-any": "off",
20+
"@typescript-eslint/no-empty-function": "off",
21+
"@typescript-eslint/explicit-module-boundary-types": "off"
22+
},
23+
"settings": {
24+
"react": {
25+
"version": "detect"
26+
}
27+
}
28+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ yarn-error.log
1616

1717
# production
1818
/build
19+
.netlify/
1920

2021
# misc
2122
.DS_Store

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"bracketSpacing": false,
4+
"trailingComma": "all",
5+
"semi": false
6+
}

@types/react-i18next/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import 'react-i18next'
2+
import {resources, defaultNS} from '../../src/i18n/config'
3+
4+
declare module 'react-i18next' {
5+
interface CustomTypeOptions {
6+
defaultNS: typeof defaultNS
7+
resources: typeof resources['en']
8+
}
9+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ Made with React & Redux. Powered by [PokeAPI](https://pokeapi.co)
4343

4444
- ~~a11y~~
4545

46-
- i18n
46+
- ~~i18n~~

functions/search.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

functions/search.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {Handler} from '@netlify/functions'
2+
import get from 'lodash/get'
3+
import pokedex from '../search/search-index.json'
4+
5+
const handler: Handler = (event, context, callback) => {
6+
const query = get(event, ['queryStringParameters', 'q'])
7+
8+
const res = pokedex.filter(
9+
(pokemon) =>
10+
pokemon.name.toString().toLowerCase().includes(query.toLowerCase()) ||
11+
pokemon.id.toString().toLowerCase().includes(query.toLowerCase()),
12+
)
13+
14+
callback(null, {
15+
statusCode: 200,
16+
headers: {
17+
'Access-Control-Allow-Origin': '*',
18+
'Access-Control-Allow-Methods': 'GET',
19+
},
20+
body: JSON.stringify(res),
21+
})
22+
}
23+
24+
export {handler}

package.json

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22
"name": "pokedex",
33
"version": "2.0.0",
44
"private": true,
5+
"scripts": {
6+
"dev": "netlify dev",
7+
"start": "react-scripts start",
8+
"build": "react-scripts build",
9+
"test": "react-scripts test",
10+
"eject": "react-scripts eject",
11+
"format": "prettier --write \"**/*.ts{,x}\"",
12+
"lint": "tsc --noEmit && eslint \"**/*.ts{,x}\"",
13+
"lint:fix": "tsc --noEmit && eslint \"**/*.ts{,x}\" --fix",
14+
"clean": "rimraf .netlify"
15+
},
516
"dependencies": {
17+
"@netlify/functions": "^0.10.0",
618
"@testing-library/jest-dom": "^5.11.4",
719
"@testing-library/react": "^11.1.0",
820
"@testing-library/user-event": "^12.1.10",
@@ -19,11 +31,13 @@
1931
"@types/react-router-dom": "^5.3.2",
2032
"axios": "^0.24.0",
2133
"gestalt": "^40.1.2",
34+
"i18next": "^21.5.4",
2235
"lodash": "^4.17.21",
2336
"react": "^17.0.2",
2437
"react-dom": "^17.0.2",
2538
"react-gtm-module": "^2.0.11",
2639
"react-helmet": "^6.1.0",
40+
"react-i18next": "^11.14.3",
2741
"react-redux": "^7.2.6",
2842
"react-router-dom": "^6.0.2",
2943
"react-scripts": "4.0.2",
@@ -44,15 +58,14 @@
4458
"workbox-strategies": "^5.1.3",
4559
"workbox-streams": "^5.1.3"
4660
},
47-
"scripts": {
48-
"dev": "netlify dev",
49-
"start": "react-scripts start",
50-
"build": "react-scripts build",
51-
"test": "react-scripts test",
52-
"eject": "react-scripts eject",
53-
"format": "prettier --write src/**/**/*.ts{,x}",
54-
"lint": "tsc --noEmit && eslint src/**/**/*.ts{,x}",
55-
"lint:fix": "tsc --noEmit && eslint src/**/**/*.ts{,x} --fix"
61+
"devDependencies": {
62+
"@typescript-eslint/eslint-plugin": "^5.4.0",
63+
"@typescript-eslint/parser": "^5.4.0",
64+
"eslint-config-prettier": "^8.3.0",
65+
"eslint-plugin-prettier": "^4.0.0",
66+
"eslint-plugin-react": "^7.27.1",
67+
"prettier": "^2.5.0",
68+
"rimraf": "^3.0.2"
5669
},
5770
"eslintConfig": {
5871
"extends": [
@@ -71,20 +84,5 @@
7184
"last 1 firefox version",
7285
"last 1 safari version"
7386
]
74-
},
75-
"devDependencies": {
76-
"@typescript-eslint/eslint-plugin": "^4.18.0",
77-
"@typescript-eslint/parser": "^4.18.0",
78-
"eslint": "^7.22.0",
79-
"eslint-config-airbnb": "^18.2.1",
80-
"eslint-config-airbnb-typescript": "^12.3.1",
81-
"eslint-config-prettier": "^8.1.0",
82-
"eslint-plugin-import": "^2.22.1",
83-
"eslint-plugin-jest": "^24.3.1",
84-
"eslint-plugin-jsx-a11y": "^6.4.1",
85-
"eslint-plugin-prettier": "^3.3.1",
86-
"eslint-plugin-react": "^7.22.0",
87-
"eslint-plugin-react-hooks": "^4.2.0",
88-
"prettier": "^2.2.1"
8987
}
9088
}

0 commit comments

Comments
 (0)