Skip to content

Commit

Permalink
chore: use alloy eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
timcui committed May 28, 2018
1 parent fe3b358 commit fe5eec3
Show file tree
Hide file tree
Showing 139 changed files with 4,061 additions and 3,871 deletions.
39 changes: 38 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"extends": "eslint-config-alloy",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2017
Expand Down Expand Up @@ -79,6 +79,36 @@
],
"prefer-const": [
"warn"
],
"no-param-reassign": [
"off"
],
"no-template-curly-in-string": [
"off"
],
"one-var": [
"off"
],
"guard-for-in": [
"off"
],
"no-undefined": [
"off"
],
"complexity": [
"off"
],
"max-nested-callbacks": [
"off"
],
"no-path-concat": [
"off"
],
"eqeqeq": [
"off"
],
"max-depth": [
"off"
]
},
"overrides": [
Expand All @@ -90,6 +120,13 @@
"globals": {
"define": true
}
}, {
"files": ["bin/tsw/util/auto-report/tmpl.js"],
"rules": {
"no-inner-declarations": [
"off"
]
}
}, {
"files": ["bin/lib/util/mail/tmpl.js", "bin/tsw/util/**/tmpl.js"],
"rules": {
Expand Down
4 changes: 2 additions & 2 deletions bin/lib/api/cmdb/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
/* !
* Tencent is pleased to support the open source community by making Tencent Server Web available.
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';


const Deferred = require('util/Deferred');

Expand Down
6 changes: 3 additions & 3 deletions bin/lib/api/code/watcher.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*!
/* !
* Tencent is pleased to support the open source community by making Tencent Server Web available.
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';


this.watch = function() {


};
4 changes: 2 additions & 2 deletions bin/lib/api/habo/habo.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
/* !
* Tencent is pleased to support the open source community by making Tencent Server Web available.
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';


module.exports.report = function(obj, rate) {

Expand Down
84 changes: 42 additions & 42 deletions bin/lib/api/keyman/alphaMap.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
/* !
* Tencent is pleased to support the open source community by making Tencent Server Web available.
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';


const Deferred = require('util/Deferred');
const logger = require('logger');
Expand All @@ -21,32 +21,32 @@ let cache = {
dataFile: {}
};

if(global[__filename]) {
if (global[__filename]) {
cache = global[__filename];
}else{
} else {
global[__filename] = cache;
isFirstLoad = true;
}


if(isFirstLoad) {
if(config.alphaFile) {
if (isFirstLoad) {
if (config.alphaFile) {

(function() {
//导入alphaFile
// 导入alphaFile
let text = '';

try{
try {
text = fs.readFileSync(config.alphaFile, 'UTF-8');
}catch(e) {
} catch (e) {
logger.warn(e.stack);
}

if(!text) {
if (!text) {
return;
}

if(text.length >= 2 * 1024 * 1024) {
if (text.length >= 2 * 1024 * 1024) {
logger.error('alpha file limit <=2M');
return;
}
Expand All @@ -55,7 +55,7 @@ if(isFirstLoad) {
updateMap();
})();

}else{
} else {
logger.debug('config.alphaFile is: ' + config.alphaFile);
}
}
Expand All @@ -78,7 +78,7 @@ function updateMap(text) {

const map = getMap(text);

//copy
// copy
Object.assign(map, cache.dataFile);

cache.data = map;
Expand All @@ -89,48 +89,48 @@ function updateMap(text) {

this.getSync = function() {
this.get();

return cache.data;
};

this.get = function() {

const defer = Deferred.create();
const delay = (process.serverInfo && process.serverInfo.cpu * 1000) || 0;
const l5api = config.tswL5api['alphaFileUrl'];

if(Date.now() - cache.timeUpdate < 60000 + delay) {
if (Date.now() - cache.timeUpdate < 60000 + delay) {
return defer.resolve(cache.data);
}

cache.timeUpdate = Date.now();

if(!fileUrl) {
if (!fileUrl) {
return defer.resolve(cache.data);
}

fileCache.getAsync(fileUrl).done(function(d) {

let lastModifyTime = 0;
let text = '';
if(d && d.stats) {

if (d && d.stats) {
lastModifyTime = d.stats.mtime.getTime();
}
if(d && d.data) {

if (d && d.data) {
text = d.data.toString('utf-8');
}
if(Date.now() - lastModifyTime < 60000) {

if (Date.now() - lastModifyTime < 60000) {
logger.debug('使用本地文件');

updateMap(text);

defer.resolve(cache.data);
return;
}

require('ajax').request({
url: fileUrl,
type: 'get',
Expand All @@ -146,29 +146,29 @@ this.get = function() {
}).fail(function(d) {
defer.resolve(cache.data);
}).done(function(d) {

let text = '';
if(d && d.result && typeof d.result === 'string') {

if (d && d.result && typeof d.result === 'string') {

text = d.result;
}

if(text.length >= 2 * 1024 * 1024) {
if (text.length >= 2 * 1024 * 1024) {
logger.error('alpha file limit <=2M');
return defer.resolve(cache.data);
}

updateMap(text);
//保存在本地

// 保存在本地
fileCache.set(fileUrl, Buffer.from(text, 'UTF-8'));

defer.resolve(cache.data);
});
});


return defer;
};

Expand All @@ -178,11 +178,11 @@ function init() {
let buffer = null;
let text = '';

if(fileUrl) {
if (fileUrl) {
buffer = fileCache.getSync(fileUrl).data;
}

if(buffer) {
if (buffer) {
text = buffer.toString('utf-8');
updateMap(text);
}
Expand Down
Loading

0 comments on commit fe5eec3

Please sign in to comment.