Skip to content

Commit 7e54cfd

Browse files
微信公众号:储凡mmdapl
andauthored
fix: 修复文档、代码的Eslint校验错误 (#154)
* fix: 修复文档、代码的Eslint校验错误 * chore: update --------- Co-authored-by: chufan <mmdapl@163.com>
1 parent 1915f32 commit 7e54cfd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+495
-456
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ Nuxt.js是在vue框架上进行封装的,主要是用来解决单体页面的
368368
369369
- [ ] nodejs下gRPC的简单实用
370370
- [ ] gRPC集成express框架
371-
- [ ] gRPC集成koa框架
371+
- [ ] gRPC集成Koa框架
372372
- [ ] gRPC在egg.js下的应用
373373
- [ ] gRPC插件开发示例
374374

code/algorithm/debounce.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function debounce(func, time) {
99
clearTimeout(timeout)
1010
timeout = setTimeout(() => {
1111
// 执行函数
12+
// eslint-disable-next-line prefer-rest-params
1213
func.apply(this, arguments)
1314
// func()
1415
}, time)

code/algorithm/deepClone.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ function DeepCloneByJSON(target) {
88

99
/**
1010
* 基于递归思想的深拷贝
11-
* @param target
12-
* @returns {{}|*}
13-
* @constructor
1411
*/
1512
function DeepClone(target) {
1613
let result
@@ -41,3 +38,7 @@ function checkType(target) {
4138
// typeof -instanceof -toString.call() -Array.isArray()
4239
return Object.prototype.toString.call(target).slice(8, -1)
4340
}
41+
42+
// 深拷贝
43+
console.log(DeepCloneByJSON)
44+
console.log(DeepClone)

code/algorithm/front-end-ts/add.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
* 累加
33
*/
44
function add() {
5+
// eslint-disable-next-line prefer-rest-params
56
const args = Array.prototype.slice.call(arguments)
67
const _add = function () {
8+
// eslint-disable-next-line prefer-rest-params
79
console.log('add', arguments)
10+
// eslint-disable-next-line prefer-rest-params
811
args.push(...arguments)
912

1013
// 返回函数

code/algorithm/front-end/duplicates.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/**
22
* 找出数组 arr 中重复出现过的元素
3-
* @param arr
4-
* @returns {*[]}
53
*/
64
function duplicates(arr) {
75
const sortArr = arr.sort()

code/algorithm/interview-101/addInList.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
* @return ListNode类
1212
*/
1313
function addInList(head1, head2) {
14-
// write code here
14+
console.log(head1, head2)
1515
}
16+
1617
module.exports = {
1718
addInList,
1819
}

code/algorithm/interview-101/binarySearch.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const search = function (nums, target) {
1919
* @param target
2020
*/
2121
function binarySearch(nums, target) {
22-
let left = 0; let right = nums.length
22+
let left = 0
23+
let right = nums.length
2324
while (left < right) {
2425
// 注意js取整问题;
2526
const mid = left + Number.parseInt((right - left) / 2)
@@ -45,7 +46,8 @@ function binarySearch(nums, target) {
4546
* @param target
4647
*/
4748
function leftBound(nums, target) {
48-
let left = 0; let right = nums.length - 1
49+
let left = 0
50+
let right = nums.length - 1
4951

5052
// [left,right]
5153
while (left <= right) {
@@ -74,7 +76,9 @@ function leftBound(nums, target) {
7476
* @param target
7577
*/
7678
function rightBound(nums, target) {
77-
let left = 0; let right = nums.length
79+
let left = 0
80+
let right = nums.length
81+
7882
// [left,right) 情况
7983
while (left < right) {
8084
const mid = left + Math.floor((right - left) / 2)
@@ -97,9 +101,8 @@ function rightBound(nums, target) {
97101
return nums[left - 1] === target ? left - 1 : -1
98102
}
99103

100-
// console.log(search([-1,0,3,5,9,12],9))
101-
102-
// console.log(search([5,7,7,8,8,8,10],8))
103-
104-
// console.log(left_bound([5,7,7,8,8,8,10],8))
105-
console.log(rightBound([5, 7, 7, 8, 8, 8, 10], 8))
104+
const nums = [5, 7, 7, 8, 8, 8, 10]
105+
const target = 8
106+
console.log(search(nums, target))
107+
console.log(leftBound(nums, target))
108+
console.log(rightBound(nums, target))

code/algorithm/interview-101/deleteDuplicates-1.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@
1010
* @return ListNode类
1111
*/
1212
function deleteDuplicatesOne(head) {
13-
// write code here
13+
console.log(head)
1414
}
15+
16+
// 测试用例
17+
console.log(deleteDuplicatesOne(1))

code/algorithm/interview-101/deleteDuplicates-2.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@
1010
* @return ListNode类
1111
*/
1212
function deleteDuplicatesTwo(head) {
13-
// write code here
13+
console.log(head)
1414
}
15+
16+
// 测试用例
17+
console.log(deleteDuplicatesTwo(1))

code/algorithm/interview-101/entryNodeOfLoop.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
* @constructor
1010
*/
1111
function entryNodeOfLoop(pHead) {
12-
// write code here
12+
console.log(pHead)
1313
}
14+
1415
module.exports = {
1516
entryNodeOfLoop,
1617
}

code/algorithm/interview-101/fibonacci.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ function fibonacciTwo(n) {
1818
let secondValue = 1
1919

2020
let result = 1
21+
2122
for (let index = 3; index <= n; index++) {
2223
result = firstValue + secondValue
2324
// 前面两列重新赋值
2425
firstValue = secondValue
2526
secondValue = result
2627
}
28+
2729
return result
2830
}
2931

code/algorithm/interview-101/findContinuousSequence.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// 指针矛盾了
22
function FindContinuousSequence(sum) {
33
// 首先,序列最少包含两位数,则 x+(x+1)<=sum ===> x<sum/2 暂且向上取整吧
4-
let left = 1; const right = 2
4+
let left = 1
5+
const right = 2
56
let tempSum = 3
67
const result = []
8+
79
// < 确保序列不断,跳出玄幻时候,left ==right
810
while (left < right) {
911
// 求和

code/algorithm/interview-101/findFirstCommonNode.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
* @constructor
1111
*/
1212
function findFirstCommonNode(pHead1, pHead2) {
13-
// write code here
13+
console.log(pHead1, pHead2)
1414
}
15+
1516
module.exports = {
1617
findFirstCommonNode,
1718
}

code/algorithm/interview-101/findKth.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ function getPivot(arr, low, high) {
5151
arr[high] = arr[low]
5252
}
5353
arr[low] = pivot
54+
5455
return low
5556
}
5657

code/algorithm/interview-101/findKthToTail.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/**
22
* 链表结点
33
*/
4+
// eslint-disable-next-line no-unused-vars,unused-imports/no-unused-vars
45
function ListNode(x) {
56
this.val = x
67
this.next = null
78
}
9+
810
/**
911
*【简单】 链表中倒数最后k个结点
1012
* @param pHead ListNode类

code/algorithm/interview-101/findNumbersWithSum.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ function FindNumbersWithSum(array, sum) {
1717
// 向右
1818
left++
1919
}
20-
else if (tempSum > sum) {
20+
21+
if (tempSum > sum) {
2122
// 向左
2223
right--
2324
}
24-
else if (tempSum === sum) {
25+
26+
if (tempSum === sum) {
2527
// 已找到符合条件的元素,需要对齐进行乘积比较
2628
if (min > array[left] * array[right]) {
2729
// 假定为最小值
@@ -34,6 +36,7 @@ function FindNumbersWithSum(array, sum) {
3436
right--
3537
}
3638
}
39+
3740
// left===right 退出
3841
return sumResult
3942
}

code/algorithm/interview-101/getLongestPalindrome.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ function getLongestPalindrome(str, len) {
2222
}
2323
return max
2424
}
25+
26+
// 测试用例
27+
console.log(getLongestPalindrome('sbcc', 2))

code/algorithm/interview-101/hasCycle.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
* @return bool布尔型
55
*/
66
function hasCycle(head) {
7-
// write code here
7+
console.log(head)
88
}
9+
910
module.exports = {
1011
hasCycle,
1112
}

code/algorithm/interview-101/isPail.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
* @return bool布尔型
1111
*/
1212
function isPail(head) {
13-
// write code here
13+
console.log(head)
1414
}
15+
1516
module.exports = {
1617
isPail,
1718
}

code/algorithm/interview-101/merge.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
* @return ListNode类
55
*/
66
function merge(pHead1, pHead2) {
7-
// write code here
7+
console.log(pHead1, pHead2)
88
}
9+
910
module.exports = {
1011
merge,
1112
}

code/algorithm/interview-101/mergeLists.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
* @return ListNode类
55
*/
66
function mergeKLists(lists) {
7-
7+
console.log(lists)
88
}
9+
910
module.exports = {
1011
mergeKLists,
1112
}

code/algorithm/interview-101/moreThanHalfNum.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
*
3+
* @param numbers
4+
* @returns {number}
5+
* @constructor
6+
*/
17
function MoreThanHalfNumSolution(numbers) {
28
const map = new Map()
39
numbers.forEach((item) => {
@@ -17,3 +23,6 @@ function MoreThanHalfNumSolution(numbers) {
1723
})
1824
return result
1925
}
26+
27+
// 测试用例
28+
console.log(MoreThanHalfNumSolution(11))
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
/*
2-
* function ListNode(x){
3-
* this.val = x;
4-
* this.next = null;
5-
* }
1+
/**
2+
* 结点
3+
* @param x
4+
* @constructor
65
*/
6+
// eslint-disable-next-line no-unused-vars,unused-imports/no-unused-vars
7+
function ListNode(x) {
8+
this.val = x
9+
this.next = null
10+
}
11+
712
/**
813
*
914
* @param head ListNode类
1015
* @return ListNode类
1116
*/
1217
function oddEvenList(head) {
13-
// write code here
18+
console.log(head)
1419
}
20+
1521
module.exports = {
1622
oddEvenList,
1723
}

code/algorithm/interview-101/reverseGroup.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
* @return ListNode类
55
*/
66
function reverseGroup(head, k) {
7-
// write code here
7+
console.log(head, k)
88
}
9+
10+
// 测试用例
11+
console.log(reverseGroup(11, 11))

code/algorithm/interview-101/reverseList.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
this.next = null;
44
} */
55
function reverseList(pHead) {
6-
// write code here
6+
console.log(pHead)
77
}
8+
89
module.exports = {
910
reverseList,
1011
}

code/algorithm/interview-101/sortInList.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
* @return ListNode类
1010
*/
1111
function sortInList(head) {
12-
// write code here
12+
console.log(head)
1313
}
14+
1415
module.exports = {
1516
sortInList,
1617
}

code/algorithm/interview-101/threeNum.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ function threeSum(num) {
1111
// 查找左边
1212
for (let left = 0; left < mid; left++) {
1313
// 查找右边
14-
1514
for (let right = mid + 1; right < len; right++) {
1615
if (num[left] + num[mid] + num[right] === 0) {
1716
result.push([num[left], num[mid], num[right]])
1817
}
1918
}
2019
}
2120
}
21+
2222
return result
2323
}
24+
2425
console.log(threeSum([-2, 0, 1, 1, 2]))

code/algorithm/interview-101/twoSum.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ function twoSumByMap(numbers, target) {
3232
if (map.has(target - numbers[left]) && map.get(target - numbers[left]) !== (left + 1)) {
3333
// 则在左边找到元素
3434
const right = map.get(target - numbers[left])
35-
console.log(map)
3635
return [right, left + 1]
3736
}
3837
// 有点倒排索引的意思

0 commit comments

Comments
 (0)