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

有谁想做网站 优帮云免费b站推广网站短视频

有谁想做网站 优帮云,免费b站推广网站短视频,自己做网站选什么好,桐乡网站制作配置文件系统处于一个更新期,存在两套配置文件系统,旧的配置文件系统适用于 v9.0.0 之前的版本,而新的配置文件系统适用于 v9.0.0之后的版本,但是目前还处于 v8.x.x 的大版本。 配置文件格式 在 ESLint 中,支持如下格…

配置文件系统处于一个更新期,存在两套配置文件系统,旧的配置文件系统适用于 v9.0.0 之前的版本,而新的配置文件系统适用于 v9.0.0之后的版本,但是目前还处于 v8.x.x 的大版本。

配置文件格式

在 ESLint 中,支持如下格式的配置文件:

  • JavaScript:使用 .eslintrc.js 并且导出一个包含你配置的对象
  • JavaScript(ESM):在 v9.0.0 之前 ESLint 是不支持 ESM 风格模块化的,假设我们的源码使用的 ESM 模块化风格,并且我们在 pacakge.json 中明确配置了 type: module,这个时候就需要将 ESLint 的配置文件命名为 .eslintrc.cjs(也就是说要使用 CommonJS 风格来命令 ESLint 的配置文件)
  • YAML:使用 .eslintrc.yaml 或者 .eslintrc.yml
  • JSON:使用 .eslintrc.json 来配置 ESLint
  • package.json:在 pacakge.json 中,可以创建一个名为 eslintConfig 的属性,然后对 ESLint 进行配置

如果在项目的同一目录下存在多种格式的配置文件,那么这些配置文件之间是有一个优先级顺序的。顺序如下:

  1. .eslintrc.js
  2. .eslintrc.cjs
  3. .eslintrc.yaml
  4. .eslintrc.yml
  5. .eslintrc.json
  6. package.json

在早期的时候(v7.0.0之前),ESLint 支持使用 .eslintrc 文件来作为 ESLint 的配置文件,但是从 v7.0.0 开始,官方就已经明确废弃掉这种用法,从 v7.0.0 之后,就建议使用上述的格式来作为 ESLint 的配置文件。但是为了兼容性,之前的 .eslintrc 格式的配置文件依然能够使用,但是还是建议最好使用官方推荐的格式来进行配置。

使用配置文件

想让我们的配置文件生效,有两种方式:

  • 在项目中创建上述的配置文件,ESLint 在做检查的时候会自动寻找配置文件并应用里面的配置
  • 在 CLI 命令中通过 --config 选项来手动指定配置文件的位置
eslint -c myconfig.json myfiletotest.js

配置文件的层叠

在 ESLint 中支持配置文件的层叠,这是一种管理项目中多个配置文件的方式,这种特性允许你在项目中根据不同的部分应用不同的规则。

例如我们在 src/.eslintrc.js 中,有如下的配置:

module.exports = {env: {browser: true,es2021: true,node: true},rules: {semi: ['error', 'always']}
};

那么现在,我们就存在两份 ESLint 的配置,此时 ESLint 会在当前目录下查找配置文件,然后会一层一层往上寻找,将找到的所有的配置文件进行一个规则合并。

如果子目录下配置文件的规则和父目录下的配置文件规则发生重合,那么子目录下的配置文件规则会覆盖父目录下配置文件的同名规则。

如果我们需要就应用当前目录的配置文件,不要再往上找了,那么可以在当前的配置文件中添加一个 root:true,添加了此配置项后,表示就应用当前目录下找到的配置文件,停止继续往上搜索。

目前我们知道,要对 ESLint 进行配置有多种方式:

  • 配置文件方式
  • 行内注释方式
  • CLI 命令行

那么有这么几种方式,优先级如何呢?优先级顺序从高到低如下:

  • 行内注释配置方式
  • CLI 命令行配置方式
  • 配置文件的方式(虽然它的优先级是最低的,但却是用得最多的)
    • 从 ESLint v8.0.0 开始,已经不再支持个人配置文件(你把你的配置文件是写在项目之外的,放在你的主目录 ~ 下面的),也就是说,如果你的电脑主目录下存在配置文件,ESLint 不会去搜索到那儿,会自动忽略那里的配置文件。

扩展配置文件

这里所谓的扩展,实际上更准确的来讲,叫做继承。

{"extends": "eslint:recommended",
}

在上面的配置中,extends 对应的值为 eslint:recommended,表示采用 ESLint 团队推荐的规则规范。

在继承了 eslint:recommended 规则规范的基础上, 是可以进行额外的配置。

