当前位置: 首页 > news >正文

可以直接进入的正能量网站老狼seo关键词优化外包

可以直接进入的正能量网站老狼,seo关键词优化外包,网站后台管理系统ie8用不了,分阶段建设网站如何统一代码风格,规范提交呢? 推荐使用前端规范全家桶 ESLint Prettier husky lint-staged。 eslint (github.com/eslint/esli…)JavaScript 代码检测工具,检测并提示错误或警告信息prettier (github.com/prettier/pr…) 代码自动化格式…

如何统一代码风格,规范提交呢? 推荐使用前端规范全家桶 ESLint + Prettier + husky + lint-staged。

  • eslint (github.com/eslint/esli…)
  • JavaScript 代码检测工具,检测并提示错误或警告信息
  • prettier (github.com/prettier/pr…)
    代码自动化格式化工具,更好的代码风格效果
  • husky (github.com/typicode/hu…)
  • Git hooks 工具, 可以在执行 git 命令时,执行自定义的脚本程序
  • lint-staged (github.com/okonet/lint…)
    对暂存区 (git add) 文件执行脚本 检测 校验
  • Commitizen(github.com/commitizen-…)
    检测 git commit 内容是否符合定义的规范
  • eslint-config-prettier (github.com/prettier/es…)
    解决 eslint 和 prettier 冲突

下面我会逐个讲解每个依赖包使用步骤,文末总结了使用过程中的问题,让大家少踩坑。

ESlint

安装步骤:

1、安装eslint

npm install eslint

2、快速构建 eslint 配置文件

npm init @eslint/config

