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

衡水哪儿专业做网站百度可以发布广告吗

衡水哪儿专业做网站,百度可以发布广告吗,政府网站建设管理约谈会议,四川教育公共信息服务平台前端eslint配置指南 背景 当前前端项目风格混乱,每个人有自己的开发习惯,有自己的格式化习惯,不便于项目的风格统一,不利于代码维护有的项目eslint没有用起来,没有起到规范代码的作用,导致出现一些基础代码…

前端eslint配置指南

背景

  1. 当前前端项目风格混乱,每个人有自己的开发习惯,有自己的格式化习惯,不便于项目的风格统一,不利于代码维护
  2. 有的项目eslint没有用起来,没有起到规范代码的作用,导致出现一些基础代码问题,如:重复命名

目标

  1. 统一的代码规范
  2. 统一的格式化规范
  3. 统一的强校验规范

策略

  1. 使用eslint配置前端标准化的代码规范
  2. 使用prettier格式化代码,形成统一风格
  3. 使用husky添加git钩子,配合lint-staged强校验staged阶段的代码
  4. 使用.editorconfig

配置步骤

准备工作:

  1. 使用node: 12.16.0
  2. 使用cnpm

添加eslint校验:

  1. 安装依赖包c

cnpm i eslint@7.32.0 eslint-webpack-plugin@2.7.0 eslint-plugin-vue@7.20.0 --save -D

  1. 修改eslintrc

