apply linter

This commit is contained in:
Simon Vieille 2023-03-31 17:53:24 +02:00
parent e9cb85c695
commit 5130a96edc
Signed by: deblan
GPG key ID: 579388D585F70417
6 changed files with 76 additions and 76 deletions

View file

@ -3,56 +3,56 @@
var Minimist = require('minimist');
class Input {
/**
* Constructor.
*
* @param object process
*/
constructor(process) {
this.args = Minimist(process.argv.slice(2))
this.node = process.argv[0]
this.script = process.argv[1]
/**
* Constructor.
*
* @param object process
*/
constructor(process) {
this.args = Minimist(process.argv.slice(2))
this.node = process.argv[0]
this.script = process.argv[1]
}
/**
* Return the value of the given name argument.
*
* @param string name
* @param mixed default
*
* @return mixed
*/
get(name, defaultValue) {
if (this.has(name)) {
return this.args[name]
}
/**
* Return the value of the given name argument.
*
* @param string name
* @param mixed default
*
* @return mixed
*/
get(name, defaultValue) {
if (this.has(name)) {
return this.args[name]
}
if (defaultValue !== undefined) {
return defaultValue
}
return null;
if (defaultValue !== undefined) {
return defaultValue
}
/**
* Check the given argument name exists.
*
* @param string name
*
* @return boolean
*/
has(name) {
return this.args.hasOwnProperty(name)
}
return null;
}
/**
* Return if args is empty.
*
* @return boolean
*/
empty() {
return Object.keys(this.args).length === 1
}
/**
* Check the given argument name exists.
*
* @param string name
*
* @return boolean
*/
has(name) {
return this.args.hasOwnProperty(name)
}
/**
* Return if args is empty.
*
* @return boolean
*/
empty() {
return Object.keys(this.args).length === 1
}
}
module.exports = Input

View file

@ -1,37 +1,37 @@
"use strict";
class Output {
/**
* Convert and print data to json.
*
* @param mixed data
*/
json(data, pretty) {
data = JSON.stringify(
data,
function(key, value) {
if (value === undefined) {
return null
}
/**
* Convert and print data to json.
*
* @param mixed data
*/
json(data, pretty) {
data = JSON.stringify(
data,
function(key, value) {
if (value === undefined) {
return null
}
return value
},
pretty ? 2 : null
);
return value
},
pretty ? 2 : null
);
return this.write(data)
}
return this.write(data)
}
/**
* Print data.
*
* @param mixed data
*/
write(data, level) {
level = level || 'log'
/**
* Print data.
*
* @param mixed data
*/
write(data, level) {
level = level || 'log'
console[level](data)
}
console[level](data)
}
}
module.exports = Output

View file

@ -1,5 +1,5 @@
const filter = function(value) {
return value.replace(/(\n|\r)/g, '')
return value.replace(/(\n|\r)/g, '')
}
module.exports = filter

View file

@ -1,5 +1,5 @@
const filter = function(value) {
return value.replace(/\s{2,}/g, ' ')
return value.replace(/\s{2,}/g, ' ')
}
module.exports = filter

View file

@ -1,7 +1,7 @@
const striptags = require('striptags')
const filter = function(value, tags) {
return striptags(value, tags)
return striptags(value, tags)
}
module.exports = filter

View file

@ -1,7 +1,7 @@
const trim = require('trim')
const filter = function(value) {
return trim(value)
return trim(value)
}
module.exports = filter