Giter Club home page Giter Club logo

frontend-guidelines's Introduction

frontend-guidelines's People

Contributors

abazhenov-4xxi avatar rqrqrqrq avatar sg-4xxi avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

valmac g-baranov

frontend-guidelines's Issues

Нейминг

JavaSrcipt basics

Naming

[1.1] Используйте говорящие названия

// bad
function q() {
  // ...
}

// good
function query() {
  // ...
}

[1.2] Используйте camelCase для переменных, объектов, функций

// bad
const OBJEcttsssss = {};
const this_is_my_object = {};
function c() {}

// good
const thisIsMyObject = {};
function thisIsMyFunction() {}

[1.3] Используйте PascalCase только для конструкторов, классов и типов.

// bad
function user(options) {
  this.name = options.name;
}

const bad = new user({
  name: 'nope',
});

// good
class User {
  constructor(options) {
    this.name = options.name;
  }
}

const good = new User({
  name: 'yup',
});

[1.4] Не используйте нижние подчеркивания как префикс или постфикс

// bad
this.__firstName__ = 'Panda';
this.firstName_ = 'Panda';
this._firstName = 'Panda';

// good
this.firstName = 'Panda';

[1.5] Булевые переменные (и только они) называются с префиксами is, has.

// bad
const opened = true;
const options = false;

// good
const isOpened = true;
const hasOptions = false;

[1.6] Методы и функции называются начиная с глагола

// bad
const userData = () => {...};
this.account = () => {...};

// good
const getUserData = () => {...};
this.createAccount = () => {...};

[1.7] Хендлеры начинаются с префикса handle

// bad
const onClick = e => {...};
const click = e => {...};
this.keyPress = e => {...};

// good
const handleClick = e => {...};
const handleChange = e => {...};
this.handleKeyPress = e => {...};

При этом входящие пропсы для хендлеров стоит именовать с префиксом on

// bad
<Component handleClick={this.handleClick} />
$.CustomSuperPlugin({
  handleClick: handleClick,
});

//good
<Component onClick={this.handleClick} />
$.CustomSuperPlugin({
  onClick: handleClick,
});

[1.8] Для jQuery коллекций должен использоваться префикс $

// bad
var inputs = $('input');

//good
var $inputs = $('input');

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.