Skip to content

Commit 9c4fa8f

Browse files
committed
Merge branch 'main' of github.com.:dwightjack/vue-types
2 parents f6425ed + 4148c6c commit 9c4fa8f

Some content is hidden

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

85 files changed

+4411
-8916
lines changed

.github/workflows/build.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ jobs:
2727
cache: 'pnpm'
2828
registry-url: 'https://registry.npmjs.org'
2929
- run: pnpm i
30+
- name: Build
31+
run: pnpm build
3032
- name: Lint
31-
run: pnpm -r run lint
33+
run: pnpm lint
3234

3335
- name: Test
34-
run: pnpm -r test
36+
run: pnpm test
3537
- name: Upload code coverage
3638
uses: paambaati/codeclimate-action@f429536ee076d758a24705203199548125a28ca7 # v9.0.0
3739
env:
3840
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
3941
with:
4042
coverageLocations: ${{github.workspace}}/packages/core/coverage/lcov.info:lcov
4143
prefix: test
42-
- name: Build
43-
run: pnpm -r run build
4444
- name: Create Release Pull Request or Publish to npm
4545
id: changesets
4646
if: github.ref_name == 'main'

.npmrc

-3
This file was deleted.

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.18.1
1+
22.12.0

.prettierrc.cjs

-7
This file was deleted.

.prettierrc.mjs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @see https://prettier.io/docs/en/configuration.html
3+
* @type {import("prettier").Config}
4+
*/
5+
export default {
6+
printWidth: 80,
7+
trailingComma: 'all',
8+
arrowParens: 'always',
9+
semi: false,
10+
singleQuote: true,
11+
}

.vscode/settings.json

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"[ts]": {
66
"editor.formatOnSave": false
77
},
8+
"[markdown]": {
9+
"editor.formatOnSave": true,
10+
"editor.defaultFormatter": "esbenp.prettier-vscode"
11+
},
812
"editor.codeActionsOnSave": {
913
"source.fixAll.eslint": "explicit"
1014
}

eslint.config.mjs

+25-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,33 @@
33
import eslint from '@eslint/js'
44
import ts from 'typescript-eslint'
55
import prettier from 'eslint-plugin-prettier/recommended'
6+
import vue from 'eslint-plugin-vue'
7+
import globals from 'globals'
68