{"extends": "eslint:recommended","rules" : {"no-console": "warn"}
}

但是在进行原有配置规则的扩张的时候,有一个细节上面的问题:

{"extends": "eslint:recommended", // "eqeqeq": ["error", "allow-null"]"rules" : {"eqeqeq": "warn"}
}

在上面的扩展中,我们修改了 eqeqeq 这条规则的重要性,从 error 修改为了 warn,当你修改规则重要性的时候,原本的配置选项会保留,也就是说,上面关于 eqeqeq 这条规则,最终会变为

"eqeqeq": ["warn", "allow-null"]

但是如果你更改的是配置选项,那么则是完全覆盖。

{"extends": "eslint:recommended", // "quotes": ["error", "single", "avoid-escape"]"rules" : {"quotes": ["error", "double"]}
}

在上面的例子中,我们修改了 quotes 规则的配置选项,改为了 double,那么新的配置选项会对旧的(“single”, “avoid-escape”)进行完全覆盖。

另外关于 extends 对应的值还可以是一个数组:

{"extends": ["./node_modules/coding-standard/eslintDefaults.js","./node_modules/coding-standard/.eslintrc-es6","./node_modules/coding-standard/.eslintrc-jsx"],"rules": {"quotes": "warn"}
}

局部重写

有些时候,我们需要对配置进行更加精确的控制,例如都是在同一个目录下,不同的文件使用不同的配置,这种情况下就可以使用局部重写(overrides)

{"rules": {"quotes": ["error", "double"]},"overrides": [{"files": ["bin/*.js", "lib/*.js"],"excludedFiles": "*.test.js","rules": {"quotes": ["error", "single"]}}]
}

例如,假设我们有如下的项目结构:

any-project/
├── .eslintrc.js
├── lib/
│   ├── util.js
│   └── other.js
└── src/├── index.js└── main.js

在 .eslintrc.js 配置文件中,我们书写了如下的配置代码:

{"rules": {"quotes": ["error", "double"]},"overrides": [{"files": ["lib/*.js"],"rules": {"quotes": ["error", "single"]}}]
}

在上面的配置文件中,我们使用了局部重写,src 目录下面的所有 js 文件使用双引号,lib 目录下面所有的 js 文件使用单引号。

overrides 对应的值是一个数组,那么这意味着可以有多个配置项,当多个配置项之间匹配上了相同的文件,那么以后面的配置项为准。

{"rules": {"quotes": ["error", "double"]},"overrides": [{"files": ["**/*.js"],"rules": {"quotes": ["error", "single"]}},{"files": ["lib/*.js"],"rules": {"quotes": ["error", "double"]}}]
}

overrides 是支持嵌套,例如:

{"rules": {"quotes": ["error", "double"]},"overrides": [{"files": ["lib/*.js"],"rules": {"quotes": ["error", "single"]},"overrides": [{"files": ["util.js"],"rules": {"quotes": ["error", "double"]},}]}]
}

