剪藏
Rethinking your position
Learn how to learn
3R编码 | nestjs最佳实践 - 课程概览
3R编码 | Node.js开发环境搭建
3R编码 | Nestjs+Eslint+SWC应用初始化及断点调试
3R编码 | 装饰器与反射
3R编码 | Nestjs核心概念
3R编码 | 无懈可击的Linux服务器构建
3R编码 | 使用Turborepo+pnpm workspaces构建monorepo应用
3R编码 | 使用Gitea+Drone自建CICD平台
3R编码 | 整合Typeorm实现CRUD
3R编码 | 请求数据的验证和响应数据的序列化
3R编码 | 数据关联与树形嵌套结构的分类和评论的实现
3R编码 | 自定义全局的验证管道,拦截器和过滤器
3R编码 | 自定义数据验证约束及约束中的依赖注入
3R编码 | 批量操作及软删除(回收站)功能使用
3R编码 | 数据库与MeiliSearch的全文搜索
3R编码 | 数据操作代码的抽象化
3R编码 | 整合bun与pm2实现开发环境与生产环境免编译和自启
3R编码 | 自建配置系统实现
3R编码 | 嵌套路由与Swagger文档实现
3R编码 | 使用Yargs构建命令行工具
3R编码 | 生产环境下静默启动以及PM2 API的使用
3R编码 | 数据迁移功能的实现
3R编码 | 数据填充命令实现
3R编码 | 用户模块开发以及使用Passport实现JWT认证和无痛刷新
3R编码 | 基于CASL的RBAC动态角色及权限系统实现
3R编码 | 模型动态关联与基于CASL的动态权限的实现
3R编码 | 使用BullMQ实现异步验证短信与邮件发送
3R编码 | WebSocket实现消息广播功能
3R编码 | chapter27
3R编码 | chapter28
3R编码 | TS全栈+AI开发实战 - 课程概览
3R编码 | Node.js环境搭建及应用初始化
3R编码 | Next.js应用初始化
3R编码 | React内置Hooks的使用与自定义详解
3R编码 | Next.js中使用Zustand进行状态管理详解
3R编码 | Next.js核心概念及应用构建
微电子学第1话 MOS Differential Pair (I)
微电子学第1话 MOS Differential Pair (I)
微电子学第3话 CMRR
微电子学第2话 MOS Differential Pair (II)
终于有人讲了,凭什么三极管能放大?
降低人类负担:类型系统即边界
固态变压器SST是什么
本站点使用 MrDoc 构建
-
+
3R编码 | Nestjs+Eslint+SWC应用初始化及断点调试
``` { "compilerOptions": { "strict": true, "alwaysStrict": true, "target": "esnext", "module": "commonjs", "moduleResolution": "Node", "declaration": true, "declarationMap": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "sourceMap": true, "incremental": true, "skipLibCheck": true, "strictNullChecks": false, "noImplicitAny": true, "strictBindCallApply": false, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": false, "isolatedModules": true, "esModuleInterop": true, "noUnusedLocals": true, "noImplicitReturns": true, "pretty": true, "resolveJsonModule": true, "allowJs": true, "importsNotUsedAsValues": "remove", "noEmit": false, "lib": ["esnext", "DOM", "ScriptHost", "WebWorker"], "baseUrl": ".", "outDir": "./dist", "paths": { "@/*": ["./src/*"] } }, "include": ["src", "test", "typings/**/*.d.ts", "**.js"]} ``` ``` // .eslintrc.jsmodule.exports = { parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', tsconfigRootDir: __dirname, ecmaVersion: 'latest', sourceType: 'module', }, root: true, env: { node: true, jest: true, }, plugins: ['@typescript-eslint', 'jest', 'prettier', 'import', 'unused-imports'], extends: [ // airbnb规范 // https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb 'airbnb-base', // 兼容typescript的airbnb规范 // https://github.com/iamturns/eslint-config-airbnb-typescript 'airbnb-typescript/base', // typescript的eslint插件 // https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md // https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin 'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended-requiring-type-checking', // 支持jest 'plugin:jest/recommended', // 使用prettier格式化代码 // https://github.com/prettier/eslint-config-prettier#readme 'prettier', // 整合typescript-eslint与prettier // https://github.com/prettier/eslint-plugin-prettier 'plugin:prettier/recommended', ], rules: { /* ********************************** ES6+ ********************************** */ 'no-console': 0, 'no-var-requires': 0, 'no-restricted-syntax': 0, 'no-continue': 0, 'no-await-in-loop': 0, 'no-return-await': 0, 'no-unused-vars': 0, 'no-multi-assign': 0, 'no-param-reassign': [2, { props: false }], 'import/prefer-default-export': 0, 'import/no-cycle': 0, 'import/no-dynamic-require': 0, 'max-classes-per-file': 0, 'class-methods-use-this': 0, 'guard-for-in': 0, 'no-underscore-dangle': 0, 'no-plusplus': 0, 'no-lonely-if': 0, 'no-bitwise': ['error', { allow: ['~'] }], /* ********************************** Module Import ********************************** */ 'import/no-absolute-path': 0, 'import/extensions': 0, 'import/no-named-default': 0, 'no-restricted-exports': 0, // 一部分文件在导入devDependencies的依赖时不报错 'import/no-extraneous-dependencies': [ 1, { devDependencies: [ '**/*.test.{ts,js}', '**/*.spec.{ts,js}', './test/**.{ts,js}', './scripts/**/*.{ts,js}', ], }, ], // 模块导入顺序规则 'import/order': [ 1, { pathGroups: [ { pattern: '@/**', group: 'external', position: 'after', }, ], alphabetize: { order: 'asc', caseInsensitive: false }, 'newlines-between': 'always-and-inside-groups', warnOnUnassignedImports: true, }, ], // 自动删除未使用的导入 // https://github.com/sweepline/eslint-plugin-unused-imports 'unused-imports/no-unused-imports': 1, 'unused-imports/no-unused-vars': [ 'error', { vars: 'all', args: 'none', ignoreRestSiblings: true, }, ], /* ********************************** Typescript ********************************** */ '@typescript-eslint/no-unused-vars': 0, '@typescript-eslint/no-empty-interface': 0, '@typescript-eslint/no-this-alias': 0, '@typescript-eslint/no-var-requires': 0, '@typescript-eslint/no-use-before-define': 0, '@typescript-eslint/explicit-member-accessibility': 0, '@typescript-eslint/no-non-null-assertion': 0, '@typescript-eslint/no-unnecessary-type-assertion': 0, '@typescript-eslint/require-await': 0, '@typescript-eslint/no-for-in-array': 0, '@typescript-eslint/interface-name-prefix': 0, '@typescript-eslint/explicit-function-return-type': 0, '@typescript-eslint/no-explicit-any': 0, '@typescript-eslint/explicit-module-boundary-types': 0, '@typescript-eslint/no-floating-promises': 0, '@typescript-eslint/restrict-template-expressions': 0, '@typescript-eslint/no-unsafe-assignment': 0, '@typescript-eslint/no-unsafe-return': 0, '@typescript-eslint/no-unused-expressions': 0, '@typescript-eslint/no-misused-promises': 0, '@typescript-eslint/no-unsafe-member-access': 0, '@typescript-eslint/no-unsafe-call': 0, '@typescript-eslint/no-unsafe-argument': 0, '@typescript-eslint/ban-ts-comment': 0, }, settings: { extensions: ['.ts', '.d.ts', '.cts', '.mts', '.js', '.cjs', 'mjs', '.json'], },}; ``` ``` 'import/order': [ 'error', { pathGroups: [ { pattern: '@/**', group: 'external', position: 'after', }, ], alphabetize: { order: 'asc', caseInsensitive: false }, 'newlines-between': 'always-and-inside-groups', warnOnUnassignedImports: true, },], ``` ``` 'import/no-extraneous-dependencies': [ 'error', { devDependencies: [ '**/*.test.{ts,js}', '**/*.spec.{ts,js}', './test/**.{ts,js}', ], },], ``` 并且把一些prettier和eslint需要忽略的目录和文件分别添加到 .eslintignore 和 .prettierignore,这样就可以避免一些不必要的文件被格式化 对于 [Node.js](https://nodejs.org/) 和 [TypeScript](https://www.typescriptlang.org/) 等前端技术最好的开发工具,毋庸置疑的就是 [VSCode](https://code.visualstudio.com/)。任何其它选项(包括 Vim、Emacs、Sublime Text、Atom、WebStorm 等等)都有这样那样的问题需要去耗费精力解决,所以建议直接使用 VSCode 进行开发 然后按`shift + cmd + p`(windows下使用`ctrl + shift + p`),输入`reload`,选择重新加载窗口,打开源码按`cmd + s`即可在保存代码的时候自动格式化 ``` { // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "debug 3rapp", "request": "launch", "runtimeArgs": ["run-script", "start:debug"], "autoAttachChildProcesses": true, "console": "integratedTerminal", "runtimeExecutable": "pnpm", "skipFiles": ["<node_internals>/**"], "type": "node" } ]} ``` 再次运行`pnpm start:dev`,然后尝试改动`src/app.controller.ts`中的随意一行代码。比如注释掉`console.log('welcome to')`,就可以看到下图这样热更新速度明显比默认的TSC快,这证明`swc`已经配置成功
peipeo
2026年11月8日 10:14
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
PDF文档(打印)
分享
链接
类型
密码
更新密码