mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore(util) lint
This commit is contained in:
parent
697d256730
commit
73e464848f
2 changed files with 9 additions and 46 deletions
|
|
@ -1,51 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
const exec = require('execon');
|
||||
const rendy = require('rendy');
|
||||
const jonny = require('jonny');
|
||||
const itype = require('itype/legacy');
|
||||
|
||||
const Scope = global || window;
|
||||
|
||||
module.exports.getStrBigFirst = getStrBigFirst;
|
||||
module.exports.kebabToCamelCase = kebabToCamelCase;
|
||||
|
||||
/**
|
||||
* copy objFrom properties to target
|
||||
*
|
||||
* @target
|
||||
* @objFrom
|
||||
*/
|
||||
const extend = (target, objFrom) => {
|
||||
const isFunc = itype.function(objFrom);
|
||||
const isArray = Array.isArray(objFrom);
|
||||
const isObj = itype.object(target);
|
||||
let ret = isObj ? target : {};
|
||||
|
||||
if (isArray)
|
||||
objFrom.forEach((item) => {
|
||||
ret = Util.extend(target, item);
|
||||
});
|
||||
|
||||
else if (objFrom) {
|
||||
const obj = isFunc ? new objFrom() : objFrom;
|
||||
let keys = Object.keys(obj);
|
||||
|
||||
if (!keys.length) {
|
||||
const proto = Object.getPrototypeOf(objFrom);
|
||||
keys = Object.keys(proto);
|
||||
}
|
||||
|
||||
keys.forEach((name) => {
|
||||
ret[name] = obj[name];
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
module.exports.extend = extend;
|
||||
|
||||
/**
|
||||
* extend proto
|
||||
*
|
||||
|
|
@ -53,7 +14,7 @@ module.exports.extend = extend;
|
|||
*/
|
||||
module.exports.extendProto = (obj) => {
|
||||
const F = () => {};
|
||||
F.prototype = extend({}, obj);
|
||||
F.prototype = Object.assign({}, obj);
|
||||
return new F();
|
||||
};
|
||||
|
||||
|
|
@ -71,7 +32,9 @@ module.exports.escapeRegExp = (str) => {
|
|||
/**
|
||||
* get regexp from wild card
|
||||
*/
|
||||
module.exports.getRegExp = (wildcard = '*') => {
|
||||
module.exports.getRegExp = (wildcard) => {
|
||||
wildcard = wildcard || '*';
|
||||
|
||||
const escaped = '^' + wildcard // search from start of line
|
||||
.replace('.', '\\.')
|
||||
.replace('*', '.*')
|
||||
|
|
@ -91,7 +54,7 @@ module.exports.exec = exec;
|
|||
* @return ext
|
||||
*/
|
||||
module.exports.getExt = (name) => {
|
||||
const isStr = typeof name === 'string'
|
||||
const isStr = typeof name === 'string';
|
||||
|
||||
if (!isStr)
|
||||
return '';
|
||||
|
|
@ -113,7 +76,7 @@ module.exports.getExt = (name) => {
|
|||
module.exports.findObjByNameInArr = (array, name) => {
|
||||
let ret;
|
||||
|
||||
if (!Array.isArray(array))
|
||||
if (!Array.isArray(array))
|
||||
throw Error('array should be array!');
|
||||
|
||||
if (typeof name !== 'string')
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
"cloudcmd": "bin/cloudcmd.js"
|
||||
},
|
||||
"config": {
|
||||
"dirs": "bin/cloudcmd.js server",
|
||||
"dirs": "bin/cloudcmd.js common server",
|
||||
"dirs_dev": "test bin/release.js webpack.config.js"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
@ -52,8 +52,8 @@
|
|||
"lint": "redrun lint:*",
|
||||
"lint:css": "stylelint css/*.css",
|
||||
"lint:js": "redrun lint:js:*",
|
||||
"lint:js:eslint:server": "eslint --rule 'no-console:0' -c .eslintrc.server $npm_package_config_dirs",
|
||||
"lint:js:eslint:dev": "eslint --rule 'no-console:0' $npm_package_config_dirs_dev",
|
||||
"lint:js:server": "eslint --rule 'no-console:0' -c .eslintrc.server $npm_package_config_dirs",
|
||||
"lint:js:dev": "eslint --rule 'no-console:0' $npm_package_config_dirs_dev",
|
||||
"lint:js:jshint": "jshint bin client server",
|
||||
"lint:js:jscs": "jscs --esnext $npm_package_config_dirs",
|
||||
"lint:js:eslint:client": "eslint --rule 'no-console:0' --env browser client",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue