Skip to content

Commit

Permalink
格式🌈(elint): 格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
bubao committed Nov 26, 2019
1 parent 7ee2848 commit c371f81
Show file tree
Hide file tree
Showing 29 changed files with 619 additions and 1,196 deletions.
41 changes: 41 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"root": true,
"env": {
"es6": true,
"node": true
},
"extends": [
"standard",
"prettier",
"plugin:node/recommended"
],
"plugins": [
"standard",
"prettier"
],
"rules": {
"prettier/prettier": "error",
"semi": [
2,
"always"
],
"quotes": [
2,
"double"
],
"no-multiple-empty-lines": "error",
"no-var": "error",
"no-template-curly-in-string": "off",
"node/no-deprecated-api": "off",
"camelcase": "off",
"no-bitwise": "off",
"no-case-declarations": "off",
"no-new": "off",
"new-cap": "off",
"no-unmodified-loop-condition": "off",
"no-loop-func": "off",
"prefer-promise-reject-errors": "off",
"node/no-unsupported-features/es-syntax": "off",
"standard/no-callback-literal": "off"
}
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ env.json

.idea/

package-lock.json
package-lock.json

yarn.lock
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"eslintIntegration": true,
"stylelintIntegration": true,
"tabWidth": 4,
"useTabs": true,
"singleQuote": false,
"semi": true,
"trailingComma": "none",
"bracketSpacing": true,
"arrowParens": "avoid",
"endOfLine": "lf"
}
23 changes: 23 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"workbench.colorCustomizations": {
"tab.unfocusedActiveBorder": "#4391c5"
},
// "prettier.trailingComma": "none",
// "prettier.endOfLine": "lf",
// "prettier.semi": true,
// 是否开启eslint检测
"eslint.enable": true,
// 文件保存时是否根据eslint进行格式化
"eslint.autoFixOnSave": true,
"eslint.run": "onType",
// "workbench.iconTheme": "material-icon-theme",
// "workbench.colorTheme": "Darcula Theme from IntelliJ",
"files.eol": "\n",
// "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
// "window.zoomLevel": 1,
"line-counter.excludes": [
// "**/.vscode/**",
"**/node_modules/**"
],
"editor.tabSize": 4
}
7 changes: 7 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"subject-empty": [0, "always"],
"type-empty": [0, "always"]
}
};
50 changes: 50 additions & 0 deletions config/cz-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
types: [
{ value: "特性✨", name: "特性: 一个新的特性" },
{ value: "修复🐛", name: "修复: 修复一个Bug" },
{ value: "文档📚", name: "文档: 变更的只有文档" },
{ value: "格式🌈", name: "格式: 空格, 分号等格式修复" },
{ value: "重构⛑", name: "重构: 代码重构,注意和特性、修复区分开" },
{ value: "性能🕑", name: "性能: 提升性能" },
{ value: "测试☕", name: "测试: 添加一个测试" },
{ value: "工具⛏", name: "工具: 开发工具变动(构建、脚手架工具等)" },
{ value: "回滚🔙", name: "回滚: 代码回退" }
],

scopes: [
{ name: "模块1" },
{ name: "模块2" },
{ name: "模块3" },
{ name: "模块4" }
],

// it needs to match the value for field type. Eg.: 'fix'
/*
scopeOverrides: {
fix: [
{name: 'merge'},
{name: 'style'},
{name: 'e2eTest'},
{name: 'unitTest'}
]
},
*/
// override the messages, defaults are as follows
messages: {
type: "选择一种你的提交类型:",
scope: "选择一个scope (可选):",
// used if allowCustomScopes is true
customScope: "Denote the SCOPE of this change:",
subject: "短说明:\n",
body: "长说明,使用|换行(可选):\n",
breaking: "非兼容性说明 (可选):\n",
footer: "关联关闭的issue,例如:#31, #34(可选):\n",
confirmCommit: "确定提交说明?"
},

allowCustomScopes: true,
allowBreakingChanges: ["特性", "修复"],

// limit subject length
subjectLimit: 100
};
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
* @Last Modified time: 2018-06-11 10:31:47
*/

const api = require('./src/api');
const api = require("./src/api");

module.exports = api;
module.exports = api;
39 changes: 37 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,44 @@
"dependencies": {
"better-console": "^1.0.1",
"cheerio": "^1.0.0-rc.2",
"lodash": "^4.17.10",
"lodash": "^4.17.15",
"ora": "^2.1.0",
"request": "^2.86.0",
"request": "^2.88.0",
"turndown": "^4.0.2"
},
"devDependencies": {
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"commitizen": "^4.0.3",
"cz-customizable": "^6.2.0",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.7.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"husky": "^2.2.0",
"prettier": "^1.17.0",
"pretty-quick": "^1.10.0"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged",
"pre-push": "pretty-quick --staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"config": {
"commitizen": {
"path": "node_modules/cz-customizable"
},
"cz-customizable": {
"config": "config/cz-config.js"
}
},
"engines": {
"node": ">=8.3.0"
}
}
6 changes: 3 additions & 3 deletions src/api/Answer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @author bubao
* @description
* @date: 2018-05-17 13:47:58
* @author bubao
* @description
* @date: 2018-05-17 13:47:58
* @Last Modified by: bubao
* @Last Modified time: 2018-05-17 13:59:29
*/
31 changes: 16 additions & 15 deletions src/api/Post.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* @Last Modified time: 2018-06-11 11:51:18
*/

const { request } = require('../config/commonModules');
const API = require('../config/api');
const assign = require('lodash/assign');
const template = require('lodash/template');
const { loopMethod, rateMethod } = require('../config/utils');
const { request } = require("../config/commonModules");
const API = require("../config/api");
const assign = require("lodash/assign");
const template = require("lodash/template");
const { loopMethod, rateMethod } = require("../config/utils");

/**
* 通用方法
Expand All @@ -27,37 +27,38 @@ const universalMethod = async (ID, API, countName, infoMethod) => {
assign(
{
options: {
urlTemplate,
urlTemplate
}
},
rateMethod(count, 20)
), resolve);
),
resolve
);
});

};

/**
* 知乎专栏信息
* @param {string} columnsID //专栏ID
*/
const info = async (columnsID) => {
const info = async columnsID => {
const urlTemplate = template(API.post.columns)({ columnsID });
let object = {};
object = {
url: urlTemplate,
gzip: true,
gzip: true
};
return JSON.parse((await request(object)).body);
}
};
/**
* 专栏所有post
* @param {string} columnsID 专栏ID
*/
const posts = (columnsID) => {
return universalMethod(columnsID, API.post.page, 'postsCount', info);
const posts = columnsID => {
return universalMethod(columnsID, API.post.page, "postsCount", info);
};

module.exports = {
info,
posts,
}
posts
};
10 changes: 5 additions & 5 deletions src/api/Question.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @author bubao
* @description
* @date: 2018-05-17 13:48:39
* @Last Modified by: bubao
* @Last Modified time: 2018-05-17 13:48:39
* @author bubao
* @description
* @date: 2018-05-17 13:48:39
* @Last Modified by: bubao
* @Last Modified time: 2018-05-17 13:48:39
*/
Loading

0 comments on commit c371f81

Please sign in to comment.