79
export default ts.config(
810
eslint.configs.recommended,
911
...ts.configs.strict,
1012
...ts.configs.stylistic,
13+
{
14+
extends: [
15+
eslint.configs.recommended,
16+
...ts.configs.strict,
17+
...ts.configs.stylistic,
18+
...vue.configs['flat/recommended'],
19+
],
20+
files: ['**/*.{ts,vue}'],
21+
languageOptions: {
22+
ecmaVersion: 'latest',
23+
sourceType: 'module',
24+
globals: globals.browser,
25+
parserOptions: {
26+
parser: ts.parser,
27+
},
28+
},
29+
rules: {
30+
'vue/one-component-per-file': 0,
31+
},
32+
},
1133
{
1234
files: ['**/*.ts'],
1335
rules: {
@@ -16,5 +38,7 @@ export default ts.config(
1638
},
1739
},
1840
prettier,
19-
{ ignores: ['**/dist', '**/node_modules', '**/shim', '**/*.vue'] },
41+
{
42+
ignores: ['**/dist', '**/node_modules', '**/shim', '**/*.vue', '**/cache'],
43+
},
2044
)

package.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
"description": "VueTypes Monorepo",
44
"author": "Marco Solazzi",
55
"license": "MIT",
6-
"homepage": "https://dwightjack.github.io/vue-types/",
6+
"homepage": "https://vue-types.codeful.dev/",
77
"type": "module",
88
"private": true,
99
"packageManager": "[email protected]",
1010
"engines": {
11-
"node": ">=16.16.0",
11+
"node": ">=20.0.0",
1212
"pnpm": "^9.0.0"
1313
},
1414
"scripts": {
1515
"examples:dev": "pnpm --filter=vue-types run build && pnpm --filter=examples start",
1616
"docs:dev": "pnpm --filter=docs run dev",
17+
"build": "pnpm -r build",
18+
"lint": "pnpm -r lint",
19+
"test": "pnpm -r test",
1720
"ci:version": "pnpm changeset version && pnpm install --lockfile-only",
1821
"ci:publish": "git status && pnpm -r publish"
1922
},
@@ -28,9 +31,12 @@
2831
"@vitest/coverage-v8": "2.1.8",
2932
"eslint-config-prettier": "9.1.0",
3033
"eslint-plugin-prettier": "5.2.1",
34+
"eslint-plugin-vue": "^9.32.0",
35+
"globals": "^15.14.0",
3136
"happy-dom": "15.11.7",
3237
"lefthook": "1.8.5",
3338
"prettier": "3.3.3",
39+
"publint": "^0.3.4",
3440
"typescript": "5.6.3",
3541
"typescript-eslint": "8.15.0",
3642
"vite": "5.4.12",

packages/core/.babelrc

-11
This file was deleted.

packages/core/CHANGELOG.md

+82
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,87 @@
11
# vue-types
22

3+
## 6.0.0
4+
5+
### Major Changes
6+
7+
- 306173f: #### Drop Vue 2 support
8+
9+
Vue 2 reached End of Life (EOL) on December 31st, 2023. By dropping Vue 2 compatibility we can deliver a smaller package and make the source code more maintainable.
10+
11+
If you're unable to update to Vue 3, please use [email protected]
12+
13+
#### Removed `VueTypes.extend` method
14+
15+
`VueTypes.extend` was deprecated in v5. In v6 this method has been removed. Please migrate your code to use ES6+ `extends` feature.
16+
17+
Example:
18+
19+
Using `VueTypes.extend` (old):
20+
21+
```js
22+
import VueTypes from 'vue-types'
23+
24+
export const VueTypesProject = VueTypes.extend([
25+
{
26+
name: 'maxLength',
27+
type: String,
28+
validator: (max, v) => v.length <= max,
29+
},
30+
{
31+
name: 'positive',
32+
getter: true,
33+
type: Number,
34+
validator: (v) => v > 0,
35+
},
36+
])
37+
```
38+
39+
Using ES6+ `extends` (new):
40+
41+
```js
42+
import VueTypes, { toType } from 'vue-types'
43+
44+
export class VueTypesProject extends VueTypes {
45+
static maxLength(max) {
46+
return toType('maxLength', {
47+
type: String,
48+
validator: (v) => String(v).length <= max,
49+
})
50+
}
51+
52+
static get positive() {
53+
return toType('positive', {
54+
type: Number,
55+
validator: (v) => v > 0,
56+
})
57+
}
58+
}
59+
```
60+
61+
#### Package format review:
62+
63+
- ESM and CJS builds target is ESNext (browsers with support for the latest JavaScript features).
64+
- UMD builds target is ES2016 (aligned with [Vue 3 browser support](https://vuejs.org/about/faq#what-browsers-does-vue-support))
65+
66+
If you're using a bundler, you should not encounter any issue.
67+
68+
If you are directly referencing or importing a specific file in the `dist` or `shim` folder, you might need to update its path as described in the following table:
69+
70+
| Old (v5) | New (v6) |
71+
| -------------------------- | ------------------- |
72+
| `dist/vue-types.m.js` | `dist/index.mjs` |
73+
| `dist/vue-types.modern.js` | `dist/index.mjs` |
74+
| `dist/vue-types.cjs` | `dist/index.cjs` |
75+
| `dist/vue-types.umd.js` | `dist/index.umd.js` |
76+
| `dist/shim.m.js` | `dist/shim.mjs` |
77+
| `dist/shim.modern.js` | `dist/shim.mjs` |
78+
| `dist/shim.cjs` | `dist/shim.cjs` |
79+
| `dist/shim.umd.js` | `dist/shim.umd.js` |
80+
| `shim/index.m.js` | `dist/shim.mjs` |
81+
| `shim/index.modern.js` | `dist/shim.mjs` |
82+
| `shim/index.cjs` | `dist/shim.cjs` |
83+
| `shim/index.umd.js` | `dist/shim.umd.js` |
84+
385
## 5.1.3
486

587
### Patch Changes

packages/core/__tests__/helpers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export function checkRequired(type: any) {
88

99
// Vue.js does keep the context for validators, so there is no `this`
1010
export const forceNoContext = <T extends (..._args: any[]) => any>(
11-
validator: T,
12-
): T => validator.bind(undefined)
11+
validator?: T,
12+
): T => validator?.bind(undefined) as T
1313

1414
export function getDescriptors<T extends Record<string, any>>(type: T): T {
1515
const descriptors = {} as { [P in keyof T]: any }
@@ -25,10 +25,10 @@ export function getExpectDescriptors<T extends Record<string, any>>(
2525
const descriptors = {} as { [P in keyof T]: any }
2626
Object.getOwnPropertyNames(type).forEach((key) => {
2727
const descr = Object.getOwnPropertyDescriptor(type, key)
28-
if (typeof descr.get === 'function') {
28+
if (typeof descr?.get === 'function') {
2929
descr.get = expect.any(Function) as any
3030
}
31-
if (typeof descr.value === 'function') {
31+
if (typeof descr?.value === 'function') {
3232
descr.value = expect.any(Function) as any
3333
}
3434
descriptors[key as keyof T] = descr

0 commit comments

Comments
 (0)