Skip to content

Commit 065a586

Browse files
committed
Merge branch 'release/1.2.4'
2 parents 55fb39f + e6dcfca commit 065a586

25 files changed

+1360
-935
lines changed

.eslintrc.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
module.exports = {
22
root: true,
33
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
4-
extends: 'vue',
4+
extends: ['plugin:vue-libs/recommended'],
55
// required to lint *.vue files
6-
env: {
7-
'browser': true,
8-
},
9-
plugins: [
10-
'html'
11-
],
6+
// env: {
7+
// 'browser': true,
8+
// },
129
// add your custom rules here
1310
'rules': {
1411
// allow paren-less arrow functions
15-
'arrow-parens': 0,
16-
// allow debugger during development
17-
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
18-
'comma-dangle': 0,
19-
'no-unused-vars': 1,
20-
'camelcase': 0,
21-
'space-before-function-paren': 0,
12+
// 'arrow-parens': 0,
13+
// // allow debugger during development
14+
// 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
15+
// 'comma-dangle': 0,
16+
// 'no-unused-vars': 1,
17+
// 'camelcase': 0,
18+
// 'space-before-function-paren': 0,
2219
}
2320
}

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ add the following script tags before your code
7676
<script src="https://unpkg.com/vue-types"></script>
7777
```
7878

79+
## Usage with [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue)
80+
81+
When used in a project with [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue), the linter might report errors related to the `vue/require-default-prop` rule.
82+
83+
To prevent that error use [eslint-plugin-vue-types](https://github.com/dwightjack/eslint-plugin-vue-types)
84+
7985
## Documentation
8086

8187
### Native Types

dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ var VueTypes = {
8282
}
8383

8484
return (0, _utils.toType)(validatorFn.name || '<<anonymous function>>', {
85-
validator: function validator() {
86-
var valid = validatorFn.apply(undefined, arguments);
85+
validator: function validator(value) {
86+
var valid = validatorFn(value);
8787
if (!valid) (0, _utils.warn)(this._vueTypes_name + ' - ' + warnMsg);
8888
return valid;
8989
}

es/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ var VueTypes = {
7373
}
7474

7575
return toType(validatorFn.name || '<<anonymous function>>', {
76-
validator: function validator() {
77-
var valid = validatorFn.apply(undefined, arguments);
76+
validator: function validator(value) {
77+
var valid = validatorFn(value);
7878
if (!valid) warn(this._vueTypes_name + ' - ' + warnMsg);
7979
return valid;
8080
}

karma.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const baseConfig = {
4242
// list of files / patterns to load in the browser
4343
files: [
4444
{ pattern: 'src/*.js', included: false },
45-
'test/**/*.spec.js'
45+
'test/**/*.test.js'
4646
],
4747

4848
// list of files to exclude
@@ -54,7 +54,7 @@ const baseConfig = {
5454
preprocessors: {
5555
// add webpack as preprocessor
5656
'src/**/*.js': ['rollup'],
57-
'test/**/*.spec.js': ['rollup']
57+
'test/**/*.test.js': ['rollup']
5858
},
5959

6060
rollupPreprocessor: {

package.json

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-types",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"description": "Prop types utility for Vue",
55
"author": "Marco Solazzi",
66
"license": "MIT",
@@ -9,22 +9,26 @@
99
"unpkg": "umd/vue-types.min.js",
1010
"jsnext:main": "es/index.js",
1111
"module": "es/index.js",
12+
"typings": "types/index.d.ts",
1213
"files": [
1314
"dist",
1415
"es",
1516
"src",
16-
"umd"
17+
"umd",
18+
"types/*.d.ts"
1719
],
1820
"scripts": {
1921
"prepublishOnly": "npm run build",
20-
"build": "npm run lint && npm test && npm run build:cjs && npm run build:es && npm run build:umd",
22+
"build": "npm run lint && npm run test:types && npm test && npm run build:cjs && npm run build:es && npm run build:umd",
2123
"build:cjs": "rimraf dist && cross-env BABEL_ENV=cjs babel ./src -d dist",
2224
"build:es": "rimraf es && cross-env BABEL_ENV=es babel ./src -d es",
2325
"build:umd": "rimraf umd && cross-env BABEL_ENV=rollup rollup -c rollup.config.js",
2426
"test": "cross-env BABEL_ENV=rollup karma start karma.conf.js --single-run --browsers PhantomJS",
2527
"test:all": "cross-env BABEL_ENV=rollup karma start karma.conf.js --single-run --browsers Chrome,Firefox",
2628
"test:saucelab": "cross-env BABEL_ENV=rollup karma start karma-sauce.conf.js --single-run",
29+
"test:types": "tsc -p ./types/test/tsconfig.json",
2730
"lint": "eslint src/*.js test/*.js",
31+
"lint:types": "dtslint types",
2832
"start": "node ./server/index.js"
2933
},
3034
"keywords": [
@@ -40,16 +44,17 @@
4044
"vue": "*"
4145
},
4246
"devDependencies": {
47+
"@types/lodash.isplainobject": "4.0.3",
48+
"@types/node": "10.1.4",
4349
"babel-cli": "6.26.0",
4450
"babel-core": "6.26.3",
4551
"babel-plugin-add-module-exports": "0.2.1",
4652
"babel-plugin-external-helpers": "6.22.0",
4753
"babel-preset-env": "1.7.0",
48-
"cross-env": "5.1.5",
54+
"cross-env": "5.1.6",
55+
"dtslint": "0.3.0",
4956
"eslint": "4.19.1",
50-
"eslint-config-vue": "2.0.2",
51-
"eslint-plugin-html": "4.0.3",
52-
"eslint-plugin-vue": "4.5.0",
57+
"eslint-plugin-vue-libs": "3.0.0",
5358
"expect": "1.20.2",
5459
"express": "4.16.3",
5560
"karma": "2.0.2",
@@ -63,9 +68,9 @@
6368
"karma-rollup-preprocessor": "6.0.0",
6469
"karma-safari-launcher": "1.0.0",
6570
"karma-sauce-launcher": "1.2.0",
66-
"mocha": "5.1.1",
71+
"mocha": "5.2.0",
6772
"rimraf": "2.6.2",
68-
"rollup": "0.58.2",
73+
"rollup": "0.59.4",
6974
"rollup-plugin-babel": "3.0.4",
7075
"rollup-plugin-commonjs": "9.1.3",
7176
"rollup-plugin-filesize": "1.5.0",
@@ -74,9 +79,12 @@
7479
"rollup-plugin-node-resolve": "3.3.0",
7580
"rollup-plugin-replace": "2.0.0",
7681
"rollup-plugin-stub": "1.2.0",
77-
"rollup-plugin-uglify": "3.0.0",
82+
"rollup-plugin-uglify": "4.0.0",
7883
"serve-index": "1.9.1",
79-
"vue": "2.5.16"
84+
"tslint": "5.10.0",
85+
"typescript": "2.8.3",
86+
"vue": "~2.5.0",
87+
"vue-class-component": "~6.2.0"
8088
},
8189
"dependencies": {
8290
"lodash.isplainobject": "4.0.6"

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import commonjs from 'rollup-plugin-commonjs'
22
import resolve from 'rollup-plugin-node-resolve'
33
import babel from 'rollup-plugin-babel'
4-
import uglify from 'rollup-plugin-uglify'
4+
import { uglify } from 'rollup-plugin-uglify'
55
import replace from 'rollup-plugin-replace'
66
import filesize from 'rollup-plugin-filesize'
77

src/index.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,81 @@ import { noop, toType, getType, isFunction, validateType, isInteger, isArray, wa
33

44
const VueTypes = {
55

6-
get any() {
6+
get any () {
77
return toType('any', {
88
type: null
99
})
1010
},
1111

12-
get func() {
12+
get func () {
1313
return toType('function', {
1414
type: Function
1515
}).def(currentDefaults.func)
1616
},
1717

18-
get bool() {
18+
get bool () {
1919
return toType('boolean', {
2020
type: Boolean
2121
}).def(currentDefaults.bool)
2222
},
2323

24-
get string() {
24+
get string () {
2525
return toType('string', {
2626
type: String
2727
}).def(currentDefaults.string)
2828
},
2929

30-
get number() {
30+
get number () {
3131
return toType('number', {
3232
type: Number
3333
}).def(currentDefaults.number)
3434
},
3535

36-
get array() {
36+
get array () {
3737
return toType('array', {
3838
type: Array
3939
}).def(currentDefaults.array)
4040
},
4141

42-
get object() {
42+
get object () {
4343
return toType('object', {
4444
type: Object
4545
}).def(currentDefaults.object)
4646
},
4747

48-
get integer() {
48+
get integer () {
4949
return toType('integer', {
5050
type: Number,
51-
validator(value) {
51+
validator (value) {
5252
return isInteger(value)
5353
}
5454
}).def(currentDefaults.integer)
5555
},
5656

57-
get symbol() {
57+
get symbol () {
5858
return toType('symbol', {
5959
type: null,
60-
validator(value) {
60+
validator (value) {
6161
return typeof value === 'symbol'
6262
}
6363
})
6464
},
6565

66-
custom(validatorFn, warnMsg = 'custom validation failed') {
66+
custom (validatorFn, warnMsg = 'custom validation failed') {
6767
if (typeof validatorFn !== 'function') {
6868
throw new TypeError('[VueTypes error]: You must provide a function as argument')
6969
}
7070

7171
return toType(validatorFn.name || '<<anonymous function>>', {
72-
validator(...args) {
73-
const valid = validatorFn(...args)
72+
validator (value) {
73+
const valid = validatorFn(value)
7474
if (!valid) warn(`${this._vueTypes_name} - ${warnMsg}`)
7575
return valid
7676
}
7777
})
7878
},
7979

80-
oneOf(arr) {
80+
oneOf (arr) {
8181
if (!isArray(arr)) {
8282
throw new TypeError('[VueTypes error]: You must provide an array as argument')
8383
}
@@ -91,21 +91,21 @@ const VueTypes = {
9191

9292
return toType('oneOf', {
9393
type: allowedTypes.length > 0 ? allowedTypes : null,
94-
validator(value) {
94+
validator (value) {
9595
const valid = arr.indexOf(value) !== -1
9696
if (!valid) warn(msg)
9797
return valid
9898
}
9999
})
100100
},
101101

102-
instanceOf(instanceConstructor) {
102+
instanceOf (instanceConstructor) {
103103
return toType('instanceOf', {
104104
type: instanceConstructor
105105
})
106106
},
107107

108-
oneOfType(arr) {
108+
oneOfType (arr) {
109109
if (!isArray(arr)) {
110110
throw new TypeError('[VueTypes error]: You must provide an array as argument')
111111
}
@@ -144,7 +144,7 @@ const VueTypes = {
144144
return getType(type)
145145
}).reduce((ret, type) => ret.concat(isArray(type) ? type : [type]), []).join('", "')
146146

147-
return this.custom(function oneOfType(value) {
147+
return this.custom(function oneOfType (value) {
148148
const valid = arr.some((type) => {
149149
if (type._vueTypes_name === 'oneOf') {
150150
return type.type ? validateType(type.type, value, true) : true
@@ -156,35 +156,35 @@ const VueTypes = {
156156
})
157157
},
158158

159-
arrayOf(type) {
159+
arrayOf (type) {
160160
return toType('arrayOf', {
161161
type: Array,
162-
validator(values) {
162+
validator (values) {
163163
const valid = values.every((value) => validateType(type, value))
164164
if (!valid) warn(`arrayOf - value must be an array of "${getType(type)}"`)
165165
return valid
166166
}
167167
})
168168
},
169169

170-
objectOf(type) {
170+
objectOf (type) {
171171
return toType('objectOf', {
172172
type: Object,
173-
validator(obj) {
173+
validator (obj) {
174174
const valid = Object.keys(obj).every((key) => validateType(type, obj[key]))
175175
if (!valid) warn(`objectOf - value must be an object of "${getType(type)}"`)
176176
return valid
177177
}
178178
})
179179
},
180180

181-
shape(obj) {
181+
shape (obj) {
182182
const keys = Object.keys(obj)
183183
const requiredKeys = keys.filter((key) => obj[key] && obj[key].required === true)
184184

185185
const type = toType('shape', {
186186
type: Object,
187-
validator(value) {
187+
validator (value) {
188188
if (!isPlainObject(value)) {
189189
return false
190190
}
@@ -215,7 +215,7 @@ const VueTypes = {
215215
})
216216

217217
Object.defineProperty(type, 'loose', {
218-
get() {
218+
get () {
219219
this._vueTypes_isLoose = true
220220
return this
221221
},
@@ -241,7 +241,7 @@ let currentDefaults = typeDefaults()
241241

242242
Object.defineProperty(VueTypes, 'sensibleDefaults', {
243243
enumerable: false,
244-
set(value) {
244+
set (value) {
245245
if (value === false) {
246246
currentDefaults = {}
247247
} else if (value === true) {
@@ -250,13 +250,13 @@ Object.defineProperty(VueTypes, 'sensibleDefaults', {
250250
currentDefaults = value
251251
}
252252
},
253-
get() {
253+
get () {
254254
return currentDefaults
255255
}
256256
})
257257

258258
VueTypes.utils = {
259-
validate(value, type) {
259+
validate (value, type) {
260260
return validateType(type, value, true)
261261
},
262262
toType

0 commit comments

Comments
 (0)