Use 'const' instead prefer-const 大概意思就是 标识符'errMsg'永远不会被重新分配;使用'const'而不是'let'。...(prefer-const) 解决方法就是在eslint配置文件或者tslintt配置文件增加 { "rules":{ "prefer-const": "off" } }
const obj = new Demo();这一行最初写的是let obj = new Demo();,报ERROR: 9:5 prefer-const Identifier 'obj' is never
} console.log(a) // ReferenceError console.log(b) // ReferenceError 对所有引用都使用 const,不要使用 var,eslint: prefer-const
// ], // 强制使用驼峰 // camelcase: ["error", { properties: "always" }], // 优先使用 const 'prefer-const
{ 'beforeStatementContinuationChars': 'never' } ], 'no-delete-var': 2, 'prefer-const
要求使用 let 或 const 而不是 var object-shorthand 要求或禁止对象字面量中方法和属性使用简写语法 prefer-arrow-callback 要求回调函数使用箭头函数 prefer-const
'no-useless-call': 2, //禁止不必要的call和apply 'init-declarations': 0, //声明时必须赋初值 'prefer-const
undefined 'no-useless-call': 2, //禁止不必要的call和apply 'init-declarations': 0, //声明时必须赋初值 'prefer-const
} console.log(a) // ReferenceError console.log(b) // ReferenceError 对所有引用都使用 const,不要使用 var,eslint: prefer-const...eslint: no-undef prefer-const // bad demo = new Demo() // good const demo = new Demo() 将所有的 const 和
在打开的规则作为警告(不影响退出代码) "error"或者2 //把规则作为一个错误(退出代码触发时为1) */ 'no-var': 'error', // 禁止使用var 'prefer-const
赋值运算符 += -=什么的 “operator-linebreak”: [2, “after”],//换行时运算符在行尾还是行首 “padded-blocks”: 0,//块语句内行首行尾是否要空行 “prefer-const
"check-open-brace", "check-catch", "check-else", "check-whitespace" ], "prefer-const
赋值运算符 += -=什么的 "operator-linebreak": [2, "after"],//换行时运算符在行尾还是行首 "padded-blocks": 0,//块语句内行首行尾是否要空行 "prefer-const
non critical issues from legacy JavaScript files "files": ["*.js"], "rules": { "prefer-const.../**/*.ts"], "extends": ["async", "async/node", "async/typescript"], "rules": { "prefer-const
关闭服务后的回调函数 const closeHttpServer = createServerCloseFn(httpServer) // eslint-disable-next-line prefer-const
eslint: no-undef prefer-const // bad superPower = new SuperPower(); // good const superPower = new SuperPower
msg: 'Hello' }) const emit = defineEmits(['update']) let count = $ref(1) // eslint-disable-next-line prefer-const
bar[0]); // => 9, 9 object array function ⬆ back to top References 2.1 所有的赋值都用const,避免使用var. eslint: prefer-const
领取专属 10元无门槛券
手把手带您无忧上云