Brevada / brv

Official Brevada Repository
http://brevada.com
2 stars 0 forks source link

Front-end Code Style #221

Closed noahnu closed 7 years ago

noahnu commented 7 years ago

Summary

Style

Enforce a style guide for the frontend JavaScript. We use eslint with custom rules configured in the eslint json file in the project's root. An editorconfig file is also setup to configure indentation style and line-endings.

Some files have also been broken up into smaller component files. PropTypes are enforced on all components, along with JSDoc.

In a few cases, eslint-disable rules have been employed. This is bad practice and has been used in scenarios where the changes were too extreme, too time intensive, or raised questions with the configured eslint rules. These will have to be re-evaluated at a later time.

Documentation

Quite a lot of documentation has been added. Mainly block-level/function-level documentation, rather than inline. JSDoc is required by our current eslint configuration.

Style: Fetch/Form

DataLayer has been renamed to Fetch. Form now passes itself to its children via context rather than via properties (this allows extremely nested forms).

Bug Fix

The feedback session controller failed to commit sessions due to a flaw in the session entity logic. This has been fixed. Now, if a session is seen to already exist, it'd ID will be looked up from its session code.

Loading

A "blur" loading state has been added to some of the event components (for use with Fetch/Form). This is more of an experiment in more responsive state indicators. More complex style/animation will be added in a separate PR.

New Scripts

See the README for a complete list of new npm scripts. For styling, you can run npm run lint:frontend to execute eslint on all the frontend JavaScript.

The format for the npm scripts has changed to make use of categories via :. See README.

Tests

Feedback

noahnu commented 7 years ago

Possible concern with Inactivity Timer for device feedback app. Must devise better test.