GithubHelp home page GithubHelp logo

openzeppelin / configs Goto Github PK

View Code? Open in Web Editor NEW
19.0 19.0 19.0 39 KB

Code style guidelines and rules for OpenZeppelin projects

License: Creative Commons Zero v1.0 Universal

JavaScript 100.00%

configs's People

Contributors

abcoathup avatar come-maiz avatar frangio avatar ylv-io avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

configs's Issues

Use pinned dependencies

Since we're starting to use Dependabot across our repos, I think we should make code-style use pinned dependencies. Thus, we contain all of the linter related Dependabot PRs to this repository.

Increase line-length limit to 120 characters

This affects both Solidity and JavaScript style guides.

We're thinking 80 characters is too little. We're used to writing longer lines so it gets in the way of coding.

A justification for 120: it seems to be the width that GitHub uses.

Don't treat style rules as errors but warnings

Currently there are many style rules in both Solidity and JavaScript linters which are treated as errors.

In the interested of reducing friction for contributors, but without giving up on our pursuit of code style consistency, we have decided to demote style rules to warnings. This will allow us to ask contributors nicely to adhere to our style, instead of them running against a failed CI build.

Should line length limit be a soft or hard rule?

In OpenZeppelin/openzeppelin-contracts#944 the question came up whether the line length limit should trigger an error or a warning.

I am strongly against making it an error. It should be a soft rule to nudge people in the right direction, but not something that should be strictly enforced.

Here is an interesting talk about the tyranny of style guides, which eventually had to be shared in this repository:
Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015.

In attempting to stay below the line length limit, a programmer could turn to using one-letter variable names. In this case I prefer a longer line with more meaningful variable names.

@ElOpio presents the argument that warnings will be ignored and accumulate over time. I agree with this, but in such a case we should consider removing the rule.

Limit line length

To comply with the Solidity style guide, we should add a rule to limit the maximum line length to 79 characters (note that solium doesn't yet support such a rule).

I would also drop the arg-overflow rule, since this one tackles the same problem.

Do not enforce semicolons at the end of each line

This dispute happened on slack, so I'm copying the discussion here. It was brought by @facuspagnuolo.

@frangio: imo we have to enforce either all semicolons or no semicolons at all. either rule is quite rigorous but i think we definitely shouldn't be placing semicolons inconsistently
@ElOpio: yes, consistency is the objective.
@facuspagnuolo: we will always have different opinions about it but if iโ€™m the only one against it I can live with it ๐Ÿ™‚
@ElOpio: facu I have no opinion, as long as it's either all or none.
I think frangio doesn't like them much
@frangio: no, i don't have strong opinions about semicolons either. aesthetically i prefer no semicolons. but i recognize that there are some corner cases where semicolon injection can cause some confusion

e.g. having an expression in parentheses at the beginning of a line will cause javascript to think it's a function of the previous line's last expression

doSomething()
(x+2).should.equal(3)

my vote is for always semicolons because of the principle of least surprise

eslint no-unused-expressions rule has conflicts with chai's getters

Chai uses getters with side-effects to make assertions, like:

f().should.be.true

Side-effects are always wrong, so eslint makes the right thing sending an error like this:

error  Expected an assignment or function call and instead saw an expression  no-unused-expressions

But chai is very useful and popular.

This issue is discussed here: eslint/eslint#2102
There are many options, like disabling the rule, using dirty-chai, using eslint-plugin-chai-friendly, using jhint instead of eslint.

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.