GithubHelp home page GithubHelp logo

Comments (8)

errorrik avatar errorrik commented on July 23, 2024

这条属于code style,主要是和之前我厂的风格保持一致。我厂之前有类似的条目:

[强制] 对象创建时,如果一个对象的所有 属性 均可以不添加引号,则所有 属性 不得添加引号。
[强制] 对象创建时,如果任何一个 属性 需要添加引号,则所有 属性 必须添加 '。

这种 @hax 大就忽略吧,估计其他团队不会像我们这么龟毛,所以也不会理这种条目的。😄

from spec.

hax avatar hax commented on July 23, 2024

确实龟毛。

而且这规则实行起来很麻烦,比如修改代码新增加/删除一个属性,导致整块代码需要修改,这是制定代码风格时应该尽量避免的。(话说这也是我prefer tab而不是空格的原因之一。)

我理解这类规则其实主要出于美观(从而略有提高可读性),但是在ES6还加入了computed property,所以只要有计算属性,那么完全整齐是不可能做到的。

建议可以考虑取消这条龟毛而又无法达到当初目的的规则。(因为这是放松规则,所以应该不会引起反弹吧。)

from spec.

errorrik avatar errorrik commented on July 23, 2024

现晒晒我写的代码,哈哈

    var HTML_ENTITY = {
        /* jshint ignore:start */
        '&': '&',
        '<': '&lt;',
        '>': '&gt;',
        '"': '&quot;',
        /* eslint-disable quotes */
        "'": '&#39;'
        /* eslint-enable quotes */
        /* jshint ignore:end */
    };

确实有了computed property后美观已不可得。可以考虑。回头我们在内部专门找个机会讨论相关问题,看Work Group大家的意见。

from spec.

Justineo avatar Justineo commented on July 23, 2024

这个我同意 @hax 说的,其实这个就像冒号对齐、等号对齐一样,会造成维护成本提高。@errorrik 现在这样插了这么多注释感觉也挺不好看的……

from spec.

hax avatar hax commented on July 23, 2024

这个代码不需要 eslint-disable quotes 呀,只要把规则设为 [2, "single", "avoid-escape"] 即可。

from spec.

errorrik avatar errorrik commented on July 23, 2024

voting, just a note

from spec.

cnberg avatar cnberg commented on July 23, 2024

同意 @hax ,这条规则执行起来太麻烦了,而且修改成本太高

from spec.

errorrik avatar errorrik commented on July 23, 2024

内部投票结论已出,该issue在完成修改后关闭。


A. 直接删除 (5)
B. 改成建议 (6)√
C. 保留强制 (0)

from spec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.