[英]Converting eslint config from json to JavaScript throws error when exporting config
I am trying to convert my eslint config from json to JavaScript.我正在尝试将我的 eslint 配置从 json 转换为 JavaScript。
After exporting a config object from .eslintrc.js like it sys in the docs :从 .eslintrc.js 中导出配置对象后,如文档中的sys :
JavaScript - use .eslintrc.js and export an object containing your configuration.
JavaScript - 使用 .eslintrc.js 并导出包含您的配置的对象。
I get the error:我收到错误:
(function (exports, require, module, __filename, __dirname) { export default {
^^^^^^
SyntaxError: Unexpected token export
at new Script (vm.js:83:7)
This is the first couple of lines of my config:这是我的配置的前几行:
export default {
env: {
browser: true,
How can I fix the error?我该如何修复错误?
I have named the object and exported the const but get this error:我已经命名了对象并导出了常量,但出现了这个错误:
const config = {
env: {
export default config;
^^^^^^
SyntaxError: Unexpected token export
at new Script (vm.js:83:7)
you should use module.exports like this:你应该像这样使用 module.exports:
module.exports = {
putYour: "config here"
};
thats all that you need这就是你所需要的
This is what I have in my .eslintrc.js :这是我在 .eslintrc.js 中的内容:
module.exports = {
env: {
browser: true,
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.