Skip to content

Commit ee4106e

Browse files
authored
refactor: rewrite to TypeScript (#14)
1 parent cab5466 commit ee4106e

Some content is hidden

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

94 files changed

+4637
-3203
lines changed

.eslintrc.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"no-array-constructor": 2,
3434
"no-mixed-spaces-and-tabs": 2,
3535
"no-multiple-empty-lines": 2,
36-
"no-nested-ternary": 2,
3736
"semi-spacing": 2,
3837
"no-spaced-func": 2,
3938
"no-trailing-spaces": 2,
@@ -43,7 +42,13 @@
4342
},
4443
"overrides": [
4544
{
46-
"files": ["test/**/*.js", "*.spec.js", "*.stories.js"],
45+
"files": ["**/*.ts"],
46+
"parser": "@typescript-eslint/parser",
47+
"plugins": ["@typescript-eslint"],
48+
"extends": ["plugin:@typescript-eslint/recommended"]
49+
},
50+
{
51+
"files": ["test/**/*.{js,ts}", "*.spec.{js,ts}", "*.stories.{js,ts}"],
4752
"plugins": [
4853
"jest",
4954
"testing-library",
@@ -55,7 +60,8 @@
5560
},
5661
"rules": {
5762
"no-console": 0,
58-
"no-shadow": 0
63+
"no-shadow": 0,
64+
"@typescript-eslint/no-explicit-any": 0
5965
}
6066
}
6167
]

.storybook/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
'@storybook/addon-viewport'
1212
],
1313
webpackFinal: async config => {
14+
config.module.rules[0].use = [require.resolve('swc-loader')];
1415
config.module.rules.push({
1516
test: /\.scss$/,
1617
sideEffects: true,
@@ -23,7 +24,7 @@ module.exports = {
2324
? 'chartist/dist/chartist.css'
2425
: path.resolve(__dirname, '..', 'src', 'styles', 'chartist.scss');
2526
config.resolve.alias['chartist-dev$'] = isCompatMode
26-
? path.resolve(__dirname, '..', 'test', 'mock', 'compat.js')
27+
? path.resolve(__dirname, '..', 'test', 'mock', 'compat.ts')
2728
: path.resolve(__dirname, '..', 'src');
2829

2930
return config;

package.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
"node": ">=14"
3333
},
3434
"sideEffects": false,
35+
"types": "./dist/index.d.ts",
3536
"style": "./src/styles/chartist.scss",
36-
"main": "./src/index.js",
37+
"main": "./src/index.ts",
3738
"publishConfig": {
3839
"style": "./dist/index.css",
3940
"main": "./dist/index.cjs",
@@ -50,15 +51,17 @@
5051
"LICENSE-MIT"
5152
],
5253
"scripts": {
54+
"emitDeclarations": "tsc --emitDeclarationOnly",
5355
"build:styles": "./scripts/styles.js",
54-
"build": "rollup -c & pnpm build:styles",
56+
"build": "rollup -c & pnpm build:styles & pnpm emitDeclarations",
5557
"start:storybook": "start-storybook -p 6006 --ci",
5658
"build:storybook": "del ./storybook-static; NODE_ENV=production build-storybook",
59+
"jest": "jest -c jest.config.json",
5760
"test:unit": "jest -c jest.config.json ./src",
5861
"test:storyshots": "jest -c jest.config.json ./test/storyshots.spec.js",
5962
"test": "pnpm lint && pnpm test:unit",
60-
"lint": "eslint './*.js' 'test/**/*.js' 'src/**/*.js' '.storybook/**/*.js' 'scripts/**/*.js'",
61-
"format": "prettier --write './*.js' 'test/**/*.js' 'src/**/*.js' '.storybook/**/*.js' 'scripts/**/*.js'",
63+
"lint": "eslint './*.{js,ts}' 'test/**/*.{js,ts}' 'src/**/*.{js,ts}' '.storybook/**/*.{js,ts}' 'scripts/**/*.{js,ts}'",
64+
"format": "prettier --write './*.{js,ts}' 'test/**/*.{js,ts}' 'src/**/*.{js,ts}' '.storybook/**/*.{js,ts}' 'scripts/**/*.{js,ts}'",
6265
"commit": "cz",
6366
"updateGitHooks": "simple-git-hooks"
6467
},
@@ -81,6 +84,10 @@
8184
"@swc/jest": "^0.2.20",
8285
"@testing-library/jest-dom": "^5.16.4",
8386
"@types/faker": "^5.5.8",
87+
"@types/jest": "^27.5.1",
88+
"@types/node": "^17.0.34",
89+
"@typescript-eslint/eslint-plugin": "^5.25.0",
90+
"@typescript-eslint/parser": "^5.25.0",
8491
"browserslist": "^4.20.2",
8592
"chartist": "^0.11.4",
8693
"commitizen": "^4.2.4",
@@ -107,7 +114,10 @@
107114
"rollup-plugin-swc": "^0.2.1",
108115
"sass": "^1.50.1",
109116
"sass-loader": "^10.0.0",
110-
"simple-git-hooks": "^2.7.0"
117+
"simple-git-hooks": "^2.7.0",
118+
"swc-loader": "^0.2.3",
119+
"tsd": "^0.20.0",
120+
"typescript": "^4.6.4"
111121
},
112122
"readme": ""
113123
}

0 commit comments

Comments
 (0)