Skip to content

Commit 3923c68

Browse files
authored
refactor: migrate to typescript (#272)
Should have no impact, we bump as major only for the sake of convenience BREAKING CHANGE: migrate the codebase to typescript
1 parent e14f88f commit 3923c68

33 files changed

+605
-300
lines changed

.eslintrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,14 @@
1313
"devDependencies": ["**/__tests__/*", "rollup.config.mjs"]
1414
}
1515
]
16-
}
16+
},
17+
"overrides": [
18+
{
19+
"files": ["*.ts", "*.tsx"],
20+
"parserOptions": {
21+
"project": ["tsconfig.json"]
22+
},
23+
"extends": ["./packages/eslint-config-react/typescript.js"]
24+
}
25+
]
1726
}

babel.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"presets": ["@babel/preset-env", "@babel/preset-react"],
2+
"presets": ["@babel/preset-typescript", "@babel/preset-env", "@babel/preset-react"],
33
"plugins": ["@babel/plugin-transform-runtime"]
44
}

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
"@babel/plugin-transform-runtime": "^7.12.10",
1212
"@babel/preset-env": "^7.12.11",
1313
"@babel/preset-react": "^7.13.13",
14+
"@babel/preset-typescript": "^7.14.5",
1415
"@commitlint/cli": "^12.0.0",
1516
"@commitlint/config-conventional": "^12.0.0",
1617
"@rollup/plugin-babel": "^5.2.2",
1718
"@rollup/plugin-node-resolve": "^13.0.0",
1819
"@testing-library/jest-dom": "^5.11.9",
1920
"@testing-library/react": "^12.0.0",
2021
"@testing-library/react-hooks": "^7.0.0",
22+
"@types/react-router-dom": "^5.1.8",
2123
"builtin-modules": "^3.2.0",
2224
"cross-env": "^7.0.3",
2325
"eslint": "^7.18.0",
@@ -30,10 +32,12 @@
3032
"prettier": "^2.2.1",
3133
"read-pkg": "^6.0.0",
3234
"rollup": "^2.36.1",
33-
"rollup-plugin-visualizer": "^5.5.0"
35+
"rollup-plugin-dts": "^3.0.2",
36+
"rollup-plugin-visualizer": "^5.5.0",
37+
"typescript": "^4.3.5"
3438
},
3539
"scripts": {
36-
"lint": "eslint --cache .",
40+
"lint": "eslint --ext js,ts,tsx --cache .",
3741
"lint:fix": "yarn run lint --fix",
3842
"build": "lerna exec --stream --ignore @scaleway/eslint-* --ignore @scaleway/countries -- rollup -c ../../rollup.config.mjs",
3943
"build:profile": "cross-env PROFILE=true yarn run build",
@@ -65,7 +69,7 @@
6569
"jest-localstorage-mock"
6670
],
6771
"collectCoverageFrom": [
68-
"packages/*/src/**/*.{js,jsx}"
72+
"packages/*/src/**/*.{ts,tsx,js,jsx}"
6973
],
7074
"modulePathIgnorePatterns": [
7175
"locales"

packages/random-name/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
"version": "1.3.2",
44
"description": "A small utility to generate a random name",
55
"type": "module",
6-
"main": "dist/module.js",
7-
"module": "dist/module.js",
6+
"main": "dist/index.js",
7+
"module": "dist/index.js",
8+
"types": "dist/index.d.ts",
89
"browser": {
9-
"dist/module.js": "./dist/module.browser.js"
10+
"dist/index.js": "./dist/index.browser.js"
1011
},
1112
"publishConfig": {
1213
"access": "public"

packages/random-name/src/__tests__/index.js renamed to packages/random-name/src/__tests__/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('randomNames', () => {
2222
})
2323

2424
it('should never includes the word "cocks"', () => {
25-
const names = Array.from(Array(1000000), randomName)
25+
const names = Array.from(Array(1000000), () => randomName())
2626
expect(names).not.toEqual(
2727
expect.arrayContaining([expect.stringMatching('cocks')]),
2828
)

packages/random-name/src/index.js renamed to packages/random-name/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import dockerNames from 'docker-names'
22

3-
const randomName = (prefix = '', separator = '-') => {
3+
const randomName = (prefix = '', separator = '-'): string => {
44
let random = dockerNames.getRandomName().replace(/_/g, separator)
55
while (random.includes('cocks')) {
66
random = dockerNames.getRandomName().replace(/_/g, separator)

packages/regex/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
"version": "1.4.3",
44
"description": "A small utility to use regex",
55
"type": "module",
6-
"main": "dist/module.js",
7-
"module": "dist/module.js",
6+
"main": "dist/index.js",
7+
"module": "dist/index.js",
8+
"types": "dist/index.d.ts",
89
"browser": {
9-
"dist/module.js": "./dist/module.browser.js"
10+
"dist/index.js": "./dist/index.browser.js"
1011
},
1112
"publishConfig": {
1213
"access": "public"

0 commit comments

Comments
 (0)