[英]JSLint and ESLint Problems (Brackets)
I am creating a mock website for a small project that I am doing.我正在为我正在做的一个小项目创建一个模拟网站。 I am using nunjucks to perform some tasks.
我正在使用修女来执行一些任务。 When I try to create a .js file that I can run later, I am getting errors.
当我尝试创建以后可以运行的 .js 文件时,出现错误。
I have looked online, and tried every solution out there.我在网上查看,并尝试了所有解决方案。 I couldn't get any of them to work.
我无法让他们中的任何一个工作。
My Code:我的代码:
const nunjucks = require('nunjucks');
const fs = require('fs'); // The file system module
let files = ["index.html", "About.html", "Membership.html", "Fighting%20Kites.html"];
let srcDir = "./content/";
let outDir = "./output/";
// Tells nunjucks where to look for templates and set any options
nunjucks.configure('views', { autoescape: true });
for (let fname of files) {
let contents = fs.readFileSync(srcDir + fname);
let outString = nunjucks.render('base.njk', {mainContent: contents});
fs.writeFileSync(outDir + fname, outString);
console.log(`Wrote file: ${fname}`);
}
My Error Messages:我的错误信息:
JSLint (2)
1 Expected an identifier and instead saw 'const'. const nunjucks = require('nunjucks');
1 Stopping. (10% scanned). const nunjucks = require('nunjucks');
ESLint (1)
1 ERROR: Parsing error: The keyword 'const' is reserved const nunjucks = require('nunjucks');
I have no idea how to fix this.我不知道如何解决这个问题。 Any ideas help.
任何想法都有帮助。
const
is a ES6 JavaScript feature. const
是 ES6 JavaScript 的一个特性。 Try enabling the ES6 syntax for Eslint:尝试为 Eslint 启用 ES6 语法:
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.