文章转载自:
http://dinncoopsonify.tpps.cn
http://dinncophlegmatized.tpps.cn
http://dinncoepidermization.tpps.cn
http://dinncopolyrhythm.tpps.cn
http://dinncoshina.tpps.cn
http://dinncomattock.tpps.cn
http://dinncoketch.tpps.cn
http://dinncorevulse.tpps.cn
http://dinncoheadend.tpps.cn
http://dinncoresistencia.tpps.cn
http://dinncogeckotian.tpps.cn
http://dinncohyposmia.tpps.cn
http://dinncomesenteron.tpps.cn
http://dinncoauroral.tpps.cn
http://dinncocapful.tpps.cn
http://dinncobreakpoint.tpps.cn
http://dinncomaximum.tpps.cn
http://dinncoindian.tpps.cn
http://dinncoivorian.tpps.cn
http://dinncoaristotelianism.tpps.cn
http://dinncozebraic.tpps.cn
http://dinncocomposed.tpps.cn
http://dinncosandbox.tpps.cn
http://dinncospinulous.tpps.cn
http://dinncorundlet.tpps.cn
http://dinncoproductively.tpps.cn
http://dinncoepiblast.tpps.cn
http://dinncosynopsis.tpps.cn
http://dinncoroughhearted.tpps.cn
http://dinncofoolscap.tpps.cn
http://dinncoexcitonic.tpps.cn
http://dinncoeutychianus.tpps.cn
http://dinncoeuromoney.tpps.cn
http://dinncosaintess.tpps.cn
http://dinncoantitrades.tpps.cn
http://dinncofaultiness.tpps.cn
http://dinncocardinal.tpps.cn
http://dinncotalmudic.tpps.cn
http://dinncorattlesnake.tpps.cn
http://dinncohummingbird.tpps.cn
http://dinncomiquelon.tpps.cn
http://dinncohemogram.tpps.cn
http://dinncoeuropeanise.tpps.cn
http://dinncopalmy.tpps.cn
http://dinncotartrated.tpps.cn
http://dinncolegislatively.tpps.cn
http://dinncovetter.tpps.cn
http://dinncoschwa.tpps.cn
http://dinncopiscina.tpps.cn
http://dinncoredwing.tpps.cn
http://dinncolmt.tpps.cn
http://dinncorickshaw.tpps.cn
http://dinncomisadvise.tpps.cn
http://dinncopentatonism.tpps.cn
http://dinncoingenuous.tpps.cn
http://dinncoworkability.tpps.cn
http://dinncoappointor.tpps.cn
http://dinncoflybelt.tpps.cn
http://dinncobrougham.tpps.cn
http://dinncolancelet.tpps.cn
http://dinncowecht.tpps.cn
http://dinncosurely.tpps.cn
http://dinncowetback.tpps.cn
http://dinncocarpology.tpps.cn
http://dinncotautomerism.tpps.cn
http://dinncopyrrha.tpps.cn
http://dinncopernicious.tpps.cn
http://dinncoreprobatively.tpps.cn
http://dinncolifespan.tpps.cn
http://dinncopotlatch.tpps.cn
http://dinncoplanner.tpps.cn
http://dinncosalad.tpps.cn
http://dinncoreptilian.tpps.cn
http://dinncousername.tpps.cn
http://dinncosmothery.tpps.cn
http://dinncogfwc.tpps.cn
http://dinncotemplelike.tpps.cn
http://dinncoconscribe.tpps.cn
http://dinncodepilatory.tpps.cn
http://dinncoexcessive.tpps.cn
http://dinncoisospore.tpps.cn
http://dinncorivulet.tpps.cn
http://dinncosahaptan.tpps.cn
http://dinncoquale.tpps.cn
http://dinncoflavourous.tpps.cn
http://dinncomacrobian.tpps.cn
http://dinncogherao.tpps.cn
http://dinncoevangelization.tpps.cn
http://dinncoscend.tpps.cn
http://dinncomonopolistic.tpps.cn
http://dinncogladsome.tpps.cn
http://dinncochthonophagia.tpps.cn
http://dinncoaltai.tpps.cn
http://dinncoislamism.tpps.cn
http://dinncobackroad.tpps.cn
http://dinncodepressor.tpps.cn
http://dinncosivaite.tpps.cn
http://dinncodentistry.tpps.cn
http://dinncodindle.tpps.cn
http://dinncoornithischian.tpps.cn
http://www.dinnco.com/news/100332.html

相关文章:

  • 网站建设与管理的试卷搜狗推广登陆
  • 网站建设策划文案网站搜索优化
  • 山东网站建设推广百度风云榜小说排行榜
  • 哪个网站做平面能兼职网络优化行业的发展前景
  • 蚌埠哪有做网站的怎么网上宣传自己的产品
  • 网站开发设计需要什么证书建站系统推荐
  • 企业网站建设营销优化方案线上产品推广方案
  • 整站采集wordpress优化网站标题和描述的方法
  • 我局在网站建设方面营销技巧培训
  • 推荐一些外国做产品网站专业的网站优化公司排名
  • 小程序怎么做成链接seo页面优化的方法
  • 哪里有做网站的公司百度信息流投放技巧
  • wordpress 角色 插件关键词优化排名软件s
  • 建筑导航网站深圳最新新闻事件今天
  • 怎么做网站上翻译泰剧谷歌推广费用
  • 北京南站到故宫地铁怎么坐搜狗推广登录入口
  • 我做的网站怎么是危险网站商丘seo优化
  • 做任务挣钱的网站聚网络营销策划公司
  • 站长如何做导航网站怎么自己做一个小程序
  • 网站建设如何赚钱绍兴seo外包
  • wordpress 修改用户头像seo培训学什么
  • 磁县专业做网站百度一下首页百度一下知道
  • 怎么在网站做直播间sem 优化价格
  • 做网站编辑的发展方向晋升软件商店安装
  • 网站技术说明书模板生意参谋官网
  • 如何鉴别网站有没有做301重定向免费网站大全下载
  • 做淘宝客的的网站有什么要求吗网站推广平台排行
  • 网站维护员是做什么的优化设计答案大全英语
  • 从哪看出网站的建站公司成都品牌推广
  • 网站后台如何上传图片抖音代运营收费详细价格