Skip to content

Commit 9e4d75f

Browse files
微信公众号:储凡mmdapl
andauthored
fix: 基于Eslint规则修复一些文档格式问题 (#170)
* fix: 基于`Eslint`规则修复一些文档问题 * chore: update --------- Co-authored-by: chufan <mmdapl@163.com>
1 parent 520b21c commit 9e4d75f

File tree

26 files changed

+91
-55
lines changed

26 files changed

+91
-55
lines changed

code/algorithm/mergeLink.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,4 @@ last.next = new ListNode(4)
6666
last.next.next = new ListNode(6)
6767
console.log('last:', last)
6868
console.log(Merge(pre, last))
69-
module.exports = {
70-
Merge,
71-
}
69+
console.log(Merge1(pre, last))

code/algorithm/sword-point/isPopOrder.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
* @param popV
55
*/
66
function IsPopOrder(pushV, popV) {
7+
console.log(pushV, popV)
78
}
9+
10+
console.log(IsPopOrder)

code/algorithm/sword-point/permutation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function Permutation(str) {
1+
export function Permutation(str) {
22
const result = []
33
const i = 0
44
while (i < str.length) {

code/algorithm/sword-point/reOrderArray.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
*/
1616
function reOrderArray(array) {
1717
// 奇数,偶数;
18-
const oddArr = []; const evenArr = []
18+
const oddArr = []
19+
const evenArr = []
1920
for (let index = 0; index < array.length; index++) {
2021
if (array[index] % 2 !== 0) {
2122
// 奇数

code/design-patterns/lsp-demo.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* 里氏替换原则Demo
33
*/
44

5-
namespace LspDemoFather{
5+
// eslint-disable-next-line ts/no-namespace
6+
namespace LspDemoFather {
67
export class Rectangle {
78
protected width: number
89
protected height: number
@@ -24,13 +25,15 @@ namespace LspDemoFather{
2425
return this.width * this.height
2526
}
2627
}
28+
2729
export function printArea(rectangle: Rectangle): void {
2830
rectangle.setWidth(4)
2931
rectangle.setHeight(5)
3032
console.log(`Area: ${rectangle.getArea()}`)
3133
}
3234
}
3335

36+
// eslint-disable-next-line unused-imports/no-unused-vars,ts/no-namespace
3437
namespace LspDemo {
3538
import Rectangle = LspDemoFather.Rectangle
3639
import printArea = LspDemoFather.printArea

code/express/apps/error-handle-demo/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const app = express()
44
const port = 4000
55
const appName = require('./package.json').name
66

7-
app.get('/', async (req, res) => {
7+
app.get('/', async (_req, _res) => {
88
console.log('请求进来了...')
99
throw new Error('手动抛错了!!')
1010
})

code/express/apps/static-source-demo/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ app.use('/static', express.static('public'))
7373

7474
服务启动后,在浏览器中访问:
7575

76-
```js
76+
```textmate
7777
http://localhost:3000/static/css/style.css
7878
http://localhost:3000/static/js/app.js
7979
http://localhost:3000/static/images/bg.png

code/express/apps/static-source-demo/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const express = require('express')
22

33
const app = express()
4+
// eslint-disable-next-line import/order
45
const path = require('node:path')
56
// 服务启动端口
67
const port = 3000

code/express/apps/template-demo/app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ app.use((req, res, next) => {
3333
/**
3434
* 错误处理中间件
3535
*/
36-
app.use((err, req, res, next) => {
36+
app.use((err, req, res, _next) => {
3737
res.locals.message = err.message
3838
res.locals.error = req.app.get('env') === 'development' ? err : {}
3939

@@ -58,10 +58,12 @@ server.on('error', (error) => {
5858
switch (error.code) {
5959
case 'EACCES':
6060
console.error(`${bind} requires elevated privileges`)
61+
// eslint-disable-next-line node/prefer-global/process
6162
process.exit(1)
6263
break
6364
case 'EADDRINUSE':
6465
console.error(`${bind} is already in use`)
66+
// eslint-disable-next-line node/prefer-global/process
6567
process.exit(1)
6668
break
6769
default:

code/express/apps/template-demo/routes/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ const express = require('express')
33
const router = express.Router()
44

55
/* GET home page. */
6-
router.get('/', (req, res, next) => {
7-
res.render('index', { title: 'Express' })
6+
router.get('/', (req, res, _next) => {
7+
res.render('index', {
8+
title: 'Express',
9+
})
810
})
911

1012
module.exports = router

code/koa/koa-listen.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line import/order
12
const Koa = require('koa')
23

34
const app = new Koa()

code/koa/koa-response.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ app.use(async (ctx, next) => {
1212
if (!body || body.pipe)
1313
return
1414

15+
// eslint-disable-next-line node/prefer-global/buffer
1516
if (Buffer.isBuffer(body))
1617
body = body.toString()
1718
ctx.body = minify(body)

code/node/es6/es5-2009-lastIndexOf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const stu = ['Tom', 'Lisa', '142vip']
1+
const stu: string[] = ['Tom', 'Lisa', '142vip']
22

33
// 输出 2,数组中角标为2对应的就是142vip
44
console.log(stu.lastIndexOf('142vip'))

code/node/es6/es5-2009-reduceRight.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
const nums = [12, 14, 33, 25, 28]
22

3-
const reuslt = 1
4-
53
nums.reduceRight()

code/node/es6/es6-2015-map.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ studentAgeMap.set('fairy', 24)
1616
* 根据映射关键字获取值
1717
*/
1818
const age = studentAgeMap.get('fairy')
19+
// 打印
20+
console.log(age)
1921

2022
/**
2123
* 返回集合中元素个数
2224
*/
2325
const size = studentAgeMap.size
26+
console.log(size)
2427

2528
/**
2629
* 根据键删除映射关系
@@ -40,11 +43,15 @@ studentAgeMap.clear()
4043
* 判断类型,返回对象object
4144
*/
4245
const mapType = typeof studentAgeMap
46+
// 打印
47+
console.log(mapType)
4348

4449
/**
4550
* 判断实例,返回true
4651
*/
4752
const isMap = studentAgeMap instanceof Map
53+
// 打印
54+
console.log(isMap)
4855

4956
/**
5057
* 循环处理

code/node/es6/es6-2015-set.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
*/
44
const stuSet = new Set([1, 2, 3])
55

6+
// 打印
7+
console.log(stuSet)
8+
69
/**
710
* 利用add()方法创建Set集合
811
*/

code/node/lodash/demo-set.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ const userList = [
4444
{ user: 'barney', age: 36, active: true },
4545
{ user: 'fred', age: 40, active: false },
4646
]
47-
console.log(_.filter(userList, (o) => { return !o.active }))
47+
console.log(_.filter(userList, (o) => {
48+
return !o.active
49+
}))
4850
// => objects for ['fred']
4951
// The `_.matches` iteratee shorthand.
5052
console.log(_.filter(userList, { age: 36, active: true }))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
const { DataTypes } = require('sequelize')
2+
3+
console.log(DataTypes)

docs/README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ actions:
1818
features:
1919
- title: SOLO算法
2020
details: 习题整理,代码通过记录,个人实际解题思路,助力刷题通关
21-
link: /solo-algorithm
21+
link: /solo-algorithm/
2222
- title: Battle面试官
2323
details: 校招社招八股文集合,分享面经与常见面试题,总结面试套路、经验,对线、Battle面试官丝毫不慌
24-
link: /battle-interview
24+
link: /battle-interview/
2525
- title: 前端
2626
details: 熟练前端基础知识、常用框架,总结、提炼前端部署方案
27-
link: /front-end
27+
link: /front-end/
2828
- title: 后端
2929
details: 夯实基础、熟练使用框架,有一定封装能力。造轮子、定制化插件功能,保姆级开发、部署流程
30-
link: /server-end
30+
link: /server-end/
3131
- title: 微服务
3232
details: 网关、服务间调用、ELK、消息中间件等对开发有更高要求,学习技术无止境
33-
link: /microservice
33+
link: /microservice/
3434
- title: 开发技巧
3535
details: 知识很重要,技巧不可缺。汇总日常软件安装、基础编译、代码管理等琐碎小技巧
36-
link: /develop-skill
36+
link: /develop-skill/
3737
- title: 读书写作
3838
details: 代码虽好,读书提升更为重要,不可偏执一端。人文社科、生活百态都是职场、人生的软技能
39-
link: /read-books
39+
link: /read-books/
4040
- title: 自媒体
4141
details: 尝试尝试再尝试,等等我呀。一路磕磕绊绊,自认并无天赋,辛酸、冷暖自知。 做好当下,便是不辜负自己
4242
link: /wechat-list.html
@@ -48,7 +48,9 @@ features:
4848
## 本地浏览【推荐】
4949

5050
由于平台、网络等原因,在线浏览容易出现加载面、加载不出来等常见问题,因此非常建议在本地进行浏览、学习。
51-
**下面指令默认你已经安装[Git](https://git-scm.com/download)[NPM](https://www.npmjs.com/)[PNPM](https://www.pnpm.cn/)[Yarn](https://yarn.bootcss.com/)[Node](http://nodejs.cn)等环境,并对此有一定了解!**
51+
52+
- \*下面指令默认你已经安装[Git](https://git-scm.com/download)[NPM](https://www.npmjs.com/)[PNPM](https://www.pnpm.cn/)[Yarn](https://yarn.bootcss.com/)[Node](http://nodejs.cn)
53+
等环境,并对此有一定了解!\*\*
5254

5355
::: code-tabs#shell
5456
@tab PNPM(推荐)

docs/front-end/base-begin/javascript.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,24 @@ son.money()
129129

130130
```js
131131
// 利用new Object() 创建对象
132-
let obj = new Object();
132+
const obj1 = new Object()
133133

134134
// 利用对象字面量创建对象
135-
let obj = {}
135+
const obj2 = {}
136136

137137
// 利用构造函数创建对象
138-
function creatObj(name, sex) {
139-
this.name = name;
140-
this.sex = sex;
138+
function CreatObj(name, sex) {
139+
this.name = name
140+
this.sex = sex
141141
this.test = function () {
142142
console.log('xxxx')
143143
}
144144
}
145145

146146
// 创建
147-
let obj = new creatObj('xxx', 'xx');
147+
const obj = new CreatObj('xxx', 'xx')
148148
// 使用
149-
obj.test();
149+
obj.test()
150150
```
151151

152152
**构造函数是一种特殊的函数,主要用来初始化对象,即为对象成员变量赋初始值,总是与new一起使用。
@@ -201,7 +201,7 @@ creatObj.prototype.test = function () {
201201

202202
```js
203203
// 实例化对象中的_proto对象原型 和 构造函数中的原型对象prototype是等价的 输出结构为:true;
204-
console.log(obj.__proto__ === creatObj.prototype)
204+
// console.log(obj.__proto__ === creatObj.prototype)
205205
```
206206

207207
### 构造函数
@@ -323,6 +323,7 @@ const fn = function () {
323323
```js
324324
// 利用Function构造函数 【所有函数都是Function的实例】
325325
const fn = new Function('a', 'b', 'return a+b')
326+
console.log(fn)
326327
```
327328

328329
### 调用方式
@@ -357,7 +358,9 @@ function Fn() {
357358
// ...
358359
}
359360

360-
new Fn()
361+
const fn = new Fn()
362+
363+
console.log(fn)
361364

362365
// 绑定事件函数(例如:按钮点击事件)
363366
button.onclick = function () {
@@ -369,10 +372,10 @@ setInterval(() => {
369372
// ....
370373
}, 1000)
371374

372-
// 立即执行函数(自动调用)
373-
(() => {
374-
// .....
375-
})()
375+
// 立即执行函数(自动调用)
376+
(() => {
377+
// .....
378+
})()
376379
```
377380

378381
### 内部的this指向
@@ -546,6 +549,7 @@ fn()
546549
```js
547550
function fn() {
548551
const num = 10
552+
console.log(num)
549553

550554
// 函数内部定义函数
551555
function fun() {

docs/server-end/database/redis/哨兵模式.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ Redis的Sentinel系统是一个分布式的系统,可以在系统中配置一
4040

4141
- redis-sentinel-26380配置文件
4242

43-
@[code conf](@code/redis/sentinel/conf/redis-sentinel-26380.conf)
43+
@[code nginx](@code/redis/sentinel/conf/redis-sentinel-26380.conf)
4444

4545
- redis-sentinel-26381配置文件
4646

47-
@[code conf](@code/redis/sentinel/conf/redis-sentinel-26381.conf)
47+
@[code nginx](@code/redis/sentinel/conf/redis-sentinel-26381.conf)
4848

4949
- redis-sentinel-26382配置文件
5050

51-
@[code conf](@code/redis/sentinel/conf/redis-sentinel-26382.conf)
51+
@[code nginx](@code/redis/sentinel/conf/redis-sentinel-26382.conf)
5252

5353
注意修改各容器redis映射的配置文件;

docs/server-end/es-version/ES5-2009.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ str.charAt(1)
4141

4242
```js
4343
// 转义字符可能支持的不是很好
44-
const msg = 'Hello \
45-
Dolly!'
44+
// const msg = 'Hello \
45+
// Dolly!'
4646

4747
// 更安全的做法
4848
const newMsg = 'Hello ' + 'Dolly!'

docs/server-end/es-version/Readme-back.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ arr[1]() // 输出1
6363

6464
```js
6565
const PI = 3.14
66-
PI = 100 // 出错
66+
// 出错
67+
// PI = 100
6768

6869
const arr = [10, 11]
6970

@@ -73,7 +74,7 @@ arr[1] = 13
7374
console.log(arr) // 输出 [12,13]
7475

7576
// 注意:这种修改不行,不要试图去修改内存地址
76-
arr = [12, 13]
77+
// arr = [12, 13]
7778
```
7879

7980
## let const var的区别
@@ -113,12 +114,12 @@ console.log(my_name, my_age) // leo 20
113114
```
114115

115116
```js
116-
const fn = () => {
117+
function fn() {
117118
console.log(123)
118119
}
119120

120-
const sum = (a, b) => a + b
121-
const sum = a => a
121+
const sum1 = (a, b) => a + b
122+
const sum2 = a => a
122123
```
123124

124125
## 箭头函数的this关键字
@@ -200,6 +201,7 @@ let arrayLike = {
200201

201202
// 伪数组转换为数组
202203
let arr2 = Array.from(arrayLike) // ['a',''b,'c']
204+
console.log(arr2)
203205

204206
// 函数统一处理每一项
205207
let arr3 = Array.from(arrayLike, item => {

0 commit comments

Comments
 (0)