简体   繁体   English

如何为未定义规则设置陪同规则?

[英]How can i set an eslint rule for no-undefined?

I am trying to make a simple function which will redirect the user to the home page, as the name say. 我正在尝试制作一个简单的函数,该函数会将用户重定向到首页,如名称所示。 I can't get rid of this error: 我无法摆脱这个错误:

*ReferenceError: location is not defined * ReferenceError:未定义位置

Can someone help me with this, using eslint? 有人可以使用eslint帮助我吗?

export function goToHomePage() {
  location = '/';
}

I am using backbone.js MVC 我正在使用骨干.js MVC

Try setting your ESLINT config to: 尝试将ESLINT配置设置为:

var esLintDevConfig = {
    env: {
        "browser": true,
        "node": true,
        "jquery": true
    },
    "globals": {
        "angular": true, "window": true, //anyother global variables
    },
    rules: {

    }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让 eslint 检测 JSON 文件中的规则违规? - How can I make eslint detect rule violations in JSON files? 如何绕过 ESLint 调用 Typescript 中未定义的 Geolocation 接口? - How can I bypass ESLint calling the Geolocation interface undefined in Typescript? 如何设置ESLint规则以识别功能是否为驼峰式? - How to set ESLint rule to identify functions are either camelcase or not? 在ESlint中强制执行“换行样式”规则有多重要? 我可以关掉它吗? - How important is to enforce the “linebreak-style” rule in ESlint? Can I just turn it off? 如果div为空,则Eslint airbnb gets强制执行自我关闭div标签。 如何禁用此规则? - Eslint airbnb gets enforces self closing div tag if the div is empy. How can I disable this rule? 如何在没有节点的情况下获取自定义eslint规则来执行context.report? - How can I get a custom eslint rule to do context.report without having a node? 我如何为“linebreak-style”编写 ESLint 规则,根据 Windows 或 Unix 进行更改? - How can I write a ESLint rule for "linebreak-style", changing depending on Windows or Unix? 我可以在 eslint 配置中编写自己的自定义规则吗? - Can I write my own custom rule in eslint config? 我无法使我的自定义 eslint 规则起作用 - I can't make my custom eslint rule to work 如何在eslint规则中添加异常? - How to add exception to a eslint rule?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM