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模块到项目中,也不需要每次修改配置后重载窗口以应用配置。

相关推荐
恋猫de小郭10 小时前
Flutter Zero 是什么?它的出现有什么意义?为什么你需要了解下?
android·前端·flutter
崔庆才丨静觅17 小时前
hCaptcha 验证码图像识别 API 对接教程
前端
passerby606117 小时前
完成前端时间处理的另一块版图
前端·github·web components
掘了17 小时前
「2025 年终总结」在所有失去的人中,我最怀念我自己
前端·后端·年终总结
崔庆才丨静觅17 小时前
实用免费的 Short URL 短链接 API 对接说明
前端
崔庆才丨静觅18 小时前
5分钟快速搭建 AI 平台并用它赚钱!
前端
崔庆才丨静觅18 小时前
比官方便宜一半以上!Midjourney API 申请及使用
前端
Moment18 小时前
富文本编辑器在 AI 时代为什么这么受欢迎
前端·javascript·后端
崔庆才丨静觅19 小时前
刷屏全网的“nano-banana”API接入指南!0.1元/张量产高清创意图,开发者必藏
前端
剪刀石头布啊19 小时前
jwt介绍
前端