Skip to content

Commit

Permalink
style: eslint code
Browse files Browse the repository at this point in the history
  • Loading branch information
mmdapl committed Feb 24, 2025
1 parent 05345d9 commit 16e12c6
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 57 deletions.
2 changes: 1 addition & 1 deletion code/algorithm/interview-101/binarySearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
*
*/
const search = function (nums, target) {
function search(nums, target) {
// 投机
// return nums.indexOf(target)

Expand Down
2 changes: 1 addition & 1 deletion code/express/apps/static-source-demo/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const express = require('express')

const app = express()
// eslint-disable-next-line import/order

const path = require('node:path')
// 服务启动端口
const port = 3000
Expand Down
6 changes: 3 additions & 3 deletions code/express/apps/template-demo/app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require('node:path')
const http = require('node:http')
const createError = require('http-errors')
const express = require('express')
const path = require('node:path')
const cookieParser = require('cookie-parser')
const express = require('express')
const createError = require('http-errors')
const logger = require('morgan')
const indexRouter = require('./routes/index')
const usersRouter = require('./routes/users')
Expand Down
1 change: 0 additions & 1 deletion code/koa/koa-listen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/order
const Koa = require('koa')

const app = new Koa()
Expand Down
2 changes: 1 addition & 1 deletion docs/front-end/base-begin/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ function fn() {

```js
// 匿名函数
const fn = function () {
function fn() {

}
```
Expand Down
24 changes: 12 additions & 12 deletions docs/read-books/cs-books/ES6标准入门.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ function objectConstant(obj) {
: this)

// 方法二
const getGlobal = function () {
function getGlobal() {
if (typeof self !== 'undefined') {
return self
}
Expand Down Expand Up @@ -2315,7 +2315,7 @@ ES6 对这个属性的行为做出了一些修改,如果将一个匿名函数

```js
// 匿名函数
const f = function () {
function f() {
}

// ES5
Expand All @@ -2328,7 +2328,7 @@ f.name // "f"
如果将一个具名函数赋值给一个变量,则 ES5 和 ES6 的name属性都返回这个具名函数原本的名字。

```js
const bar = function test() {
function bar() {
}

// ES5
Expand Down Expand Up @@ -3094,9 +3094,9 @@ Array.of(3).length // 1
弥补数组构造函数`Array()`的不足。因为参数个数的不同,会导致`Array()`的行为有差异。

```js
Array() // []
Array(3) // [, , ,]
Array(3, 11, 8) // [3, 11, 8]
new Array() // []
Array.from({ length: 3 }) // [, , ,]
new Array(3, 11, 8) // [3, 11, 8]
```

`Array()`方法没有参数、一个参数、三个参数时,返回的结果都不一样。
Expand Down Expand Up @@ -3430,7 +3430,7 @@ arr.flatMap(function callback(currentValue[, index[, array]]) {

```js
// 返回具有 3 个空位的数组。
Array(3) // [, , ,]
Array.from({ length: 3 }) // [, , ,]
```

空位不是`undefined`,一个位置的值等于`undefined`,依然是有值的。**空位是没有任何值**,in运算符可以说明这一点。
Expand Down Expand Up @@ -3833,7 +3833,7 @@ descriptor.set.name // "set foo"
```js
(new Function()).name // "anonymous"

const doSomething = function () {
function doSomething() {
// ...
}
doSomething.bind().name // "bound doSomething"
Expand Down Expand Up @@ -4328,9 +4328,9 @@ console.log(obj) // { "0": "a", "1": "b", "2": "c" }
只有字符串合入目标对象(以字符数组的形式),数值和布尔值都会被忽略。**因为只有字符串的包装对象,会产生可枚举属性。**
```js
Object(true) // {[[PrimitiveValue]]: true}
Object(10) // {[[PrimitiveValue]]: 10}
Object('abc') // {0: "a", 1: "b", 2: "c", length: 3, [[PrimitiveValue]]: "abc"}
new Object(true) // {[[PrimitiveValue]]: true}
new Object(10) // {[[PrimitiveValue]]: 10}
new Object('abc') // {0: "a", 1: "b", 2: "c", length: 3, [[PrimitiveValue]]: "abc"}
```
`布尔值``数值``字符串`分别转成对应的包装对象,可以看到它们的原始值都在包装对象的内部属性`[[PrimitiveValue]]`
Expand Down Expand Up @@ -4606,7 +4606,7 @@ obj.method = function () {
```js
Object.defineProperty(Object.prototype, '__proto__', {
get() {
const _thisObj = Object(this)
const _thisObj = new Object(this)
return Object.getPrototypeOf(_thisObj)
},
set(proto) {
Expand Down
4 changes: 2 additions & 2 deletions docs/read-books/cs-books/更了不起的Node.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ Node.js是基于CommonJS规范的实现,即每个文件都是一个模块,
```js
// 相关模块

const http = require('node:http')
const fs = require('node:fs')
const http = require('node:http')

// 实例化对象

Expand Down Expand Up @@ -717,7 +717,7 @@ Node.js对模块的定义非常简单,主要分为模块应用、模块定义
> 可以将关联代码封装到一个代码单元中,创建一个模块可以理解为全部有关联的函数放在一个文件中
```js
const sayHelloEnglish = function () {
function sayHelloEnglish() {
return 'hello'
}

Expand Down
8 changes: 4 additions & 4 deletions docs/read-books/cs-books/深入浅出的Node.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ web服务器的会话实现一般通过内存来存储,**当访问量大的时

```js
// test函数 local局部变量
const test = function () {
function test() {
const local = {}
}
```
Expand Down Expand Up @@ -419,7 +419,7 @@ Tips:同样,在非全局作用域中,想要主动释放变量引用的对
主要是通过高阶函数的特性(函数可以作为参数或者返回值)完成的

```js
const foo = function () {
function foo() {
const bar = function () {
// 定义局部变量
const local = '局部变量'
Expand Down Expand Up @@ -496,7 +496,7 @@ Node对内存泄露非常敏感,一旦线上项目应用拥有成千上万的
// 例如利用cache全局对象来常驻老生代内存中
const cache = {}
// 获取目标值
const get = function (key) {
function get(key) {
if (cache[key]) {
// 内存中存在,即返回
return cache[key]
Expand All @@ -507,7 +507,7 @@ const get = function (key) {
}

// 设置key/value值
const set = function (key, value) {
function set(key, value) {
// 设置
cache[key] = value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ permalink: /server-end/design-patterns/data-access-object-mode.html
* @param {string} prefix Key前缀
* @param {string} timeSplit 时间戳与存储数据之间的分割符
*/
const DAO = function (prefix, timeSplit) {
function DAO(prefix, timeSplit) {
this.prefix = prefix
this.timeSplit = timeSplit || '|-|'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ permalink: /server-end/design-patterns/waiters-mode.html
### 实现

```javascript
const Waiter = function () {
function Waiter() {
let dfd = [] // 等待对象容器
let doneArr = [] // 成功回调容器
let failArr = [] // 失败回调容器
Expand Down Expand Up @@ -98,9 +98,7 @@ const Waiter = function () {
failArr = failArr.concat(args) // 向失败回调函数中添加方法
return this
}
}

;(function () {
}(function () {
const waiter = new Waiter() // 创建一个等待者实例
const first = (function () {
const promise = waiter.Deferred()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ permalink: /server-end/design-patterns/link-mode.html
- 闭包返回对象的方式实现,这种方式与柯里化有相似之处。

```javascript
const Person = function () {}
function Person() {}
Person.prototype.setAge = function (age) {
this.age = age
return this
Expand Down
2 changes: 1 addition & 1 deletion docs/server-end/es-version/ES6-2015.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const x = 100

```ts
// ES5
const result = function (x, y) {
function result(x, y) {
return x + y
}

Expand Down
14 changes: 7 additions & 7 deletions docs/server-end/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export * from './base/base.sidebar'
export * from './database/mongo/mongoSideBar'
export * from './database/mysql/mySqlSideBar'
export * from './database/redis/redisSidebar'
export * from './design-patterns/designPatterns.sidebar'
export * from './framework/egg/eggSidebar'
export * from './framework/koa/koa.sidebar'
export * from './framework/express/express.sidebar'
export * from './database/redis/redisSidebar'
export * from './database/mysql/mySqlSideBar'
export * from './database/mongo/mongoSideBar'
export * from './framework/koa/koa.sidebar'
export * from './linux/linuxSidebar'
export * from './design-patterns/designPatterns.sidebar'
export * from './typescript/typescript.sidebar'
export * from './base/base.sidebar'
export * from './node-learn/nodeLearnSidebar'
export * from './orm/sequelize/sequelizeOrm.sidebar'
export * from './orm/typeorm/typeorm.sidebar'
export * from './typescript/typescript.sidebar'

/**
* 后端服务-侧边栏
Expand Down
2 changes: 1 addition & 1 deletion docs/server-end/typescript/基础教程/高级类型.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class SpaceRepeatingPadder implements Padder {
}

getPaddingString() {
return Array(this.numSpaces + 1).join(' ')
return new Array(this.numSpaces + 1).join(' ')
}
}

Expand Down
12 changes: 6 additions & 6 deletions docs/theme.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { hopeTheme, navbar, sidebar } from 'vuepress-theme-hope'
import { markdownImagePlugin } from '@vuepress/plugin-markdown-image'
import { OPEN_SOURCE_ADDRESS } from '@142vip/utils'
import { soloAlgorithmSidebar } from './solo-algorithm/solo-algorithm.sidebar'
import { FrontEndSidebar } from './front-end/front-end.sidebar'
import { markdownImagePlugin } from '@vuepress/plugin-markdown-image'
import { hopeTheme, navbar, sidebar } from 'vuepress-theme-hope'
import { BattleInterviewSidebar } from './battle-interview/battle-interview.sidebar'
import { DevelopSkillSidebar } from './develop-skill/develop-skill.sidebar'
import { ReadBooksSidebar } from './read-books/read-books.sidebar'
import { FrontEndSidebar } from './front-end/front-end.sidebar'
import { JobChanceSidebar } from './job-chance/job-chance.sidebar'
import { MicroserviceSidebar } from './microservice/microserviceSidebar'
import { BattleInterviewSidebar } from './battle-interview/battle-interview.sidebar'
import { ReadBooksSidebar } from './read-books/read-books.sidebar'
import {
BaseSidebar,
DesignPatternsSidebar,
Expand All @@ -24,6 +23,7 @@ import {
TypeormSidebar,
TypescriptSidebar,
} from './server-end'
import { soloAlgorithmSidebar } from './solo-algorithm/solo-algorithm.sidebar'

/**
* 导航栏
Expand Down
22 changes: 11 additions & 11 deletions vuepress.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { defineUserConfig } from '@vuepress/cli'
import { getDirname, path } from '@vuepress/utils'
import { viteBundler } from '@vuepress/bundler-vite'
import { hopeTheme } from 'vuepress-theme-hope'
import {
JSCHeaders,
getDocSiteBase,
OPEN_SOURCE_ADDRESS,
OPEN_SOURCE_AUTHOR,
} from '@142vip/utils'
import {
getCopyRightText,
getFooterHtml,
getThemeConfig,
getViteBundler,
JSCHeaders,
} from '@142vip/vuepress'
import {
OPEN_SOURCE_ADDRESS,
OPEN_SOURCE_AUTHOR,
getDocSiteBase,
} from '@142vip/utils'
import pkg from './package.json'
import { viteBundler } from '@vuepress/bundler-vite'
import { defineUserConfig } from '@vuepress/cli'
import { getDirname, path } from '@vuepress/utils'
import { hopeTheme } from 'vuepress-theme-hope'
import { navbarConfig, sidebarConfig } from './docs/theme.config'
import pkg from './package.json'

export default defineUserConfig({
base: getDocSiteBase(pkg.name),
Expand Down

0 comments on commit 16e12c6

Please sign in to comment.