保存格式化prettier格式化配置没有生效?.prettierrc.js没有生效,但是配置文件要是写成".prettierrc"或者".prettierrc.json" json格式就能被读取并生效,这是啥问题呢? 设置步骤如下 1. 添加prettier配置文件 2. formatOnSave: true 如果我prettier配置文件是json格式的,是能读到项目的prettier配置项并格式化生效 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20241014/399eac3fe60c9afb928a0f97763cf61f.png)格式化也正确 但是如果我写的是".prettierrc.js" 时候,对应的配置项目好像没有被读取到(或者是被默认的覆盖了?) "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20241014/19ddb1e1e0f38694b276af2c78bbd04d.png) 可以看到读取配置并不是".prettierrc.js"的配置项而是全局设置的默认项。 这大概会是什么原因呢? package.json如下 { "name": "nodejs-koa2-blog", "version": "1.0.0", "description": "基于 Node.js Koa2 实战开发的一套完整的博客项目网站,使用 Koa2 二次开发一套适合多端的 RESTful API,同时配套完整的后台管理系统,且前端展示既有基于 ejs 服务端渲染,也有基于 Vue.js 前后端分离的 2 套前端网站。", "main": "index.js", "scripts": { "dev": "nodemon app.js", "test": "jest _tests --forceExit --runInBand --colors" }, "repository": { "type": "git", "url": "git+https://github.com/liangfengbo/nodejs-koa2-blog.git" }, "keywords": [ "nodejs", "koa2", "sequelize", "mysql", "ejs", "vuejs", "JavaScript", "博客网站", "Node.js实战", "ejs 服务端渲染" ], "author": "Fengbo Liang, https://github.com/lfb", "license": "ISC", "bugs": { "url": "https://github.com/lfb/nodejs-koa2-blog/issues" }, "_moduleAliases": { "@": ".", "@app": "app", "@core": "core", "@middlewares": "middlewares", "@api": "app/api", "@dao": "app/dao", "@lib": "app/lib", "@models": "app/models", "@service": "app/service", "@validators": "app/validators" }, "homepage": "https://github.com/lfb/nodejs-koa2-blog#readme", "dependencies": { "@koa/cors": "^3.0.0", "basic-auth": "^2.0.1", "bcryptjs": "^2.4.3", "ejs": "^3.1.8", "hashids": "^2.1.0", "highlight.js": "^11.1.0", "jest": "^24.9.0", "jsonwebtoken": "^8.4.0", "koa": "^2.7.0", "koa-bodyparser": "^4.2.1", "koa-ratelimit": "^5.0.1", "koa-router": "^7.4.0", "koa-static": "^5.0.0", "koa-views": "^8.0.0", "markdown-it": "^12.1.0", "module-alias": "^2.2.2", "moment": "^2.24.0", "mysql2": "^2.2.5", "nodemon": "^2.0.12", "npm-check": "^5.9.0", "qiniu": "^7.4.0", "require-directory": "^2.1.1", "sequelize": "^6.6.5", "supertest": "^4.0.2", "validator": "^10.11.0", "xss": "^1.0.6" }, "directories": { "test": "_tests" }, "devDependencies": { "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", "prettier": "3.2.4" } }
VUE3+TS项目 在使用prettier格式化代码后会在语句前加分号 是配置文件不对吗 //prettier.config.js module.exports = { printWidth: 120, tabWidth: 2, useTabs: false, singleQuote: true, semi: false, trailingComma: "none", bracketSpacing: true, jsxSingleQuote: true, jsxBracketSameLine: false, arrowParens: "avoid" } "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20241004/056cdbee99b4c9d99d14131d732c8019.png)
使用prettier是可以比较好的解决保存代码,代码末尾自动加分号的;但使用volar后对应的保存代码自动格式化就失效了,大家有好的解决方案吗?
如图所示,我如何配置保存成我想要的结果。 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20241121/1b4eb14ae00016e97e55fa212dba2bf3.png)
vue2.x 代码格式化应该用什么更好,vetur 还是 prettier? 如图 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20241115/8074d57c954ea2c89745c60eb8887767.png) 我知道 vetur 里格式化也可以配置 prettier 相关 但是用 vutur 更好呢?还是直接使用 prettier 找过一些相关文章,感觉两种说法都有
有大佬知道怎么使用eslint和prettier 配置成可以自动格式化代码成驼峰的吗。十分感谢。"一开始是这样有警告" (https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241102/5ff3f5aa50a9daf1d3c754d1ece0ebf6.png)"希望可以自动格式化成这个样子,有大佬做过吗。感激不尽。" (https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241102/2105c87c937636a53453a6e469f79267.png)"还有一个问题明明已经安装eslint-重启过-也重新安装过-为什么右键格式化程序还是没有eslint" (https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241102/139c702957c37f69d7a6b3387de41337.png) 希望能够自动格式化驼峰格式。