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

0 commit comments

Comments
 (0)