随笔分类 - Tools
摘要:集成Prettier 目前我们所学习的两个工具:Pretter 和 ESLint,两者都有管理代码风格的功能,因此两者往往就会在代码风格的管理上面存在一些冲突。 例如举一个例子: ESLint 配置了单引号规则 Prettier 配置了要使用双引号 那么现在假设你使用双引号,ESLint 会提示错误
阅读全文
摘要:自定义ESLint插件 ESLint插件主要是用来扩展ESLint本身没有的功能,这里包括扩展规则、扩展配置、扩展解析器。 90%的ESLint插件都是以扩展规则为主,所以这些插件里面会包含大量的自定义规则。 像这一类的插件,一般一条规则会对应一个 JS 文件,JS 文件里面需要导出一个对象: mo
阅读全文
摘要:SWC SWC 英文全称为 Speedy Web Compiler,翻译成中文为“快速网页编译器”。 官网地址:https://swc.rs/ 来看一下官方的介绍: SWC is an extensible Rust-based platform for the next generation of
阅读全文
摘要:Terser Terser 是一个流行的 JavaScript 解析器和压缩器,它可以帮助你优化 JavaScript 代码以减少其大小,从而提高 web 页面的加载速度。Terser 是 Uglify-es 的替代品,后者已经停止维护,Terser 支持 ES6 和更高版本的 JavaScript
阅读全文
摘要:配置文件 配置文件格式 配置文件选项 配置文件的格式 在 babel 中,配置文件本身又可以分为两种: 项目范围的配置文件 文件相关配置文件 项目范围配置文件 顾名思义,就是该配置文件针对整个项目生效的一个配置,这种类型的配置文件一般放在项目根目录下面,babel 对项目范围级别的配置文件是有格式要
阅读全文
摘要:APIs 关于 babel 里面的 APIs 主要位于 @babel/core 这个依赖里面,你可以在官网左下角的 Tooling Packages 分类下找到这个依赖包。 这里顺便介绍一下每一种依赖包的作用: @babel/parser: 是 Babel 的解析器,用于将源代码转换为 AST。 @
阅读全文
摘要:使用插件 在 babel 要使用一个插件,步骤实际上非常简单,就分为两步: 安装插件 在配置文件或者 CLI 中指定插件 举个例子,例如有一个专门将箭头函数转为普通函数的插件: pnpm add @babel/plugin-transform-arrow-functions -D 之后在配置文件中进
阅读全文
摘要:CLI 关于 babel 所提供的 CLI,你可以在 https://babeljs.io/docs/babel-cli 看到所有所支持的 CLI 命令。 要使用 CLI 命令,首先第一步是安装: pnpm add --save-dev @babel/core @babel/cli 注意在安装 @b
阅读全文
摘要:Babel介绍 Babel 是一个编译器,主要用于将最新的 JavaScript 代码转化为向后兼容的代码,以便在老版本的浏览器或环境中运行。 例如,你可能在开发时使用了 ES6、ES7 或者更高级的 JavaScript 特性,但是有些浏览器可能并不支持这些新特性,这时就可以用 Babel 来将代
阅读全文
摘要:检查规则 这节课我们主要学习 ESLint 里面的规则相关的知识。规则是 ESLint 中一个比较重要的核心概念之一,因为究竟报不报错,是由规则来确定的。 规则的重要性 在 ESLint 中,本身可以配置规则的重要性,总共分为三个级别: off 或者 0: 关闭这条规则 warn 或者 1:这条规则
阅读全文
摘要:It's fairly trivial to create a React project, but there's always a big hurdle between creating it locally and making it shareable so that someone els
阅读全文
摘要:In case running into peer deps issue, one thing we can do (maybe unsafe) is using --legacy-peer-deps We can use this in case, some framework publish a
阅读全文
摘要:Let's say for the laptop, default node version is 20.17.0, if you want the project to use 20.18.0with pnpm, you can do // use node 20.18.0 pnpm env us
阅读全文
摘要:https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_46.md#add-all-missing-imports-source-action
阅读全文
摘要:Use Capo.js to analyze what currently is - and what should be - the order of elements in your HEAD section of the document. After we know what the ord
阅读全文
摘要:in package.json: { "main": "./dist/build.umd.cjs", "module": "./dist/build.js", "exports": { ".": { "import": "./dist/build.js", "require": "./dist/bu
阅读全文
摘要:A learning resource for Vite https://vite-workshop.vercel.app/introduction
阅读全文
摘要://////////////////////////////////////////////////////// // @filename: berries/raspberry.ts export class Raspberry { constructor(public color: 'red' |
阅读全文
摘要:In package management systems like npm (for JavaScript/Node.js projects), dependencies are typically fetched from a remote registry. However, there ar
阅读全文
摘要:Go ahead and install the Remote - Containers extension. This takes everything one step further: you can actually set up someone's editor for them when
阅读全文