SlideShare a Scribd company logo
1 of 49
Download to read offline
THE HUMAN LINTER
Ilya Gelman
Ilya Gelman
- Organizer of AngularJS-IL
- Organizer of ReactJS-Israel
- Passionate about design and UX
Sr. Developer & Consultant @ 500Tech
BAD CODE
Had to deploy fast
Didn’t read the documentation
Hoped to refactor later
It wasn’t me
New technology
'use strict';



const React = require('react');

const BaseMixin = require('mixins/base');

const ChildrenMixin = require('mixins/children');

const ComponentUtils = require('utils/component');

const Config = require('lib/config');

const Notification = require('components/notifications');



modure.exports = React.createClass({

displayName:'Form',

mixins:[BaseMixin,ChildrenMixin],

propTypes: {metadata: React.PropTypes.object.isRequired,

notifications: React.PropTypes.array

},



getChildContext(){ return { action: this._handleAction,
formId: this.props.id}},
⌥ ⌘ L
'use strict';



const React = require('react');

const BaseMixin = require('mixins/base');

const ChildrenMixin = require('mixins/children');

const ComponentUtils = require('utils/component');

const Config = require('lib/config');

const Notification = require('components/notifications');



modure.exports = React.createClass({



displayName: 'Form',



mixins: [BaseMixin, ChildrenMixin],



propTypes: {

metadata: React.PropTypes.object.isRequired,

notifications: React.PropTypes.array

},



getChildContext() {

return {

action: this._handleAction,

formId: this.props.id

}

}

EXAMPLES
FROM
REAL WORLD
?
if (connected) {

return true;

} else {

return false;

}
return connected;
?
if (connected) {

return true;

} else {

return false;

}
return connected;!!
?
if (!isActive) {

isActive = true;

} else {

isActive = false;

}
isActive = !isActive;
?
if (!grade) {

grade = 100;

}
grade = grade || 100;
?
if (books) {

books.map(fn);

} else {

return [];

}
(books || []).map(fn);
?
let point = {};



point.x = 10;

point.y = 29;
const point = {

x: 10,

y: 29

};
?
while (processing) {

const config = {

option1: 123,

option2: 456

};



// ...

}
const config = {

option1: 123,

option2: 456

};



while (processing) {

// ...

}
?
.sort((a, b) => {

return a > b;

});
.sort((a, b) => a > b);
ES6
?
{

email: email,

password: password

}
{ email, password }
ES6
1 == "1"
TRUE
1 === "1"
FALSE
http://codepen.io/borisd/pen/jbNory
Async Actions
$http.get(API_URL).then(function () {

redirectTo(profileUrl)

});
function perimeter(top, right, bottom, left) {

return Math.sum(top, right, bottom, left);

}



perimeter(20, 15, 23, 12);
ES6
function perimeter(options = {}) {

const opt = options;

return Math.sum(opt.top, opt.right, opt.bottom, opt.left);



}



perimeter({ top: 20, bottom: 23, left: 12, right: 15 });
ES6
* Not the best code, only shows options hash example
function perimeter(top, right, bottom, left) {

return Math.sum(top, right, bottom, left);

}



perimeter(/* top */ 20, /* right */ 15, /* bottom */ 23, /* left */ 12);
ES6
element.addEventListener('click', listener, false);



element.removeEventListener('click', listener, false);
Clean Listeners
Useless Comments
// Clicks the edit icon
T.simulate.click(editBtn);
Unreadable Variable Names
.map((b, i) => {

return {

catalogId: i,

description: getDescription(b.isbn),

};

});
Unreadable Variable Names
.map((book, index) => {

return {

catalogId: index,

description: getDescription(book.isbn),

};

});
Unreadable Variable Names
const getBook = (book, index) => {

return {

catalogId: index,

description: getDescription(book.isbn),

};

}
.map(getBook);
// TODO: Implement later
// FIXME: Change later
Technical Debt
WHAT TO DO
if (viewLoading) {

element.classList.add('active');

} else {

element.classList.remove('active');

}
element.classList.toggle('active', viewLoading);
READ THE DOCS
RE-READ THE DOCS
ESLint
https://github.com/500tech/code-style
.eslintrc
"modules": true,

"objectLiteralComputedProperties": true,

"objectLiteralDuplicateProperties": false,

"objectLiteralShorthandMethods": true,

"objectLiteralShorthandProperties": true,

"restParams": true,

"spread": true,

"superInFunctions": true,

"templateStrings": true,

"jsx": true,

"regexYFlag": true,

"regexUFlag": true,

},



"rules": {

// Disabled rules

"complexity": 0,

"no-extend-native": 0,

"no-process-env": 0,

"init-declarations": 0,

"no-restricted-modules": 0,

"no-sync": 0,

"no-undef-init": 0,

"linebreak-style": 0,

"no-inline-comments": 0,

"no-new-object": 0,

"no-ternary": 0,

"padded-blocks": 0,

"no-inner-declarations": 0,

"id-length": 0,

"id-match": 0,

"no-underscore-dangle": 0,

"sort-vars": 0,

"max-statements": 0,



// Warning level

"comma-dangle": [1, "always-multiline"],

"no-console": 1,

"no-control-regex": 1,

"no-empty": 1,

"no-func-assign": 1,

"consistent-return": 1,

"curly": [1, "all"],

"default-case": 1,

"dot-notation": 1,

"no-alert": 1,

"no-multi-spaces": 1,

"no-param-reassign": 1,

"no-warning-comments": [1, { "terms": ["todo",

"radix": 1,

"no-path-concat": 1,

"no-process-exit": 1,

"lines-around-comment": [1, { "beforeBlockComment":

"constructor-super": 1,

"prefer-template": 1,

free for open-source projects
javascripting.com
USE THIRD-PARTY
orders.map('customer').unique().average('payment');
http://sugarjs.com
SMALL COMMITS
com
m
it!
BAD
com
m
it!
com
m
it!
com
m
it!
GOODcom
m
it!
com
m
it!
com
m
it!
com
m
it!
com
m
it!
com
m
it!
com
m
it!
com
m
it!com
m
it!
com
m
it!
com
m
it!
com
m
it!
com
m
it!
com
m
it!
BEST
com
m
it!com
m
it!
com
m
it!
com
m
it!
com
m
it!
com
m
it!
com
m
it!
com
m
it!
com
m
it!
com
m
it!
Also, review "on-the-fly" to save time
http://www.osnews.com/story/19266/WTFs_m
js best practices
top programming mistakes
http://amzn.to/1bSAYsh http://amzn.to/1ydGaoB http://amzn.to/1K93J6h
WE ARE HIRING
Read our blog:
http://blog.500tech.com
Ilya Gelman
ilya@500tech.com

More Related Content

What's hot

Java script object model
Java script object modelJava script object model
Java script object model
James Hsieh
 
Magento Attributes - Fresh View
Magento Attributes - Fresh ViewMagento Attributes - Fresh View
Magento Attributes - Fresh View
Alex Gotgelf
 
Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.js
Jarod Ferguson
 

What's hot (20)

AngularJS $Provide Service
AngularJS $Provide ServiceAngularJS $Provide Service
AngularJS $Provide Service
 
11. delete record
11. delete record11. delete record
11. delete record
 
Backbone js
Backbone jsBackbone js
Backbone js
 
AngularJs
AngularJsAngularJs
AngularJs
 
Drupal 9 training ajax
Drupal 9 training ajaxDrupal 9 training ajax
Drupal 9 training ajax
 
ftw.tabbedview - Tabbed Views
ftw.tabbedview - Tabbed Viewsftw.tabbedview - Tabbed Views
ftw.tabbedview - Tabbed Views
 
AngularJS Animations
AngularJS AnimationsAngularJS Animations
AngularJS Animations
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
 
AngularJS Routing
AngularJS RoutingAngularJS Routing
AngularJS Routing
 
Java script object model
Java script object modelJava script object model
Java script object model
 
AngularJS Services
AngularJS ServicesAngularJS Services
AngularJS Services
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
 
Database
DatabaseDatabase
Database
 
Magento Attributes - Fresh View
Magento Attributes - Fresh ViewMagento Attributes - Fresh View
Magento Attributes - Fresh View
 
Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.js
 
GDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSGDayX - Advanced Angular.JS
GDayX - Advanced Angular.JS
 
03 page navigation and data binding in windows runtime apps
03   page navigation and data binding in windows runtime apps03   page navigation and data binding in windows runtime apps
03 page navigation and data binding in windows runtime apps
 
Les exceptions, oui, mais pas n'importe comment
Les exceptions, oui, mais pas n'importe commentLes exceptions, oui, mais pas n'importe comment
Les exceptions, oui, mais pas n'importe comment
 
Java awt
Java awtJava awt
Java awt
 
Tweaking the interactive grid
Tweaking the interactive gridTweaking the interactive grid
Tweaking the interactive grid
 

Viewers also liked

Viewers also liked (20)

The Productive Developer
The Productive DeveloperThe Productive Developer
The Productive Developer
 
Higher-Order Components — Ilya Gelman
Higher-Order Components — Ilya GelmanHigher-Order Components — Ilya Gelman
Higher-Order Components — Ilya Gelman
 
Understanding Redux — Ilya Gelman
Understanding Redux — Ilya GelmanUnderstanding Redux — Ilya Gelman
Understanding Redux — Ilya Gelman
 
Angularjs Performance
Angularjs PerformanceAngularjs Performance
Angularjs Performance
 
Managing JavaScript Complexity
Managing JavaScript ComplexityManaging JavaScript Complexity
Managing JavaScript Complexity
 
Pgconfru 2015 kosmodemiansky
Pgconfru 2015 kosmodemianskyPgconfru 2015 kosmodemiansky
Pgconfru 2015 kosmodemiansky
 
Secure Node Code (workshop, O'Reilly Security)
Secure Node Code (workshop, O'Reilly Security)Secure Node Code (workshop, O'Reilly Security)
Secure Node Code (workshop, O'Reilly Security)
 
Node.JS error handling best practices
Node.JS error handling best practicesNode.JS error handling best practices
Node.JS error handling best practices
 
How Secure Is Your Container? ContainerCon Berlin 2016
How Secure Is Your Container? ContainerCon Berlin 2016How Secure Is Your Container? ContainerCon Berlin 2016
How Secure Is Your Container? ContainerCon Berlin 2016
 
lda2vec Text by the Bay 2016
lda2vec Text by the Bay 2016lda2vec Text by the Bay 2016
lda2vec Text by the Bay 2016
 
Deploying node.js at scale - Maraschi, Collina - Codemotion Amsterdam 2016
Deploying node.js at scale - Maraschi, Collina - Codemotion Amsterdam 2016Deploying node.js at scale - Maraschi, Collina - Codemotion Amsterdam 2016
Deploying node.js at scale - Maraschi, Collina - Codemotion Amsterdam 2016
 
Apache UIMA Introduction
Apache UIMA IntroductionApache UIMA Introduction
Apache UIMA Introduction
 
Tackling a 1 billion member social network
Tackling a 1 billion member social networkTackling a 1 billion member social network
Tackling a 1 billion member social network
 
OECD "Sweden 2017-oecd-economic-survey-growing-more-equal"
OECD "Sweden 2017-oecd-economic-survey-growing-more-equal"OECD "Sweden 2017-oecd-economic-survey-growing-more-equal"
OECD "Sweden 2017-oecd-economic-survey-growing-more-equal"
 
JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!
 
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"
 
Spark streaming state of the union
Spark streaming state of the unionSpark streaming state of the union
Spark streaming state of the union
 
Using PostgreSQL with Bibliographic Data
Using PostgreSQL with Bibliographic DataUsing PostgreSQL with Bibliographic Data
Using PostgreSQL with Bibliographic Data
 
The never-ending REST API design debate
The never-ending REST API design debateThe never-ending REST API design debate
The never-ending REST API design debate
 
The Productive Developer — Ilya Gelman
The Productive Developer — Ilya GelmanThe Productive Developer — Ilya Gelman
The Productive Developer — Ilya Gelman
 

Similar to The Human Linter — Ilya Gelman

Similar to The Human Linter — Ilya Gelman (20)

How Reactive do we need to be
How Reactive do we need to beHow Reactive do we need to be
How Reactive do we need to be
 
Road to react hooks
Road to react hooksRoad to react hooks
Road to react hooks
 
React new features and intro to Hooks
React new features and intro to HooksReact new features and intro to Hooks
React new features and intro to Hooks
 
Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)
 
React redux
React reduxReact redux
React redux
 
Strategies for Mitigating Complexity in React Based Redux Applicaitons
Strategies for Mitigating Complexity in React Based Redux ApplicaitonsStrategies for Mitigating Complexity in React Based Redux Applicaitons
Strategies for Mitigating Complexity in React Based Redux Applicaitons
 
React + Redux. Best practices
React + Redux.  Best practicesReact + Redux.  Best practices
React + Redux. Best practices
 
JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"
 
Recompacting your react application
Recompacting your react applicationRecompacting your react application
Recompacting your react application
 
Building Large jQuery Applications
Building Large jQuery ApplicationsBuilding Large jQuery Applications
Building Large jQuery Applications
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
 
MeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenmentMeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenment
 
React JS Hooks Sheet .pdf
React JS Hooks Sheet .pdfReact JS Hooks Sheet .pdf
React JS Hooks Sheet .pdf
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
 
React hooks
React hooksReact hooks
React hooks
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
 
IntroToCSharpcode.ppt
IntroToCSharpcode.pptIntroToCSharpcode.ppt
IntroToCSharpcode.ppt
 

More from 500Tech

More from 500Tech (20)

State managment in a world of hooks
State managment in a world of hooksState managment in a world of hooks
State managment in a world of hooks
 
State managment in a world of hooks
State managment in a world of hooksState managment in a world of hooks
State managment in a world of hooks
 
React Under the Hook - DevDays Europe 2019
React Under the Hook - DevDays Europe 2019React Under the Hook - DevDays Europe 2019
React Under the Hook - DevDays Europe 2019
 
React Back to the Future
React Back to the FutureReact Back to the Future
React Back to the Future
 
Hooks - why should you care today?
Hooks - why should you care today?Hooks - why should you care today?
Hooks - why should you care today?
 
Migrating from angular to react
Migrating from angular to reactMigrating from angular to react
Migrating from angular to react
 
How to write bad code in redux (ReactNext 2018)
How to write bad code in redux (ReactNext 2018)How to write bad code in redux (ReactNext 2018)
How to write bad code in redux (ReactNext 2018)
 
Opinionated Approach to Redux
Opinionated Approach to ReduxOpinionated Approach to Redux
Opinionated Approach to Redux
 
Mobx Internals
Mobx InternalsMobx Internals
Mobx Internals
 
Mobx - Performance and Sanity
Mobx - Performance and SanityMobx - Performance and Sanity
Mobx - Performance and Sanity
 
Mobx Performance and Sanity
Mobx Performance and SanityMobx Performance and Sanity
Mobx Performance and Sanity
 
Mobx - performance and sanity
Mobx - performance and sanityMobx - performance and sanity
Mobx - performance and sanity
 
Tales of an open source library
Tales of an open source libraryTales of an open source library
Tales of an open source library
 
Angular2 a modern web platform
Angular2   a modern web platformAngular2   a modern web platform
Angular2 a modern web platform
 
Angular. MobX. Happiness
Angular. MobX. HappinessAngular. MobX. Happiness
Angular. MobX. Happiness
 
Render to DOM
Render to DOMRender to DOM
Render to DOM
 
Managing state in Angular 1.x with Redux
Managing state in Angular 1.x with ReduxManaging state in Angular 1.x with Redux
Managing state in Angular 1.x with Redux
 
React vs angular
React vs angularReact vs angular
React vs angular
 
D3 svg & angular
D3 svg & angularD3 svg & angular
D3 svg & angular
 
ReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparisonReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparison
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

The Human Linter — Ilya Gelman