Development Guidelines - joao-conde/feup-ldso GitHub Wiki

Coding Guidelines

Coding guidelines are automatically enforced by linters:

(Some) Specific rules enforced

JavaScript

We use the recommended ESLint profile, which includes the following rules:

  • enforce “for” loop update clause moving the counter in the right direction;
  • enforce return statements in getters;
  • disallow comparing against -0;
  • disallow assignment operators in conditional expressions;
  • disallow constant expressions in conditions;
  • disallow control characters in regular expressions;
  • disallow the use of debugger;
  • disallow duplicate arguments in function definitions;
  • disallow duplicate keys in object literals;
  • disallow duplicate case labels;
  • disallow empty block statements;
  • disallow empty character classes in regular expressions;
  • disallow reassigning exceptions in catch clauses;
  • disallow unnecessary boolean casts;
  • disallow unnecessary semicolons;
  • disallow reassigning function declarations;
  • disallow variable or function declarations in nested blocks;
  • disallow invalid regular expression strings in RegExp constructors;
  • disallow irregular whitespace outside of strings and comments;
  • disallow calling global object properties as functions;
  • disallow multiple spaces in regular expressions;
  • disallow sparse arrays;
  • disallow confusing multiline expressions;
  • disallow unreachable code after return, throw, continue, and break statements;
  • disallow control flow statements in finally blocks;
  • disallow negating the left operand of relational operators;
  • require calls to isNaN() when checking for NaN;
  • enforce comparing typeof expressions against valid strings.

React

React code must follow both the JavaScript rules and the React rules, which are as follows:

  • Prevent missing displayName in a React component definition (react/display-name);
  • Detect missing key prop (react/jsx-key);
  • Prevent comments from being inserted as text nodes (react/jsx-no-comment-textnodes);
  • Prevent duplicate properties in JSX (react/jsx-no-duplicate-props);
  • Prevent usage of unsafe target='_blank' (react/jsx-no-target-blank);
  • Disallow undeclared variables in JSX (react/jsx-no-undef);
  • Prevent passing of children as props (react/no-children-prop);
  • Prevent problem with children and props.dangerouslySetInnerHTML (react/no-danger-with-children);
  • Prevent usage of deprecated methods (react/no-deprecated);
  • Prevent direct mutation of this.state (react/no-direct-mutation-state);
  • Prevent usage of findDOMNode (react/no-find-dom-node);
  • Prevent usage of isMounted (react/no-is-mounted);
  • Prevent usage of the return value of React.render (react/no-render-return-value);
  • Prevent using string references (react/no-string-refs);
  • Prevent invalid characters from appearing in markup (react/no-unescaped-entities);
  • Prevent usage of unknown DOM property (react/no-unknown-property);
  • Prevent missing props validation in a React component definition (react/prop-types);
  • Prevent missing React when using JSX (react/react-in-jsx-scope);
  • Enforce ES5 or ES6 class for returning value in render function (react/require-render-return).

Branching Guidelines

We follow git-flow, with some additions to the naming convention.

Branch Naming

All changes are forks from the develop branch or its forks, except hotfixes which may be fork the master branch directly (as dictated by git-flow).

All branches are named as follows: <type>/<component>-<hyphen-separated-name>

<type> is one of the following:

  • feature for new features and non-emergency bug fixes;
  • enhancement for enhancements and engineering tasks;
  • hotfix for emergency bug fixes.

<component> is one of the following:

  • mobile for new development on the Mobile app;
  • web for new development on the Web app;
  • server for new development on the Server.
⚠️ **GitHub.com Fallback** ⚠️