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 to typescript #757

Merged
merged 14 commits into from Mar 17, 2022
Merged
4 changes: 3 additions & 1 deletion .clean-publish
@@ -1,4 +1,6 @@
{
"withoutPublish": true,
"tempDir": "package"
"tempDir": "package",
"fields": ["tsd"],
"files": ["docs"]
}
2 changes: 2 additions & 0 deletions .eslintignore
@@ -0,0 +1,2 @@
dist/*
node_modules/*
13 changes: 6 additions & 7 deletions .eslintrc.js
@@ -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
Expand Up @@ -26,3 +26,44 @@ jobs:
uses: andresz1/size-limit-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
typings:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

runs-on: ubuntu-latest
name: typings
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Install pnpm
uses: pnpm/action-setup@v2.0.1
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/action-setup@v2.0.1
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
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
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"
}
}