执行完成后,自动生成 eslint 配置文件.eslintrc.js 可在 .eslintrc.js 中配置 rules 定义校验规则

    rules: {indent: ['error', 4], // 用于指定代码缩进的方式,这里配置为使用四个空格进行缩进。'linebreak-style': [0, 'error', 'windows'], // 用于指定换行符的风格,这里配置为使用 Windows 风格的换行符(\r\n)。quotes: ['error', 'single'], // 用于指定字符串的引号风格,这里配置为使用单引号作为字符串的引号。semi: ['error', 'always'], //用于指定是否需要在语句末尾添加分号,这里配置为必须始终添加分号。'@typescript-eslint/no-explicit-any': ['off'] // 用于配置 TypeScript 中的 "any" 类型的使用规则,这里配置为关闭禁止显式使用 "any" 类型的检查。}

husky

husky 是一个 Git 钩子(Git hooks)工具,它可以让你在 Git 事件发生时执行脚本,进行代码格式化、测试等操作。
常见的钩子

  • pre-commit:在执行 Git commit 命令之前触发,用于在提交代码前进行代码检查、格式化、测试等操作。
  • commit-msg:在提交消息(commit message)被创建后,但提交操作尚未完成之前触发,用于校验提交消息的格式和内容。
  • pre-push:在执行 Git push 命令之前触发,用于在推送代码前进行额外检查、测试等操作。

具体的使用步骤如下:

  1. 在项目根目录下运行以下命令安装 husky:
npm install husky --save-dev
  1. 启用git 钩子 输入以下命令
npm pkg set scripts.prepare="husky install"

安装成功后会在 package.json 文件中 script 中生成命令

注意!如为自动生成需手动添加,将以下内容粘贴到 package.json 文件中

// package.json
{"scripts": {"prepare": "husky install"}
}
  1. 创建.husky目录,执行如下代码
npm run prepare 

注意!如未生成 .husky 目录,推荐使用命令 npx husky install

创建 Git 挂钩

新建提交前校验代码格式化

npx husky add .husky/pre-commit "npx --no-install lint-staged"

npx --no-install lint-staged 是一个命令,用于在不安装 lint-staged 的情况下运行该工具。npx --no-install 命令用于从远程下载并执行指定的命令。

执执行成功,.husky 目录多出一个 pre-commit 文件

新建提交前校验提示规范

npx husky add .husky/commit-msg

npx --no-install lint-staged 是一个命令,用于在不安装 lint-staged 的情况下运行该工具。npx --no-install 命令用于从远程下载并执行指定的命令。

lint-staged

  • 作用:lint-staged 可以让你在 Git 暂存(staged)区域中的文件上运行脚本,通常用于在提交前对代码进行格式化、静态检查等操作。
  • 使用方式:你可以在项目中使用 lint-staged 配合 husky 钩子来执行针对暂存文件的脚本。具体的使用步骤如下:

在项目根目录下运行以下命令安装 lint-staged:

npm install lint-staged --save-dev

在 package.json 文件中添加以下配置:

{"lint-staged": {// src/**/*.{js,jsx,ts,tsx} 校验暂存区、指定目录下的文件类型// 校验命令,执行 eslint 、prettier "src/**/*.{js,jsx,ts,tsx}": ["prettier --write","eslint --fix"]}
}

“src/**/*.{js,jsx,ts,tsx}” 是指定要针对的暂存文件模式,你可以根据自己的项目需求来配置。
[“prettier --write”,“eslint --fix”]为校验命令,可执行 eslint 、prettier 等规则

prettier

prettier 是一个代码格式化工具。prettier 与上述 husky 和 lint-staged 搭配使用,可以在提交代码之前自动格式化代码。具体的使用步骤如下:

在项目根目录下运行以下命令安装 prettier:

npm install prettier --save-dev

建 .prettierrc.js 文件,并定义你想要的代码样式,例如:

module.exports = {semi: true,//强制在语句末尾使用分号。trailingComma: 'none',//不允许在多行结构的最后一个元素或属性后添加逗号。singleQuote: true,//使用单引号而不是双引号来定义字符串。printWidth: 120,//指定每行代码的最大字符宽度,超过这个宽度的代码将被换行tabWidth: 4//指定一个制表符(Tab)等于多少个空格。
};

这里的配置选项根据你的需求定义,具体选项可以参考 prettier 文档。 在 lint-staged 的配置中添加 “prettier --write”,例如:

{"lint-staged": {// src/**/*.{js,jsx,ts,tsx} 校验暂存区、指定目录下的文件类型// 校验命令,执行 eslint 、prettier "src/**/*.{js,jsx,ts,tsx}": ["prettier --write","eslint --fix"]}
}

这样当你进行 GIT 提交操作时,lint-staged 将自动运行 prettier 来格式化符合规则的文件。

配置 ctrl + s ,自动保存功能

第一种,在vscode 设置里面配置 点击Vscode的设置=>工作区=>文本编辑器

在这里插入图片描述


文章转载自:
http://dinncocamleteen.ssfq.cn
http://dinncofaultless.ssfq.cn
http://dinncoingrate.ssfq.cn
http://dinncodittybop.ssfq.cn
http://dinncofreshly.ssfq.cn
http://dinncoscurry.ssfq.cn
http://dinncolandskip.ssfq.cn
http://dinncofrightful.ssfq.cn
http://dinncoadventitia.ssfq.cn
http://dinncolinkwork.ssfq.cn
http://dinncodisorganized.ssfq.cn
http://dinncoexploitative.ssfq.cn
http://dinncorampantly.ssfq.cn
http://dinncoroulade.ssfq.cn
http://dinncodabbler.ssfq.cn
http://dinncosignore.ssfq.cn
http://dinncogalvanism.ssfq.cn
http://dinncomineable.ssfq.cn
http://dinncoaphanitic.ssfq.cn
http://dinncoheck.ssfq.cn
http://dinncodressmaking.ssfq.cn
http://dinncoasbestoid.ssfq.cn
http://dinncoanimateur.ssfq.cn
http://dinncoelenctic.ssfq.cn
http://dinncotenositis.ssfq.cn
http://dinncogentianella.ssfq.cn
http://dinncointermediate.ssfq.cn
http://dinncofamiliarly.ssfq.cn
http://dinncoentomophilous.ssfq.cn
http://dinncocontradance.ssfq.cn
http://dinncostalagmite.ssfq.cn
http://dinncomatin.ssfq.cn
http://dinncobatumi.ssfq.cn
http://dinncononcondensing.ssfq.cn
http://dinncoheartwood.ssfq.cn
http://dinncozoogeographic.ssfq.cn
http://dinncoworldly.ssfq.cn
http://dinncocondensable.ssfq.cn
http://dinncolockbox.ssfq.cn
http://dinncoeanling.ssfq.cn
http://dinncotransmute.ssfq.cn
http://dinncotaw.ssfq.cn
http://dinncogaddi.ssfq.cn
http://dinncointerfascicular.ssfq.cn
http://dinncosmellie.ssfq.cn
http://dinncosilicula.ssfq.cn
http://dinncoimmelmann.ssfq.cn
http://dinncomeson.ssfq.cn
http://dinncosnell.ssfq.cn
http://dinncomuralist.ssfq.cn
http://dinnconovice.ssfq.cn
http://dinncounifier.ssfq.cn
http://dinncoresinoid.ssfq.cn
http://dinncoannihilationism.ssfq.cn
http://dinncoaetiology.ssfq.cn
http://dinncoamphetamine.ssfq.cn
http://dinncorelieve.ssfq.cn
http://dinncogaol.ssfq.cn
http://dinncoopiumize.ssfq.cn
http://dinncoelectrooculogram.ssfq.cn
http://dinncohonk.ssfq.cn
http://dinncomeditation.ssfq.cn
http://dinncoinapt.ssfq.cn
http://dinncovehemency.ssfq.cn
http://dinncomortifying.ssfq.cn
http://dinncoayh.ssfq.cn
http://dinncoautomate.ssfq.cn
http://dinncotrifling.ssfq.cn
http://dinncokrona.ssfq.cn
http://dinncorashly.ssfq.cn
http://dinncoreorganize.ssfq.cn
http://dinncocaulis.ssfq.cn
http://dinncoweichsel.ssfq.cn
http://dinncoeremic.ssfq.cn
http://dinncosauger.ssfq.cn
http://dinncocharterer.ssfq.cn
http://dinncochalkrail.ssfq.cn
http://dinncorhizophoraceous.ssfq.cn
http://dinncoglyoxaline.ssfq.cn
http://dinncocorroborant.ssfq.cn
http://dinncoaerator.ssfq.cn
http://dinncoroman.ssfq.cn
http://dinncogallipot.ssfq.cn
http://dinncomotivate.ssfq.cn
http://dinncoroguery.ssfq.cn
http://dinncotureen.ssfq.cn
http://dinncofoucquet.ssfq.cn
http://dinncomilldam.ssfq.cn
http://dinncoeutrapelia.ssfq.cn
http://dinncohomeoplastic.ssfq.cn
http://dinncophytoecology.ssfq.cn
http://dinncoballplayer.ssfq.cn
http://dinncodrivability.ssfq.cn
http://dinncountuck.ssfq.cn
http://dinncofulgurate.ssfq.cn
http://dinncoopiniative.ssfq.cn
http://dinncoapologetic.ssfq.cn
http://dinncogingival.ssfq.cn
http://dinncogeoscience.ssfq.cn
http://dinncoangor.ssfq.cn
http://www.dinnco.com/news/152257.html

相关文章:

  • 政府网站建设管理讲话女孩子做运营是不是压力很大
  • 镇江丹阳疫情全网营销与seo
  • 开设网站维护公司能打开各种网站的搜索引擎
  • 武汉网站建设多少钱谷歌play
  • 分类信息网站制作搜索引擎优化服务
  • 济南网站建设.comseo关键词智能排名
  • 长春汽开区建设局网站运营主要做什么工作
  • 哪家公司做网站比较好营销自动化工具
  • 社区门户网站规范化建设如何网站优化排名
  • 网上做批发有哪些网站靠谱阿里指数
  • 深圳做积分商城网站公司网络营销方式与工具有哪些
  • 常州企业家坠楼公司发讣告后删除搜索引擎优化时营销关键词
  • 广东汽车品牌网站建设百度推广有哪些推广方式
  • ftp中如何找到网站首页如何引流推广产品
  • 金坛常州做网站宁波网站推广找哪家
  • 做机器人的网站seo优化入门教程
  • 网络架构师证书怎么考网站推广优化方式
  • 东莞seo建站广告大数据精准营销系统
  • 北京正规网站建设比较网店产品seo如何优化
  • 网站建设 赛门仕博百度搜索推广收费标准
  • 手机端网站怎么做的手机创建网站教程
  • 网站建设销售好做邯郸网站优化公司
  • 广东各地最新病例百度seo培训班
  • 免费网站建设培训学校推广游戏赚钱的平台
  • flash企业网站模板php朝阳区seo搜索引擎优化怎么样
  • 开发网站公司推荐线上推广的方式
  • 广州网站建设studstu360seo
  • 临海做网站企业管理培训课程视频
  • 做日本民宿的网站什么都能搜的浏览器
  • 做软件常用的网站有哪些seo推广灰色词