-
Textarea classification
-
-
Textarea
-
+
+
Textarea classification
+
+
Textarea
+
+
-
diff --git a/package.json b/package.json
index f965c79..81e28df 100644
--- a/package.json
+++ b/package.json
@@ -51,6 +51,7 @@
"@vue/cli-plugin-eslint": "^4.3.1",
"@vue/cli-service": "^4.5.4",
"@vue/component-compiler-utils": "^3.1.2",
+ "@vue/eslint-config-standard": "^5.1.2",
"@vue/test-utils": "^1.0.2",
"autoprefixer": "^9.7.6",
"babel-core": "^7.0.0-bridge.0",
diff --git a/src/FileUpload.js b/src/FileUpload.js
index 02420ea..cf2226a 100644
--- a/src/FileUpload.js
+++ b/src/FileUpload.js
@@ -1,5 +1,6 @@
import nanoid from 'nanoid/non-secure'
+// noinspection JSUnusedGlobalSymbols
/**
* The file upload class holds and represents a file’s upload state durring
* the upload flow.
@@ -7,8 +8,9 @@ import nanoid from 'nanoid/non-secure'
class FileUpload {
/**
* Create a file upload object.
- * @param {FileList} fileList
+ * @param {FileList} input
* @param {object} context
+ * @param {object} options
*/
constructor (input, context, options = {}) {
this.input = input
@@ -27,7 +29,6 @@ class FileUpload {
/**
* Given a pre-existing array of files, create a faux FileList.
* @param {array} items expects an array of objects [{ url: '/uploads/file.pdf' }]
- * @param {string} pathKey the object-key to access the url (defaults to "url")
*/
rehydrateFileList (items) {
const fauxFileList = items.reduce((fileList, item) => {
@@ -48,15 +49,12 @@ class FileUpload {
/**
* Produce an array of files and alert the callback.
- * @param {FileList}
+ * @param {FileList} fileList
*/
addFileList (fileList) {
for (let i = 0; i < fileList.length; i++) {
const file = fileList[i]
const uuid = nanoid()
- const removeFile = function () {
- this.removeFile(uuid)
- }
this.files.push({
progress: false,
error: false,
@@ -66,7 +64,7 @@ class FileUpload {
file,
uuid,
path: false,
- removeFile: removeFile.bind(this),
+ removeFile: () => this.removeFile(uuid),
previewData: file.previewData || false
})
}
@@ -86,16 +84,11 @@ class FileUpload {
* https://github.com/axios/axios/issues/737
*/
uploaderIsAxios () {
- if (
- this.hasUploader &&
+ return this.hasUploader &&
typeof this.context.uploader.request === 'function' &&
typeof this.context.uploader.get === 'function' &&
typeof this.context.uploader.delete === 'function' &&
typeof this.context.uploader.post === 'function'
- ) {
- return true
- }
- return false
}
/**
diff --git a/src/Formulario.js b/src/Formulario.js
index 58b6780..1a9ff33 100644
--- a/src/Formulario.js
+++ b/src/Formulario.js
@@ -3,13 +3,15 @@ import rules from './libs/rules'
import mimes from './libs/mimes'
import FileUpload from './FileUpload'
import RuleValidationMessages from './RuleValidationMessages'
-import { arrayify, parseLocale, has } from './libs/utils'
+import { arrayify } from './libs/utils'
import isPlainObject from 'is-plain-object'
import fauxUploader from './libs/faux-uploader'
+
import FormularioForm from './FormularioForm.vue'
import FormularioInput from './FormularioInput.vue'
import FormularioGrouping from './FormularioGrouping.vue'
+// noinspection JSUnusedGlobalSymbols
/**
* The base formulario library.
*/
@@ -23,7 +25,7 @@ class Formulario {
components: {
FormularioForm,
FormularioInput,
- FormularioGrouping,
+ FormularioGrouping
},
library,
rules,
@@ -34,7 +36,7 @@ class Formulario {
fileUrlKey: 'url',
uploadJustCompleteDuration: 1000,
errorHandler: (err) => err,
- plugins: [ RuleValidationMessages ],
+ plugins: [RuleValidationMessages],
validationMessages: {},
idPrefix: 'formulario-'
}
@@ -48,14 +50,16 @@ class Formulario {
install (Vue, options) {
Vue.prototype.$formulario = this
this.options = this.defaults
- var plugins = this.defaults.plugins
+ let plugins = this.defaults.plugins
if (options && Array.isArray(options.plugins) && options.plugins.length) {
- plugins = plugins.concat(options.plugins)
+ plugins = plugins.concat(options.plugins)
}
plugins.forEach(plugin => (typeof plugin === 'function') ? plugin(this) : null)
this.extend(options || {})
- for (var componentName in this.options.components) {
- Vue.component(componentName, this.options.components[componentName])
+ for (const componentName in this.options.components) {
+ if (Object.prototype.hasOwnProperty.call(this.options.components, componentName)) {
+ Vue.component(componentName, this.options.components[componentName])
+ }
}
}
@@ -95,9 +99,10 @@ class Formulario {
* @param {boolean} concatArrays
*/
merge (base, mergeWith, concatArrays = true) {
- var merged = {}
- for (var key in base) {
- if (mergeWith.hasOwnProperty(key)) {
+ const merged = {}
+
+ for (const key in base) {
+ if (Object.prototype.hasOwnProperty.call(mergeWith, key)) {
if (isPlainObject(mergeWith[key]) && isPlainObject(base[key])) {
merged[key] = this.merge(base[key], mergeWith[key], concatArrays)
} else if (concatArrays && Array.isArray(base[key]) && Array.isArray(mergeWith[key])) {
@@ -109,11 +114,13 @@ class Formulario {
merged[key] = base[key]
}
}
- for (var prop in mergeWith) {
- if (!merged.hasOwnProperty(prop)) {
+
+ for (const prop in mergeWith) {
+ if (!Object.prototype.hasOwnProperty.call(merged, prop)) {
merged[prop] = mergeWith[prop]
}
}
+
return merged
}
@@ -122,9 +129,10 @@ class Formulario {
* @param {string} type
*/
classify (type) {
- if (this.options.library.hasOwnProperty(type)) {
+ if (Object.prototype.hasOwnProperty.call(this.options.library, type)) {
return this.options.library[type].classification
}
+
return 'unknown'
}
@@ -133,9 +141,10 @@ class Formulario {
* @param {string} type
*/
component (type) {
- if (this.options.library.hasOwnProperty(type)) {
+ if (Object.prototype.hasOwnProperty.call(this.options.library, type)) {
return this.options.library[type].component
}
+
return false
}
@@ -151,16 +160,16 @@ class Formulario {
* Get the validation message for a particular error.
*/
validationMessage (rule, validationContext, vm) {
- if (this.options.validationMessages.hasOwnProperty(rule)) {
+ if (Object.prototype.hasOwnProperty.call(this.options.validationMessages, rule)) {
return this.options.validationMessages[rule](vm, validationContext)
} else {
- return this.options.validationMessages['default'](vm, validationContext)
+ return this.options.validationMessages.default(vm, validationContext)
}
}
/**
* Given an instance of a FormularioForm register it.
- * @param {vm} form
+ * @param {Vue} form
*/
register (form) {
if (form.$options.name === 'FormularioForm' && form.name) {
@@ -170,7 +179,7 @@ class Formulario {
/**
* Given an instance of a form, remove it from the registry.
- * @param {vm} form
+ * @param {Vue} form
*/
deregister (form) {
if (
@@ -188,7 +197,7 @@ class Formulario {
*
* @param {error} err
* @param {string} formName
- * @param {error}
+ * @param {boolean} skip
*/
handle (err, formName, skip = false) {
const e = skip ? err : this.options.errorHandler(err, formName)
diff --git a/src/FormularioFiles.vue b/src/FormularioFiles.vue
index fd0b03d..83230df 100644
--- a/src/FormularioFiles.vue
+++ b/src/FormularioFiles.vue
@@ -16,13 +16,16 @@
>
+