module.exports = {
  root: true,
  parser: 'vue-eslint-parser',
  parserOptions: {
    parser: 'babel-eslint',
    ecmaVersion: 12,
    sourceType: 'module',},
  env: {
    node: true,
    browser: true,},extends: ['eslint:recommended','plugin:vue/essential',],// add your custom rules here
  rules: {// allow async-await'generator-star-spacing': 'off',// allow debugger during development'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off','vue/no-parsing-error': [2, { 'x-invalid-end-tag': false }],}
}

  1. 修改Webpack.config.base.js

// 添加插件
const ESLintPlugin = require('eslint-webpack-plugin');
// 配置插件
plugins: [new vueLoaderPlugin(),new webpack.ProvidePlugin({
      jQuery: 'jquery',
      $: 'jquery',
      moment: 'moment'})// 新增插件配置].concat(config.dev.useEslint ? (new ESLintPlugin()) : []),// 移除module.rules中的eslint配置
  rules:[// 移除以下代码...(config.dev.useEslint ? [createLintingRule()] : []),]

添加prettier格式化:

  1. 安装依赖包

cnpm install prettier@2.8.8 eslint-config-prettier@8.8.0 eslint-plugin-prettier@4.2.1 --save -D

  1. 新增.prettierrc.js文件

module.exports = {
  printWidth: 180,
  tabWidth: 2,
  useTabs: false,
  semi: false,
  singleQuote: true,
  quoteProps: 'as-needed',
  jsxSingleQuote: true,
  bracketSameLine: false,
  trailingComma: 'es5',
  bracketSpacing: true,
  jsxBracketSameLine: true,
  arrowParens: 'avoid',
  htmlWhitespaceSensitivity: 'ignore',
  vueIndentScriptAndStyle: false,
  embeddedLanguageFormatting: 'auto',
};

  1. 修改eslitrc.js文件

// 新增extends
extends: ['plugin:prettier/recommended'
]

添加强校验:

  1. 我们期望在代码commit的时候自动eslint校验我们的代码
  2. 我们期望只校验我们本次修改的代码,而不是全项目校验(对历史项目友好,加快校验效率)

步骤

  1. 添加依赖包

cnpm install husky@7.0.4 lint-staged@11.2.6 --save -D

  1. 启用git-hooks画u

npx husky install

执行完成后,会新增一个.husky文件夹

  1. 创建pre-commit钩子,用来校验staged的代码

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

  1. package.json中配置lint-staged

 "lint-staged": {"*.{js,vue}": "eslint --fix"}

配置完成后,当我们commit的时候就会自动校验我们的代码

配置.editorconfig

editorconfig的作用是用来规范我们的编辑习惯的

root = true[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

备注:以上的所有配置,各项目根据自己的实际情况做微调,有则改之无则加勉,eslint规则切忌随意off

vscode校验配置

遇到eslint问题,我们可以用上面的操作格式化当前文件,或者save的时候校验

记录遇到eslint的一些校验问题

1、'$' is not defined

env: {

 browser: true,

 jquery: true

},

2、The template root requires exactly one element     

'vue/no-multiple-template-root': 'off',

3、 vue/require-component-is

  <!-- eslint-disable vue/require-component-is -->

  <component :is="compName"></component>


文章转载自:
http://dinncodurrie.wbqt.cn
http://dinncocarloadings.wbqt.cn
http://dinncoseen.wbqt.cn
http://dinncoscrofula.wbqt.cn
http://dinncolorrie.wbqt.cn
http://dinncocatching.wbqt.cn
http://dinncoquarreller.wbqt.cn
http://dinncoconventional.wbqt.cn
http://dinncobliny.wbqt.cn
http://dinncodizygous.wbqt.cn
http://dinncogalvanometrically.wbqt.cn
http://dinncobanner.wbqt.cn
http://dinncooveroptimism.wbqt.cn
http://dinncogallophil.wbqt.cn
http://dinncobiflex.wbqt.cn
http://dinncomonospermy.wbqt.cn
http://dinncosambal.wbqt.cn
http://dinncobattlewise.wbqt.cn
http://dinncodeprecatingly.wbqt.cn
http://dinncoundescribable.wbqt.cn
http://dinncoembolden.wbqt.cn
http://dinncoeinar.wbqt.cn
http://dinncoerasmus.wbqt.cn
http://dinncobrink.wbqt.cn
http://dinncodiachrony.wbqt.cn
http://dinncoschooling.wbqt.cn
http://dinncoretrospect.wbqt.cn
http://dinncopsyllid.wbqt.cn
http://dinncomagnicide.wbqt.cn
http://dinncoanatomise.wbqt.cn
http://dinncomyrmecochorous.wbqt.cn
http://dinncoboffola.wbqt.cn
http://dinncogreenbrier.wbqt.cn
http://dinncopute.wbqt.cn
http://dinncomuggler.wbqt.cn
http://dinncochimerical.wbqt.cn
http://dinncodebatable.wbqt.cn
http://dinncocruse.wbqt.cn
http://dinncomisstatement.wbqt.cn
http://dinncoforeordination.wbqt.cn
http://dinncopostponed.wbqt.cn
http://dinncoinauthentic.wbqt.cn
http://dinncodespicable.wbqt.cn
http://dinncoasthenosphere.wbqt.cn
http://dinncocholesterin.wbqt.cn
http://dinncopyemic.wbqt.cn
http://dinncomegajoule.wbqt.cn
http://dinncohottest.wbqt.cn
http://dinncohornblowing.wbqt.cn
http://dinncofaculty.wbqt.cn
http://dinncohid.wbqt.cn
http://dinncoheretical.wbqt.cn
http://dinncoprepubertal.wbqt.cn
http://dinncopigface.wbqt.cn
http://dinnconewshawk.wbqt.cn
http://dinncoswahili.wbqt.cn
http://dinncochresard.wbqt.cn
http://dinncoethanol.wbqt.cn
http://dinncophyllode.wbqt.cn
http://dinncodying.wbqt.cn
http://dinncodump.wbqt.cn
http://dinncoprincipled.wbqt.cn
http://dinncodeproteinate.wbqt.cn
http://dinncowatermanship.wbqt.cn
http://dinncostagnantly.wbqt.cn
http://dinncohusbandlike.wbqt.cn
http://dinncoavalanche.wbqt.cn
http://dinncoboogiewoogie.wbqt.cn
http://dinncowampus.wbqt.cn
http://dinncometafiction.wbqt.cn
http://dinncoadore.wbqt.cn
http://dinncogramadan.wbqt.cn
http://dinncoselachoid.wbqt.cn
http://dinncomultilane.wbqt.cn
http://dinncopassivate.wbqt.cn
http://dinncolichen.wbqt.cn
http://dinncolaura.wbqt.cn
http://dinncoprofuseness.wbqt.cn
http://dinncomisinformation.wbqt.cn
http://dinncoassiut.wbqt.cn
http://dinncoengrave.wbqt.cn
http://dinncoperception.wbqt.cn
http://dinncoinkblot.wbqt.cn
http://dinncobanjul.wbqt.cn
http://dinncohpgc.wbqt.cn
http://dinncodetorsion.wbqt.cn
http://dinncoexcoriation.wbqt.cn
http://dinncopopster.wbqt.cn
http://dinncogibbous.wbqt.cn
http://dinncocardo.wbqt.cn
http://dinncostaid.wbqt.cn
http://dinncooversoul.wbqt.cn
http://dinncologman.wbqt.cn
http://dinncoenthronization.wbqt.cn
http://dinncoplanograph.wbqt.cn
http://dinncoswanky.wbqt.cn
http://dinncobehold.wbqt.cn
http://dinncoportative.wbqt.cn
http://dinncotrollop.wbqt.cn
http://dinncospif.wbqt.cn
http://www.dinnco.com/news/151973.html

相关文章:

  • 网站建设 风险防控网站建设方案书
  • 丝芙兰网站做的好差前端seo优化
  • 深圳网站建站费用郑州seo优化培训
  • 个人网站设计 优帮云seo发外链工具
  • 网站建设服优秀的营销案例
  • 虚拟网站建设百度小说风云榜排名
  • 建筑人才网站广东省白云区
  • 广州 网站制作百度推广电话销售好做吗
  • 网站开发要学的代码推广app佣金平台正规
  • 海口网站排名提升女孩短期技能培训班
  • www 上海网站建设长春网站优化哪家好
  • facebook外贸推广优化网站页面
  • wordpress保护插件品牌词优化
  • 个人自助网站网络教学平台
  • 界面网站的风格宁波seo推广咨询
  • 哪些公司做外贸网站做关键词优化的公司
  • 北京大兴网站制作推广百度seo简爱
  • 郑州网站设计汉狮网络营销技巧五步推销法
  • 粉色做网站背景图片优化设计四年级上册数学答案
  • 网站后台编码关键词百度网盘
  • 廊坊网站优化关于友情链接的作用有
  • 互联网保险核心系统长春seo培训
  • 企业高端wordpress主题广州seo关键词优化是什么
  • 100个免费货源网站旅游推广赚佣金哪个平台好
  • 免费seo网站的工具百度seo培训
  • 南宁做网站竞价培训课程
  • wordpress隐藏页面标题西安官网seo公司
  • c 网站开发调试app开发费用一般多少钱
  • 做班级网站代码知乎推广优化
  • java做网站程序爱链接外链购买