如何在括号中设置jslint ES6指令? [英] How to set the jslint ES6 directive in Brackets?

查看:125
本文介绍了如何在括号中设置jslint ES6指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到这个错误:期望一个标识符,而不是看到'const'",我正在使用方括号文本编辑器.我找到了这个答案:您需要指定es6指令.请参见JSLint帮助".但是我无法弄清楚如何在括号中指定es6指令. 这是我的代码:

I get this error: "expected an identifier and instead saw 'const'", I'm using brackets text editor. I found this answer: "You need to specify the es6 directive. See JSLint Help". But I can't figure it out how to specity the es6 directive in brackets. Here's my code:

const singleQuotes = '<p>Single quotes</p>';
const doubleQuotes = "<p>Double quotes</p>";
const stringLiterals =  `<p>String literlas</p>`;

const result = singleQuotes + doubleQuotes + stringLiterals;
document.querySelector('.basic').innerHTML = result;

感谢您的帮助.如果我使用var,效果很好.

I appreciate any help. It works fine if I use var.

推荐答案

一个文件

如果我没记错的话,请将以下内容放在文件的最上方:

If I remember right, you put the following at the very top of your file:

/*jslint es6:true*/

项目范围

如果您希望项目中的所有文件都遵守ES6,则可以在项目的根目录中添加.brackets.json文件.

If you want all files in your project to abide ES6, you can add a .brackets.json file to the root of your project.

宽括号

如果希望所有文件都遵循ES6,则可以通过单击以下菜单项来修改用户全局"首选项:Debug -> Open Preferences,然后将jslint.options属性添加到首选项中.

If you want all files to abide ES6, you can modify your User-global preferences by clicking the following menu items: Debug -> Open Preferences and then adding the jslint.options property to your preferences.

请参见 How-to-Use-Brackets:偏好设置有关更多信息.

但是,我只是尝试在禁用所有扩展的Brackets安装中执行此操作,并且Brackets不理解该指令.我认为Brackets默认情况下安装了一个非常旧的jslint版本.您可能要使用一些扩展来尝试对旧版本进行补充.

However, I just tried to do this with my Brackets installation with all extensions disabled and Brackets doesn't understand the directive. I think Brackets has a very old version of jslint installed by default. You may want to use some extensions to try to supplement the old version.

我最终要做的是安装 brackets-jshint 并将我的方括号首选项文件更改为默认情况下,使用jshint并使用以下选项:

What I ended up doing was installing the brackets-jshint and changing my brackets preferences file to use jshint by default with the following option:

{
    "language": {
        "javascript": {
            "linting.prefer": [
                "JSHint"
            ],
            "linting.usePreferredOnly": true
        }
    }
}

这篇关于如何在括号中设置jslint ES6指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