Coder Social home page Coder Social logo

code-standards's People

Contributors

adamhutchison avatar andrewmchale28 avatar beccaanderton avatar cannibble avatar craigsansam avatar dependabot-preview[bot] avatar dependabot[bot] avatar jackcolley avatar jbonwick avatar owarri avatar rowbi-wan avatar samboylett avatar samturrell avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

alexpilugin

code-standards's Issues

RFC - Route method definitions

๐Ÿ‘ Route::post(), Route::get(), Route::delete() etc
๐Ÿ˜„ Route::resource()
โค๏ธ $router->post(), $router->get(), $router->delete() etc
๐ŸŽ‰ $router->resource()

I prefer โค๏ธbecause it's easy to read and allows for autocompletion in IDEs

RFC - Commit message tense

๐ŸŽ‰ "Changed registration validation"
โค๏ธ "Changes registration validation"
๐Ÿ‘ "Changing registration validation"

RFC - Controller method parameter ordering

With the IoC container, we're not restricted to the order in which we define parameters for controller functions - meaning we can have a function like this

public function update($id, UpdateUserRequest $request, Vehicle $vehicle) { ... }

I feel we should have a defined order for URL Parameters, the request class and resolved IoC classes...

So please comment (or vote on if it's already been posted) your desired order :)

RFC - Passing data to views

Laravel gives us many ways to pass data to views. Which do we prefer?

Compact ๐Ÿ‘€

$user = User::first();
$groups = Groups::all();
$permissions = Permissions::all();

return view('groups', compact('user', 'groups', 'permissions'));

With (Array) ๐ŸŽ‰

return view('groups')
  ->with([
    'user' => User::first(),
    'groups' => Groups::all(),
    'permissions' => Permission::all(),
  ]);

With (Inline) ๐Ÿš€

return view('groups')
  ->with('user', User::first())
  ->with('groups', Groups::all())
  ->with('permissions', Permission::all());

RFC - Logical NOT operator spacing

We need a spacing format for when using 'logical not operators' within Blade files.

My usual approach is !$variable without a space. But it would be good to get an agreement on whether to include a space or not;

๐Ÿ‘ No space !$variable
๐Ÿ˜„ With space ! $variable

RFC - Request validation

Manually creating validator with Validator::make()

Using the ValidatesRequests trait and validating within Controller.

Creating FormRequest classes to store validation logic before it hits the Controller.

RFC - Route parameter definitions

๐Ÿ˜„$router->get('some-url', 'SomeController@someFunction')->name('some-name');

๐ŸŽ‰

$router->get('airport/{airportSlug}', [
    'as' => 'airport.show',
    'uses' => 'AirportController@show',
]);

Case Conventions

  • JSON responses: snake_case
  • Databases names, tables, columns: snake_case
  • URL parameters, snake_case: e.g. /user/2/show?include_extra_info=true
  • PSR-2 dictates the cases used in PHP code
  • GitHub repos: slug-case

Laravel Routes

  • Names: slug-case
  • URLs: slug-case

RFC - Spacing before directive parenthesis

We need to agree on a format of spacing before Blade Directive parenthesis.

My usual approach is, any structural directives have no space before the parenthesis, e.g.:

@extends('frontend.layout.app')
@section('body')

But any Control Structures use a space as they would in other programming languages, e.g.:

@if ($foo === $bar)
@foreach ($items as $item)

This is a bit of an inconsistency, but it makes sense. Would like to get an agreement on either:

๐Ÿ‘ Always space
๐Ÿ˜„ Never space
๐ŸŽ‰ Space for control structures

RFC - Formatting of API endpoints

Happy path

  • Nesting inside a data property (not for nested relations)
  • Use snake_case, as we are often exposing database attributes
  • Generally we use Fractal's DataArraySerializer

Exceptions

These are defined by Laravel's default error formatting

@craigsansam could you please comment the work you have done in this area and I'll write up

RFC - Model definitions

Preferred ordering within a Laravel model:

  • constants
  • traits
  • Laravel specific fields, $table, $guarded, $fillable
  • public fields
  • protected fields
  • private fields
  • relations
  • scopes
  • other methods

RFC - Vue SFC spacing between tags

I'd like to consistently break up Vue components so that they are more readable and each tag is easily distinguishable from the rest.

<template>
   ...
</template>

<script>
   ...
</script>

<style>
   ...
</style>

vs

<template>
   ...
</template>
<script>
   ...
</script>
<style>
   ...
</style>

Add tech stack page

Add a page with our preferred tech stack. Will make it easier for potential applicants to understand the tech we use.

Worried it might turn some people away, but probably just worth noting on technical tests that we are open to other tech?

Add recommended services

Discussed in #481

Originally posted by jackcolley December 15, 2021
Similar to the section on recommended packages. Should we also add a section for recommended services.

E.G RevenueCat for IAP, Stripe for real world payments,

RFC - Indentation of attributes

Continuous

<div
        id="my-div"
        class="my-class"
        v-else
>
    ...children
</div>

vs

<div
    id="my-div"
    class="my-class"
    v-else
>
    ...children
</div>

vs

<div
        id="my-div"
        class="my-class"
        v-else>
    ...children
</div>

vs

<div
    id="my-div"
    class="my-class"
    v-else>
    ...children
</div>

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.