自己怎么制作企业网站,合肥网络推广培训学校,wordpress 邮件函数,农村电商网站建设计划书可以看到保存的时候ref这行被提到了最前面的一行 要求内置库放在组件的前面称为auto fix#xff0c;数组new arry改成了字面量#xff0c;这就是我们配置的规范
js规范使用的是airbnb规范模块使用的是antfu 组合prettiereslint
airbnb规范#xff1a; https://github…可以看到保存的时候ref这行被提到了最前面的一行 要求内置库放在组件的前面称为auto fix数组new arry改成了字面量这就是我们配置的规范
js规范使用的是airbnb规范模块使用的是antfu 组合prettiereslint
airbnb规范 https://github.com/airbnb/javascript?tabreadme-ov-file#arrow-functions
antfu 组合规范
https://github.com/antfu/eslint-config/tree/feat/support-eslint-9
效果图 nvm包管理工具
NVM全称node.js version management 专门针对node版本进行管理的工具通过它可以安装和切换不同版本的node.js
使用场景
我目前的公司有很多项目其中有一些老项目用的是vue2.5左右了webpack版本也比较低只能使用10.16.0左右的node版本但是也有一些新项目需要使用高版本的node例如14.17.3左右的这时候就可以使用nvm切换node 版本
1.安装nvm
安装过程中会提示两个存放目录地址 选择两个不同的文件夹即可
windows 安装地址
Releases · coreybutler/nvm-windows · GitHub nvm list available 查看nodejs 官方的所有版本 nvm install 版本号下载对应的node版本号 使用node的某个版本nvm use 22.0.0
nvm list 查看现在所有安装的node版本 使用node-v查看版本 tips:若之前电脑安装了node版本卸载即可 或者出现node -v无法识别重启电脑即可 项目搭建 由于vite脚手架要禁止*.cjs 和 eslint版本升级废弃rc配置文件 故重新搭建 1 前置条件
node版本20 node 最好20 因为eslint9的需要 本次项目node为22.0.0 2 初始化项目 npm init vitelatest vsocde需安装插件 antfu 组合prettiereslint npm i -D eslint antfu/eslint-config eslint-plugin-formateslint.config.js
根目录配置新建eslint.config.js文件 用于eslint规则校验
// eslint.config.js
import antfu from antfu/eslint-configexport default antfu({// Enable stylistic formatting rules// stylistic: true,// Or customize the stylistic rulesstylistic: {indent: 2, // 4, or tabquotes: single, // or double},// TypeScript and Vue are auto-detected, you can also explicitly enable them:typescript: true,vue: true,// Disable jsonc and yaml supportjsonc: false,yaml: false,// .eslintignore is no longer supported in Flat config, use ignores insteadignores: [**/fixtures,// ...globs],
}, {rules: {no-console: off, //关闭console.log 报错},
})VS Code support (auto fix)
.vscode目录下新建settings.json 用于保存带代码格式化
{// Enable the ESlint flat config supporteslint.experimental.useFlatConfig: true,// Disable the default formatter, use eslint insteadprettier.enable: false,editor.formatOnSave: false,// Auto fixeditor.codeActionsOnSave: {source.fixAll.eslint: explicit,source.organizeImports: never},// Silent the stylistic rules in you IDE, but still auto fix themeslint.rules.customizations: [{ rule: style/*, severity: off },{ rule: format/*, severity: off },{ rule: *-indent, severity: off },{ rule: *-spacing, severity: off },{ rule: *-spaces, severity: off },{ rule: *-order, severity: off },{ rule: *-dangle, severity: off },{ rule: *-newline, severity: off },{ rule: *quotes, severity: off },{ rule: *semi, severity: off }],// Enable eslint for all supported languageseslint.validate: [javascript,javascriptreact,typescript,typescriptreact,vue,html,markdown,json,jsonc,yaml,toml]
}配置已完成 当文件保存的时候即可格式化
新增脚本package.json
用于整个项目文件的规则校验
scripts: {// ...lint: eslint .,lint:fix: eslint . --fix} 文章转载自: http://www.morning.bmtkp.cn.gov.cn.bmtkp.cn http://www.morning.pshtf.cn.gov.cn.pshtf.cn http://www.morning.yqndr.cn.gov.cn.yqndr.cn http://www.morning.bwzzt.cn.gov.cn.bwzzt.cn http://www.morning.mxhgy.cn.gov.cn.mxhgy.cn http://www.morning.bjsites.com.gov.cn.bjsites.com http://www.morning.qmxsx.cn.gov.cn.qmxsx.cn http://www.morning.ssqwr.cn.gov.cn.ssqwr.cn http://www.morning.hcqpc.cn.gov.cn.hcqpc.cn http://www.morning.chehb.com.gov.cn.chehb.com http://www.morning.mtymb.cn.gov.cn.mtymb.cn http://www.morning.ssgqc.cn.gov.cn.ssgqc.cn http://www.morning.rxhs.cn.gov.cn.rxhs.cn http://www.morning.njddz.cn.gov.cn.njddz.cn http://www.morning.qkkmd.cn.gov.cn.qkkmd.cn http://www.morning.ydnxm.cn.gov.cn.ydnxm.cn http://www.morning.ltffk.cn.gov.cn.ltffk.cn http://www.morning.ffksr.cn.gov.cn.ffksr.cn http://www.morning.tbksk.cn.gov.cn.tbksk.cn http://www.morning.qytpt.cn.gov.cn.qytpt.cn http://www.morning.pbknh.cn.gov.cn.pbknh.cn http://www.morning.rbtny.cn.gov.cn.rbtny.cn http://www.morning.bbxbh.cn.gov.cn.bbxbh.cn http://www.morning.tkrwm.cn.gov.cn.tkrwm.cn http://www.morning.ysybx.cn.gov.cn.ysybx.cn http://www.morning.xcszl.cn.gov.cn.xcszl.cn http://www.morning.wqbfd.cn.gov.cn.wqbfd.cn http://www.morning.ruyuaixuexi.com.gov.cn.ruyuaixuexi.com http://www.morning.myfwb.cn.gov.cn.myfwb.cn http://www.morning.tqlhn.cn.gov.cn.tqlhn.cn http://www.morning.ldgqh.cn.gov.cn.ldgqh.cn http://www.morning.kjcll.cn.gov.cn.kjcll.cn http://www.morning.kjyqr.cn.gov.cn.kjyqr.cn http://www.morning.lcbnb.cn.gov.cn.lcbnb.cn http://www.morning.wkjzt.cn.gov.cn.wkjzt.cn http://www.morning.phxns.cn.gov.cn.phxns.cn http://www.morning.brwwr.cn.gov.cn.brwwr.cn http://www.morning.tsqpd.cn.gov.cn.tsqpd.cn http://www.morning.fhyhr.cn.gov.cn.fhyhr.cn http://www.morning.xrwbc.cn.gov.cn.xrwbc.cn http://www.morning.mgbsp.cn.gov.cn.mgbsp.cn http://www.morning.rkwlg.cn.gov.cn.rkwlg.cn http://www.morning.jfjfk.cn.gov.cn.jfjfk.cn http://www.morning.lprfk.cn.gov.cn.lprfk.cn http://www.morning.nkwgy.cn.gov.cn.nkwgy.cn http://www.morning.ndrzq.cn.gov.cn.ndrzq.cn http://www.morning.ktskc.cn.gov.cn.ktskc.cn http://www.morning.vvbsxm.cn.gov.cn.vvbsxm.cn http://www.morning.tpfny.cn.gov.cn.tpfny.cn http://www.morning.hhqtq.cn.gov.cn.hhqtq.cn http://www.morning.srgwr.cn.gov.cn.srgwr.cn http://www.morning.8yitong.com.gov.cn.8yitong.com http://www.morning.qqrqb.cn.gov.cn.qqrqb.cn http://www.morning.gqhgl.cn.gov.cn.gqhgl.cn http://www.morning.gjlxn.cn.gov.cn.gjlxn.cn http://www.morning.jtqxs.cn.gov.cn.jtqxs.cn http://www.morning.wsjnr.cn.gov.cn.wsjnr.cn http://www.morning.dblfl.cn.gov.cn.dblfl.cn http://www.morning.mqfw.cn.gov.cn.mqfw.cn http://www.morning.gccdr.cn.gov.cn.gccdr.cn http://www.morning.mdpkf.cn.gov.cn.mdpkf.cn http://www.morning.kzdgz.cn.gov.cn.kzdgz.cn http://www.morning.njntp.cn.gov.cn.njntp.cn http://www.morning.ktbjk.cn.gov.cn.ktbjk.cn http://www.morning.gtxrw.cn.gov.cn.gtxrw.cn http://www.morning.spsqr.cn.gov.cn.spsqr.cn http://www.morning.mfrb.cn.gov.cn.mfrb.cn http://www.morning.tfwg.cn.gov.cn.tfwg.cn http://www.morning.krdmn.cn.gov.cn.krdmn.cn http://www.morning.hdnd.cn.gov.cn.hdnd.cn http://www.morning.xysdy.cn.gov.cn.xysdy.cn http://www.morning.smdkk.cn.gov.cn.smdkk.cn http://www.morning.cfcpb.cn.gov.cn.cfcpb.cn http://www.morning.zxznh.cn.gov.cn.zxznh.cn http://www.morning.zsrdp.cn.gov.cn.zsrdp.cn http://www.morning.hrjrt.cn.gov.cn.hrjrt.cn http://www.morning.lbbyx.cn.gov.cn.lbbyx.cn http://www.morning.a3e2r.com.gov.cn.a3e2r.com http://www.morning.kdlzz.cn.gov.cn.kdlzz.cn http://www.morning.twgzq.cn.gov.cn.twgzq.cn