Comments (7)
从babel repl来看是可以的,包括在非方法的属性上使用也是可以的
对象直接量会使用在2种场景:
- 一个带逻辑的对象,可能是一个模块的
export
- 一个纯对象,只是数据的
我们比较担心第2种情况下的滥用,在此先做比较严格的限制,在确定了一些实践的指导后再考虑改吧
from spec.
举个例子:
const o = {
@nonenumerable test() {...}
}
这样的用途并没有什么不妥当啊。
from spec.
在方法上声明我觉得OK,但是在一个纯数据型的object上把装饰器丢property上我反对
这条可以改成不得在对象的property上添加装饰器?
from spec.
我就是写了:
const test = {
@readonly test: 'You should not change me!'
}
为什么不可以呢?
当然我理解作为data的plain object似乎应该保持简单,但是到底是不是plain object,这个不是检查能检查出来的呀。
from spec.
@errorrik 我想了一下,这条我们这么说不知是否合适
不在作为纯数据使用的对象上使用装饰器
这里需要对“纯数据”作一个定义,我理解是只承载属性且使用场景仅限于hasOwnProperty
、.foo
和.foo = bar
、for in
等对plain object的操作的
from spec.
@otakustay 然而我上面这个例子代码并不会影响它作为纯数据被使用。
担心被滥用,首先得有滥用的case,否则不清楚原因就禁止,以后可能会变成讲不清楚的历史遗留习惯。。。
from spec.
纯数据
是一个很难被静态检查的定义诶。
decorator现在还不太成熟,我觉得这条不如暂时去掉,等看大家实践看看有没坑。对于这点,现在我没想出大家能玩出坑来,我甚至觉得大家应该都不会玩的。
from spec.
Related Issues (20)
- React规范中强制defaultProps的规则跟redux的冲突 HOT 5
- react-style-guide描述格式 HOT 1
- 关于 “[建议]使用@autobind进行事件处理方法与this的绑定” HOT 2
- 关于 “[强制]没有子节点的非DOM组件使用自闭合语法” HOT 1
- 关于“[强制]对于值为true的属性,省去值部分” HOT 3
- 关于"[强制]为非继承自PureComponent的纯组件实现shouldComponentUpdate方法" HOT 3
- import/extensions规则需要调整 HOT 1
- 模块规范中 define() 的 factory 可以是 string 吗?
- [强制] 当文件无法使用 .js 扩展名时,使用 .es 扩展名。 HOT 10
- 3.5 字符串 [建议] 使用 数组 或 + 拼接字符串 示例中有小错误
- 3.5 字符串 [建议] 使用 数组 或 + 拼接字符串 示例中有小错误
- sudo全局安装fecs出错
- 有return的三目运算符换行怎么做? HOT 2
- 运算符处换行时,运算符必须在新行的行首,和eslint规则有冲突了
- 对象常量的属性名要全部大写吗? HOT 3
- vue单文件组件中方法和计算属性怎样注释?
- vue组件里methods方法和computed计算属性怎样注释??
- css编码规范中在Family Name 大小写必须统一一项下有小错误
- 请问文件名应该如何约定? HOT 1
- TS 『禁止不必要的类型约束』规则,可能影响 tsx 文件下正常使用 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spec.