我已经阅读了有关如何从文件中禁用规则的文档,但是我想知道是否有一种方法可以禁用或覆盖规则.eslintrc
而不覆盖我定义的其他以前的规则和预设。我在一个 AngularJS 项目中工作,所以我extends
在我的.eslintrc
文件中使用了属性。
我想禁用 angular ESlint 插件中的 3 个特定规则,而不禁用我以前使用的所有其他规则。
如果没有该rules
属性,我的所有 linting 规则都可以正常工作(间距、语法错误等),但是我自然不想出现两个 lint 错误。但是,rules
附加属性后,我以前的所有规则都不再适用(间距语法错误等)。
我可以声明一个规则来禁用我不想在文件顶部应用的特定规则,但这会非常重复(这是我之前所做的)。
{
"rules": {
"wrap-iife": [
2,
"inside"
],
"max-len": [
2,
120
],
"indent": [
2,
2
],
"no-with": 2,
"no-implicit-coercion": [
2, {
"string": true
}
],
"camelcase": [
2, {
"properties": "never"
}
],
"quotes": [
2,
"single"
],
"linebreak-style": [
2,
"unix"
],
"semi": [
2,
"always"
]
},
"env": {
"es6": …
Run Code Online (Sandbox Code Playgroud) 在调用我的函数之后,我惊讶于我的函数没有因为有一个变量并且在函数范围内使用未定义的变量而引发错误.
我的问题:为什么我的函数没有抛出未定义,错误等?不应该抛出错误因为"长度"不在我的函数参数中吗?我知道,如果我将"长度"切换到"高度",它将起作用.
如果有人可以解释javascript如何逐步解释这个功能,这对我有帮助.这是我的代码:
function areaRectangle(width, height) {
aRectangle = width * length;
console.log("The area of the rectangle is: " + aRectangle);
}
areaRectangle(10, 7); # The area of the rectangle is: 0
Run Code Online (Sandbox Code Playgroud)