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

♻️ Migrate website to TypeScript #1244

Merged
merged 26 commits into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1a2b508
🔧 Add typescript configuration files
carloscuesta Dec 23, 2022
21af02b
➕ Install typescript dependencies
carloscuesta Dec 23, 2022
b4c90cd
♻️ Migrate `lint-staged` to .ts(x) files
carloscuesta Dec 23, 2022
94a53db
♻️ Migrate `eslint` configuration to TypeScript
carloscuesta Dec 23, 2022
a78bb15
♻️ Migrate `jest` configuration to TypeScript
carloscuesta Dec 23, 2022
454b205
🔥 Remove `babel` configuration
carloscuesta Dec 23, 2022
0089be7
➖ Uninstall flow dependencies
carloscuesta Dec 23, 2022
ec19be6
🔥 Remove `flow` configuration
carloscuesta Dec 23, 2022
b157ebf
👷 Run `tsc` in `ci` workflow
carloscuesta Dec 23, 2022
85dd45f
🔧 Update `pre-push` hook
carloscuesta Dec 27, 2022
65d4cba
♻️ Migrate `pages/api` to TS
carloscuesta Dec 27, 2022
db95265
♻️ Migrate `pages/_app` to TS
carloscuesta Dec 27, 2022
b41a5ab
♻️ Migrate `pages/_document` to TS
carloscuesta Dec 27, 2022
644d1d1
♻️ Migrate `pages/about` to TS
carloscuesta Dec 27, 2022
76c2255
♻️ Migrate `pages/contributors` to TS
carloscuesta Dec 27, 2022
921e448
♻️ Migrate `pages/index` to TS
carloscuesta Dec 27, 2022
e0cbc37
♻️ Migrate `pages/related-tools` to TS
carloscuesta Dec 27, 2022
311e429
♻️ Migrate `components/Button` to TS
carloscuesta Dec 27, 2022
e50fcdc
♻️ Migrate `components/CarbonAd` to TS
carloscuesta Dec 27, 2022
ab2281c
♻️ Migrate `components/ContributorsList` to TS
carloscuesta Dec 27, 2022
7aefa93
♻️ Migrate `components/Icon` to TS
carloscuesta Dec 27, 2022
8c3d422
♻️ Migrate `components/SEO` to TS
carloscuesta Dec 27, 2022
0c0a646
♻️ Migrate `components/Layout` to TS
carloscuesta Dec 27, 2022
4544834
♻️ Migrate `components/GitmojiList` to TS
carloscuesta Dec 27, 2022
3cc911e
♻️ Migrate `__tests__/` pages to TS
carloscuesta Dec 28, 2022
62c061a
🏷️ Update `next-env.d.ts`
carloscuesta Dec 28, 2022
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
15 changes: 0 additions & 15 deletions .flowconfig

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: yarn install --immutable
- name: Lint 🎨
run: yarn turbo lint
- name: Flow types 🏷
run: yarn turbo flow
- name: TypeScript check 🏷
run: yarn turbo tscheck
- name: Tests ✅
run: yarn turbo test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ packages/website/public/*.map
packages/website/public/robots.txt
packages/website/public/sitemap.xml
packages/website/public/sitemap-*.xml

# TS
*.tsbuildinfo
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn turbo flow && yarn turbo test
yarn turbo tscheck && yarn turbo test
4 changes: 2 additions & 2 deletions packages/website/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"./src/**/*.{js,css}": [
"./src/**/*.{ts,tsx,css}": [
"eslint --cache --fix",
"prettier --write ./src/**/*.{js,css}"
"prettier --write ./src/**/*.{ts,tsx,css}"
]
}
6 changes: 0 additions & 6 deletions packages/website/babel.config.json

This file was deleted.

20 changes: 20 additions & 0 deletions packages/website/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const nextJest = require('next/jest')

const createJestConfig = nextJest({
dir: './'
})

/** @type {import('jest').Config} */
module.exports = createJestConfig({
"collectCoverageFrom": [
"src/**/*.{ts,tsx}",
],
"testMatch": [
"**/*.(spec).(ts)",
"**/*.(spec).(tsx)"
],
"moduleNameMapper": {
"src/(.*)$": "<rootDir>/src/$1"
},
"testEnvironment": "jsdom"
})
5 changes: 5 additions & 0 deletions packages/website/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
66 changes: 16 additions & 50 deletions packages/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,28 @@
},
"scripts": {
"build": "next build && next-sitemap",
"tscheck": "yarn tsc --noEmit",
"dev": "next dev",
"flow": "flow",
"lint": "eslint ./src && prettier --check ./src/**/*.{js,css}",
"lint": "eslint ./src && prettier --check ./src/**/*.{ts,tsx,css}",
"start": "next start",
"test": "FORCE_COLOR=1 jest --coverage"
},
"devDependencies": {
"@babel/core": "^7.19.6",
"@babel/eslint-parser": "^7.19.1",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.18.6",
"@types/fetch-mock": "^7.3.5",
"@types/jest": "^29.2.4",
"@types/react": "^18.0.26",
"@types/react-test-renderer": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.47.0",
"@typescript-eslint/parser": "^5.47.0",
"clipboard": "^2.0.4",
"eslint": "^8.26.0",
"eslint-config-next": "^13.1.1",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-jest": "^27.1.3",
"eslint-plugin-react": "^7.31.10",
"flow-bin": "^0.196.3",
"focus-trap-react": "^10.0.0",
"gitmojis": "workspace:*",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.0.1",
"jest-environment-jsdom": "^29.0.1",
"jest-fetch-mock": "^3.0.3",
Expand All @@ -38,11 +37,13 @@
"next-pwa": "^5.4.4",
"next-sitemap": "^3.1.43",
"next-themes": "^0.2.0",
"node-mocks-http": "^1.12.1",
"prettier": "2.8.1",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-test-renderer": "^18.2.0"
"react-test-renderer": "^18.2.0",
"typescript": "^4.9.4"
},
"author": {
"name": "carloscuesta",
Expand All @@ -69,32 +70,19 @@
"singleQuote": true,
"arrowParens": "always"
},
"jest": {
"collectCoverageFrom": [
"./src/**/*.{js,jsx}"
],
"testMatch": [
"**/*.(spec).(js)"
],
"moduleNameMapper": {
"^.+\\.css$": "identity-obj-proxy",
"src/(.*)$": "<rootDir>/src/$1"
},
"testEnvironment": "jsdom"
},
"volta": {
"node": "16.15.0"
},
"eslintConfig": {
"parser": "@babel/eslint-parser",
"parser": "@typescript-eslint/parser",
"env": {
"jest": true,
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:flowtype/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"prettier",
"plugin:@next/next/recommended"
Expand All @@ -108,24 +96,15 @@
"requireConfigFile": false,
"babelOptions": {
"presets": [
"next/babel",
"@babel/preset-react",
"@babel/preset-flow"
"next/babel"
]
}
},
"plugins": [
"react",
"flowtype"
"@typescript-eslint"
],
"rules": {
"flowtype/require-valid-file-annotation": [
2,
"always",
{
"annotationStyle": "line"
}
],
"react/react-in-jsx-scope": "off",
"@next/next/no-img-element": "off",
"react/no-unknown-property": [
Expand All @@ -138,22 +117,9 @@
}
]
},
"overrides": [
{
"files": [
"*.spec.js",
"stubs.js",
"**/__mocks__/*.js"
],
"rules": {
"flowtype/require-valid-file-annotation": 0
}
}
],
"settings": {
"react": {
"version": "detect",
"flowVersion": "detect"
"version": "detect"
},
"import/resolver": {
"alias": {
Expand Down
Loading