Skip to content

Commit

Permalink
feat: typescript support (#757)
Browse files Browse the repository at this point in the history
* chore: add typescript

add typescript and change project configs

BREAKING CHANGE: add typescript

* refactor: rewrite code to typescript

* fix: change interface name

* feat: remove unused global var

* feat: remove old types folder

* feat: add eslintignore

* feat: add typescript to sandboxes

* feat: rewrite stories to typescript

* feat: rewrite tests to typescript

* feat: fix app exports and props types

* feat: add tests for type definitions

* fix: fix clean-publish config

* fix: fix clean-publish config again

* feat: add storybook build check
  • Loading branch information
thabarbados authored and dangreen committed Mar 17, 2022
1 parent 34ce7f9 commit 67e73a0
Show file tree
Hide file tree
Showing 86 changed files with 1,100 additions and 521 deletions.
4 changes: 3 additions & 1 deletion .clean-publish
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"withoutPublish": true,
"tempDir": "package"
"tempDir": "package",
"fields": ["tsd"],
"files": ["docs"]
}
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/*
node_modules/*
13 changes: 6 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
module.exports = {
root: true,
parserOptions: {
sourceType: 'module',
sourceType: 'module'
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
extends: [
'standard',
'plugin:prettier/recommended',
'plugin:vue/recommended',
'plugin:prettier-vue/recommended',
'plugin:vue/vue3-essential',
'@vue/eslint-config-typescript'
],
// required to lint *.vue files
plugins: ['prettier'],
Expand All @@ -19,9 +21,6 @@ module.exports = {
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'prettier/prettier': 'error',
quotes: [2, 'single', 'avoid-escape'],
},
globals: {
LIB_VERSION: true,
},
};
quotes: [2, 'single', 'avoid-escape']
}
}
41 changes: 41 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,44 @@ jobs:
uses: andresz1/size-limit-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
typings:
runs-on: ubuntu-latest
name: typings
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 6
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Prebuild
run: pnpm build
- name: Check typings
if: success()
run: pnpm test:typings
storybook:
runs-on: ubuntu-latest
name: storybook
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 6
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Check storybook
run: pnpm build:storybook
2 changes: 1 addition & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
webpackFinal: async config => {
config.resolve.alias['vue-chartjs'] = path.resolve(
__dirname,
'../src/index.js'
'../src/index.ts'
)
return config
}
Expand Down
20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"Charts"
],
"sideEffects": false,
"main": "./src/index.js",
"typings": "./dist/index.d.ts",
"main": "./src/index.ts",
"types": "./dist/index.d.ts",
"publishConfig": {
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand All @@ -47,17 +47,20 @@
"scripts": {
"prepublishOnly": "pnpm test && pnpm build && del ./package && clean-publish",
"postpublish": "del ./package",
"build": "rollup -c",
"emitDeclarations": "tsc --emitDeclarationOnly",
"build": "rollup -c & pnpm emitDeclarations",
"unit": "jest -c jest.config.json",
"test": "pnpm lint && pnpm unit",
"test:size": "size-limit",
"lint": "eslint --ext .js,.vue src test",
"test:typings": "tsd",
"lint": "eslint 'src/**/*.ts'",
"format": "prettier --write src test",
"release": "standard-version",
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs",
"commit": "cz",
"start:storybook": "start-storybook -p 6006"
"start:storybook": "start-storybook -p 6006",
"build:storybook": "del ./storybook-static; NODE_ENV=production build-storybook"
},
"peerDependencies": {
"chart.js": "^3.7.0"
Expand All @@ -75,7 +78,9 @@
"@swc/core": "^1.2.120",
"@swc/helpers": "^0.3.2",
"@swc/jest": "^0.2.15",
"@types/jest": "^27.4.1",
"@vitejs/plugin-vue": "^2.2.2",
"@vue/eslint-config-typescript": "^10.0.0",
"@vue/test-utils": "^2.0.0-rc.17",
"@vue/vue3-jest": "^27.0.0-alpha.4",
"babel-jest": "^27.4.5",
Expand Down Expand Up @@ -106,9 +111,14 @@
"simple-git-hooks": "^2.7.0",
"size-limit": "^7.0.8",
"standard-version": "^9.3.2",
"tsd": "^0.19.1",
"typescript": "^4.6.2",
"vite": "^2.8.6",
"vue": "^3.2.31",
"vue-loader": "^17.0.0",
"vuepress": "^0.14.4"
},
"tsd": {
"directory": "./test"
}
}
Loading

0 comments on commit 67e73a0

Please sign in to comment.