ESLint禁止覆写原生对象和直接用子组件

问题描述

第一个呢就是直接用属性作为组件也会报错,看网友们有没有配置过这种禁用如此使用组件的rule,分享一下

clipboard.png

第二个是no-global-assign可以对Object = 3; 这类对原生对象赋值起作用,但是对于导入对象不起作用

clipboard.png

Sonar检测报错提示:
Overriding an object changes its behavior and could potentially impact all code using that object. Overriding standard, built-in objects could therefore have broad, potentially catastrophic effects on previously-working code.

This rule detects overrides of the following native objects:

Fundamental objects - Object, Function, Boolean, Symbol, Error, EvalError, InternalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError
Numbers and dates - Number, Math, Date
Text processing - String, RegExp
Indexed collections - Array, Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Unit16Array, Int32Array, Uint32Array, Float32Array, Float64Array
Keyed collections - Map, Set, WeakMap, WeakSet
Structured data - ArrayBuffer, DataView, JSON
Control abstraction objects - Promise
Reflection - Reflect, Proxy
Internationalization - Intl
Non-standard objects - Generator, Iterator, ParallelArray, StopIteration

问题出现的环境背景及自己尝试过哪些方法

尝试了no-global-assign无果,还在找其他rule,疯狂蹂躏搜索引擎中。。。

你期待的结果是什么?实际看到的错误信息又是什么?

通过配置ESLint让本地提示如此使用是Error

阅读 1.1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题