- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我们开始混入一些 es6 模块,当您在不使用 sourceType: 脚本的情况下使用 import/export 时,eslint 会公正地提示
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'at line 1 col 1
但是,如果我将 sourceType 更改为模块,那么每个具有“use strict”的文件;在顶部被标记为模块中不需要 use strict。
模块是我的 jsx 文件,我的 js 文件是 POJ,所以我需要两个 sourceTypes 才能运行。
关于如何强制 eslint 与模块和脚本一起工作有什么想法吗?我想避免运行两个单独的 eslintrc 文件和规则集,只是让一个是模块,另一个是脚本。
最佳答案
只要您的脚本有一个扩展名,而您的模块有一个不同的扩展名,那么您就可以有两种不同的配置。
// .eslintrc.json
{
// ...
// Your normal config goes here
// ...
}
使用 eslint .
对您的普通脚本进行检查,就像您一直在做的那样。它默认为 sourceType: "script"
,默认拉取 .eslintrc.json
,默认只检查 *.js
文件。
// .eslintrc.modules.json
{
"extends": "./.eslintrc.json",
"parserOptions": {
"sourceType": "module"
},
// You can have additional module-specific config here if you want
}
现在您可以使用 eslint --config .eslintrc.modules.json --ext .jsx .
只检查模块,这将拉取模块配置,这只是正常的扩展.eslintrc.json
,它只会检查 *.jsx
文件。
关于javascript - Eslint - 脚本和模块的 SourceType 混合体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36367656/
在eslint中有没有办法像规则和环境设置一样在文件中设置sourceType? 有点像 /*eslint sourceType: "module"*/ 没看过作品 最佳答案 eslint 的一位团队
我们开始混入一些 es6 模块,当您在不使用 sourceType: 脚本的情况下使用 import/export 时,eslint 会公正地提示 Parsing error: 'import' an
我正在使用 Gulp , Browserify和 Babelify将我的源代码从 ES6 + JSX 编译为纯 Javascript。 我的 gulpfile.js 看起来像: var gulp =
我的项目对大部分文件使用 Webpack 和 es6 模块。这些文件在浏览器中运行,并由 Webpack 捆绑。 只有少数文件在节点中运行。 Webpack 没有触及它们,我看不到将它们包含在 web
我正在尝试搜索扩展某个接口(interface)的 IJavaProject 中的所有类。这个接口(interface)是Generic的,我想获取每个实现的当前类型参数。 现在我有了代表每个实现的
我正在尝试执行我认为是调整刚刚通过 UIImagePickerControllerSourceTypeCamera 拍摄的图像大小的简单任务。 拍完照片后,我想立即缩小它。我可以保持纵横比并将其缩小到
我想以恒定的频率检索 UIImage 以实现某些功能 if (!_updateTimer) { _updateTimer = [[NSTimer scheduledTimerWithTimeI
我希望用户能够使用相机但不能选择拍摄视频。目前,当用户启动相机时,照片和视频控件都会显示在 View 的左下角。下面是我的 launchCamera 和 imagePickerController 方
我目前正在使用 Google Cloud Functions 和 Firestore。但是我在尝试从父文档获取数据时遇到了问题。我已经在 Internet 上搜索了该问题,但似乎建议的修复方法都不适合
我花了几天时间在互联网上搜索这个问题的解决方案(请不要将其标记为重复!)。我正在尝试使用 ES6 导入: import * as _ from 'underscore'; Stream
我正在做一堆应用数学/信号处理/算法 C++ 代码。 我已经启用了 -Wconversion编译器警告捕获类型为 double 的数字的运行时转换等问题输入 int32_t . 显然,在这些转换过程中
我正在使用 Vue。这就是我在 gulpfile 中构建的方式: browserify('./main.js') .transform(vueify) .bundle() .pipe( fs.crea
我从 3.0.3 更新了 Cypress 至3.1.3 .我正在使用必须与文档相关的 ES6 导入/导出模块。但我收到了 undefined在终端中并在 GUI 中出现以下错误: /node_modu
在我的 gulpfile 中,我有 var gulp = require('gulp'); var browserSync = require('browser-sync').create(); va
考虑以下两个文件: app.js import Game from './game/game'; import React from 'react'; import ReactD
我有 2 个选项卡,一个包含 imagepicker Controller ,另一个包含 UItableView 作为 uiview Controller 的 subview 。 我意识到当我调用 i
我在 github 和 stackoverflow 上浏览过很多帖子。我的 package.json 中有以下开发依赖项,用于 es6 到 es5 的转换。 "babel-cli": "^6.26.0
背景 我正在使用 docusaurus ^1.14.0。我只使用 React。在我的 pages 中,我尝试使用基本的 import 语句从另一个文件导入组件来分离组件。但是,当我尝试 yarn st
当通过 angular-cli (ng test -cc) 运行具有代码覆盖率的测试时,karma 会抛出以下错误。罪魁祸首似乎是 istanbul 代码覆盖模块,因为在没有 -cc 的情况下运行测试
使用全新安装的 ionic2 开发新项目,安装 angular2-jwt 后出现此错误: ParseError: 'import' and 'export' may appear only with
我是一名优秀的程序员,十分优秀!