prettier.config.mjs配置不生效

prettier.config.mjs配置后不生效

新项目添加的prettier配置

检查vscode插件Prettier - Code formatter的Log,发现插件没有侦测到prettier.config.mjs配置文件。

shell 复制代码
["INFO" - 15:11:17] No local configuration (i.e. .prettierrc or .editorconfig) detected,
falling back to VS Code configuration

解决办法:安装prettier模块

shell 复制代码
npm install --save-dev --save-exact prettier

已安装prettier模块,修改prettier.config.mjs配置后不生效

检查插件的Log,能发现配置文件,但读取到的配置项的值与配置文件有出入。

shell 复制代码
["INFO" - 15:23:05] Detected local configuration (i.e. .prettierrc or .editorconfig),
VS Code configuration will not be used

解决办法: F1 > reload window

更轻量灵活的方法

up猪up猪,我承认上面的方法很强,但还是太吃操作啦,有没有轻量又简单的方法推荐一下。

有的兄弟,有的。 可以使用.prettierrc配置。

如果只是个人开发,或者项目体量小,可以不安装prettier模块。只需要安装prettier的vscode插件,根目录配置一个.prettierrc,这样既无需安装prettier模块到项目中,也不需要每次修改配置后重载窗口以应用配置。

相关推荐
yuanyxh13 小时前
Mac 软件推荐
前端·javascript·程序员
万少13 小时前
AtomCode开发微信小程序《谁去呀》 全流程
前端·javascript·后端
某人辛木14 小时前
Web自动化测试
前端·python·pycharm·pytest
Kagol14 小时前
Superpowers GSD gstack AgentSkills深度测评
前端·人工智能
excel15 小时前
JavaScript 字符串与模板字面量:从表象到本质理解
前端
京东云开发者16 小时前
当AI成为导演-如何用AI创作动漫短剧
前端
李白的天不白16 小时前
使用 SmartAdmin 进行前后端开发
java·前端
乘风gg16 小时前
🤡PUA AI Coding 工具 的 10 条终极语录
前端·ai编程·claude
学Linux的语莫16 小时前
Vue 3 入门教程
前端·javascript·vue.js
怕浪猫17 小时前
第一章、Chrome DevTools Protocol (CDP) 详解
前端·javascript·chrome