SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
W R I T I N G ( M E T E O R )
C O D E W I T H S T Y L E
M E C O D E P R E T T Y O N E D A Y
T
Template.linkList.helpers({
links: function() {
return LinksCollection.find({}, {
sort: {
votes: -1
}
});
}
});
Template.linkList.events({
'click button#show-more': function() {
var newLimit = Session.get('linksLimit') + 10;
Session.set('linksLimit', newLimit);
}
});
MeteoI.EetAo=s! {
,==LinC ) fLnction !=:t:) {
cAecC! =:t:, {
LID) StIing,
teOt) StIing,
c:tegoIy) StIing
R );
if !!tAis.LseI0=) {
tAIow new MeteoI./IIoI! YoL A:Me to Dogin );
R
=:t:.tiEest:Ep + new .:te!);
=:t:.Motes + (;
=:t:.LseI0= + tAis.LseI0=;
=:t:.cIe:toI + MeteoI.LseIs.fin=One! =:t:.LseI0= ).LseIn:Ee;
IetLIn LinCs-­oDDection.inseIt! =:t: );
R,
,==Vote ) fLnction !=:t:) {
cAecC! =:t:, {
DinC0=) StIing
R );
if !!tAis.LseI0=) {
tAIow new MeteoI./IIoI! YoL A:Me to Dogin to ;e :;De to Mote foI DinCs );
R
=:t:.LseI0= + tAis.LseI0=;
'' cAecC if LseI Mote= :DIe:=y
if !LinCs-­oDDection.fin=!
{ _i=) =:t:.DinC0=, MoteIs) =:t:.LseI0= R
).coLnt!) +++ () {
IetLIn LinCs-­oDDection.Lp=:te!
Meteor.publish('links', function (options) {

console.log(options);

check(options, {

linksLimit: Number

});

var qryOptions = {

limit: options.linksLimit,

sort: {

votes: -1

}

};

console.log(qryOptions);

return LinksCollection.find({}, qryOptions);

Meteor.publish('categories', function () {
return CategoriesCollection.find({}, {
sort: {
name: 1
}
});
});
Router.route ( '/new', {
name: 'new',
subscriptions: function () {
return Meteor.subscribe ( 'categories
},
onBeforeAction: function () {
if (!Meteor.userId ()) {
this.render ( 'loginRequest' );
} else {
this.next ();
}
},
action: function () {
if (this.ready ()) {
this.render ( 'addLink' );
} else {
this.render ( 'Loading categories'
}
},
data: function () {
return { categories: CategoriesCollehttps://github.com/yauh/meteor-with-style
S T E P H A N
H O C H H A U S
@ YA U H
W H O A R E Y O U ?
Being a style icon
# 1 Q U A L I T Y
# 2 U N D E R S TA N D I N G
# 3 S C A L I N G
W H Y TA L K A B O U T S T Y L E ?
R E M E M B E R G O T O FA I L ?
{
...
if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
goto fail;
...
fail:
SSLFreeBuffer(&signedHashes);
SSLFreeBuffer(&hashCtx);
return err;
}
http://opensource.apple.com/source/Security/Security-55471/libsecurity_ssl/lib/sslKeyExchange.c
L O O K AT Y O U R C O D E
N O W A S K Y O U R S E L F
T W O Q U E S T I O N S
I S I T L E G A L ? I S I T S T Y L I S H ?
P O I N T O U T S U S P I C I O U S C O D E
A V O I D S T U P I D E R R O R S - L I N E S A F T E R A R E T U R N
• Missing semicolons
• if, for, while without curly braces
• Curly braces without if, for, while
• Unreachable code after a return,
throw, continue, or break
• switch/case statements without
break
• Comments within comments.
• Ambiguity whether two adjacent lines
are part of the same statement.
• Unnecessary code
• …
L O O K F O R
M A I N TA I N U N I F O R M S T Y L E
C O N S I S T E N T LY U S I N G 2 S PA C E S , N O TA B S
A = B + 1
N O T
A = B + 1
F U N C T I O N ( A , B , C ) { R E T U R N 1 ; }
N O T
F U N C T I O N ( A , B , C ) { R E T U R N 1 ; }
F O R ( I = 0 ; I < 3 ; I + + )
N O T
F O R ( I = 0 ; I < 3 ; I + + )
A ( 1 , 2 , 3 )
N O T
A ( 1 , 2 , 3 )
{ A : 1 , B : 2 }
N O T
{ A : 1 , B : 2 }
I F ( A )
N O T
I F ( A )
…
D O M I N A T I N G S T Y L E
T H E D Y N A M I C D U O
Style
CorrectnessFocus on
*100
*69
*number of rules
T H E D Y N A M I C D U O
+ T H E N E W K I D
Style
CorrectnessFocus on
ESLint
*146
*100
*69
*number of rules
N P M
A D D I N G L I N T E R S
$ npm install -g jshint
$ npm install -g jscs
$ npm install -g eslint
AT O M . I O
A D D I N G L I N T E R S
B U T W H Y W O U L D Y O U ?
You can have as many linters as you like
W H AT ’ S W R O N G W I T H M Y C O D E ?
S TA R T S M A L L A N D I N T R O D U C E R U L E S A S N E E D E D
P L U G G A B L E A R C H I T E C T U R E
& C U S T O M R U L E S
T H I S I S J U S T T H E T I P O F T H E M O U N TA I N
Look, I found some code to fix my code!
$ npm install -g js-beautify
$ npm install -g esformatter
C O D E F I X E R S
# of settings*
Ease
of use
esformatter
Editorconfig
*6
*17
*286
Editorconfig to the rescue!
AT O M . I O
A D D I N G F O R M A T T I N G H E L P E R S
C O N F I G U R I N G T H E T O O L S
T H E P O W E R O F T H E I N V I S I B L E
T L ; D L
• Write code that
• is valid JavaScript
• uses the same style across the team
• Use tools to support the writing process
• editorconfig
• js-beautify
• Use ESLint to check style adherence and slowly introduce rules
E V E N T U A L LY
C O N T I N U O U S I N T E G R A T I O N
E V E N T U A L LY
C O N T I N U O U S I N T E G R A T I O N
W H AT A B O U T C O F F E E ?
U S E C O F F E E L I N T !
F U R T H E R R E A D I N G
• https://github.com/meteor/meteor/wiki/Meteor-Style-
Guide
• http://jsbeautifier.org/
• http://davidwalsh.name/eslint

Weitere ähnliche Inhalte

Was ist angesagt?

2017 09-17 주일예배, 눅14장01절-24절, 강권하여 데려오라
2017 09-17 주일예배, 눅14장01절-24절, 강권하여 데려오라2017 09-17 주일예배, 눅14장01절-24절, 강권하여 데려오라
2017 09-17 주일예배, 눅14장01절-24절, 강권하여 데려오라
Myoung-Ryun Mission Presbyterian Church
 

Was ist angesagt? (20)

The Case for Competitive Mobile Gaming - Peter Heinrich
The Case for Competitive Mobile Gaming - Peter HeinrichThe Case for Competitive Mobile Gaming - Peter Heinrich
The Case for Competitive Mobile Gaming - Peter Heinrich
 
Getting Started with the Amazon GameOn API - Peter Heinrich
Getting Started with the Amazon GameOn API - Peter HeinrichGetting Started with the Amazon GameOn API - Peter Heinrich
Getting Started with the Amazon GameOn API - Peter Heinrich
 
Smart Contracts Technical Overview - Meetup Roma - 17/09/19
Smart Contracts Technical Overview - Meetup Roma - 17/09/19Smart Contracts Technical Overview - Meetup Roma - 17/09/19
Smart Contracts Technical Overview - Meetup Roma - 17/09/19
 
Challenging Your Assumptions
Challenging Your AssumptionsChallenging Your Assumptions
Challenging Your Assumptions
 
Google Assistant & Alexa - Asystenci głosowi: możliwości, podobieństwa, różnice
Google Assistant & Alexa - Asystenci głosowi: możliwości, podobieństwa, różniceGoogle Assistant & Alexa - Asystenci głosowi: możliwości, podobieństwa, różnice
Google Assistant & Alexa - Asystenci głosowi: możliwości, podobieństwa, różnice
 
Representing Material Culture Online: Historic Clothing in Omeka
Representing Material Culture Online: Historic Clothing in OmekaRepresenting Material Culture Online: Historic Clothing in Omeka
Representing Material Culture Online: Historic Clothing in Omeka
 
톰캣 #02-설치환경
톰캣 #02-설치환경톰캣 #02-설치환경
톰캣 #02-설치환경
 
Xcode Survival Guide
Xcode Survival GuideXcode Survival Guide
Xcode Survival Guide
 
A Prettier Printer
A Prettier PrinterA Prettier Printer
A Prettier Printer
 
Svelte (adjective): Attractively thin, graceful, and stylish
Svelte (adjective): Attractively thin, graceful, and stylishSvelte (adjective): Attractively thin, graceful, and stylish
Svelte (adjective): Attractively thin, graceful, and stylish
 
wreewrer
wreewrerwreewrer
wreewrer
 
Building a Python IDE with Xtext
Building a Python IDE with XtextBuilding a Python IDE with Xtext
Building a Python IDE with Xtext
 
Build and deploy multiarch Linux and Windows Container images
Build and deploy multiarch Linux and Windows Container imagesBuild and deploy multiarch Linux and Windows Container images
Build and deploy multiarch Linux and Windows Container images
 
Network gateway
Network gatewayNetwork gateway
Network gateway
 
Asynchronous data processing
Asynchronous data processingAsynchronous data processing
Asynchronous data processing
 
Consistency, Availability, Partition: Make Your Choice
Consistency, Availability, Partition: Make Your ChoiceConsistency, Availability, Partition: Make Your Choice
Consistency, Availability, Partition: Make Your Choice
 
2017 09-17 주일예배, 눅14장01절-24절, 강권하여 데려오라
2017 09-17 주일예배, 눅14장01절-24절, 강권하여 데려오라2017 09-17 주일예배, 눅14장01절-24절, 강권하여 데려오라
2017 09-17 주일예배, 눅14장01절-24절, 강권하여 데려오라
 
Demystifying Unicode - Longhorn PHP 2021
Demystifying Unicode - Longhorn PHP 2021Demystifying Unicode - Longhorn PHP 2021
Demystifying Unicode - Longhorn PHP 2021
 
Plone ♥︎ Python 3
Plone ♥︎ Python 3Plone ♥︎ Python 3
Plone ♥︎ Python 3
 
Call Execute For Everyone
Call Execute For EveryoneCall Execute For Everyone
Call Execute For Everyone
 

Ähnlich wie Writing (Meteor) Code With Style

Newest copy _rockstar solutions
Newest copy _rockstar solutionsNewest copy _rockstar solutions
Newest copy _rockstar solutions
joyousone1104
 

Ähnlich wie Writing (Meteor) Code With Style (20)

Type Systems on the example of TypeScript
Type Systems on the example of TypeScriptType Systems on the example of TypeScript
Type Systems on the example of TypeScript
 
Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016 Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016
 
Ten Typ tak ma - O systemach typów na przykładzie TypeScript’a
Ten Typ tak ma - O systemach typów na przykładzie TypeScript’aTen Typ tak ma - O systemach typów na przykładzie TypeScript’a
Ten Typ tak ma - O systemach typów na przykładzie TypeScript’a
 
Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...
Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...
Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler Development
 
PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!
 
An Introduction to CSS Preprocessors
An Introduction to CSS PreprocessorsAn Introduction to CSS Preprocessors
An Introduction to CSS Preprocessors
 
eHarmony @ Phoenix Con 2016
eHarmony @ Phoenix Con 2016eHarmony @ Phoenix Con 2016
eHarmony @ Phoenix Con 2016
 
Hardware Description Languages .pptx
Hardware Description Languages .pptxHardware Description Languages .pptx
Hardware Description Languages .pptx
 
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limiters
 
Newest copy _rockstar solutions
Newest copy _rockstar solutionsNewest copy _rockstar solutions
Newest copy _rockstar solutions
 
Breathe life into your designer!
Breathe life into your designer!Breathe life into your designer!
Breathe life into your designer!
 
Constructs and techniques and their implementation in different languages
Constructs and techniques and their implementation in different languagesConstructs and techniques and their implementation in different languages
Constructs and techniques and their implementation in different languages
 
Testing TYPO3 Applications
Testing TYPO3 ApplicationsTesting TYPO3 Applications
Testing TYPO3 Applications
 
PostgreSQL Day italy 2016 Unit Test
PostgreSQL Day italy 2016 Unit TestPostgreSQL Day italy 2016 Unit Test
PostgreSQL Day italy 2016 Unit Test
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
Ember js meetup treviso liquid-fire
Ember js meetup treviso liquid-fireEmber js meetup treviso liquid-fire
Ember js meetup treviso liquid-fire
 
Fast api
Fast apiFast api
Fast api
 
hive in bigdata.pptx
hive in bigdata.pptxhive in bigdata.pptx
hive in bigdata.pptx
 

Mehr von Stephan Hochhaus

Mehr von Stephan Hochhaus (8)

Erfolgreich trotz Daten - Wie datengetriebene Unternehmen funktionieren
Erfolgreich trotz Daten - Wie datengetriebene Unternehmen funktionierenErfolgreich trotz Daten - Wie datengetriebene Unternehmen funktionieren
Erfolgreich trotz Daten - Wie datengetriebene Unternehmen funktionieren
 
Weltvermessen mit OpenDataCam - Wie ich einmal eine Viertelmillionen Autos ge...
Weltvermessen mit OpenDataCam - Wie ich einmal eine Viertelmillionen Autos ge...Weltvermessen mit OpenDataCam - Wie ich einmal eine Viertelmillionen Autos ge...
Weltvermessen mit OpenDataCam - Wie ich einmal eine Viertelmillionen Autos ge...
 
Business Value - Stop working for the trash can
Business Value - Stop working for the trash canBusiness Value - Stop working for the trash can
Business Value - Stop working for the trash can
 
Walk of Claim - A Meteor Meetup presentation
Walk of Claim - A Meteor Meetup presentationWalk of Claim - A Meteor Meetup presentation
Walk of Claim - A Meteor Meetup presentation
 
Introduction to Meteor - revised edition
Introduction to Meteor - revised editionIntroduction to Meteor - revised edition
Introduction to Meteor - revised edition
 
Automatisierte infrastruktur mit ansible
Automatisierte infrastruktur mit ansibleAutomatisierte infrastruktur mit ansible
Automatisierte infrastruktur mit ansible
 
Testing MeteorJS using CasperJS
Testing MeteorJS using CasperJSTesting MeteorJS using CasperJS
Testing MeteorJS using CasperJS
 
LaTeX für Geisteswissenschaftler
LaTeX für GeisteswissenschaftlerLaTeX für Geisteswissenschaftler
LaTeX für Geisteswissenschaftler
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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)
 
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
 
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
 

Writing (Meteor) Code With Style

  • 1. W R I T I N G ( M E T E O R ) C O D E W I T H S T Y L E M E C O D E P R E T T Y O N E D A Y T Template.linkList.helpers({ links: function() { return LinksCollection.find({}, { sort: { votes: -1 } }); } }); Template.linkList.events({ 'click button#show-more': function() { var newLimit = Session.get('linksLimit') + 10; Session.set('linksLimit', newLimit); } }); MeteoI.EetAo=s! { ,==LinC ) fLnction !=:t:) { cAecC! =:t:, { LID) StIing, teOt) StIing, c:tegoIy) StIing R ); if !!tAis.LseI0=) { tAIow new MeteoI./IIoI! YoL A:Me to Dogin ); R =:t:.tiEest:Ep + new .:te!); =:t:.Motes + (; =:t:.LseI0= + tAis.LseI0=; =:t:.cIe:toI + MeteoI.LseIs.fin=One! =:t:.LseI0= ).LseIn:Ee; IetLIn LinCs-­oDDection.inseIt! =:t: ); R, ,==Vote ) fLnction !=:t:) { cAecC! =:t:, { DinC0=) StIing R ); if !!tAis.LseI0=) { tAIow new MeteoI./IIoI! YoL A:Me to Dogin to ;e :;De to Mote foI DinCs ); R =:t:.LseI0= + tAis.LseI0=; '' cAecC if LseI Mote= :DIe:=y if !LinCs-­oDDection.fin=! { _i=) =:t:.DinC0=, MoteIs) =:t:.LseI0= R ).coLnt!) +++ () { IetLIn LinCs-­oDDection.Lp=:te! Meteor.publish('links', function (options) { console.log(options); check(options, { linksLimit: Number }); var qryOptions = { limit: options.linksLimit, sort: { votes: -1 } }; console.log(qryOptions); return LinksCollection.find({}, qryOptions); Meteor.publish('categories', function () { return CategoriesCollection.find({}, { sort: { name: 1 } }); }); Router.route ( '/new', { name: 'new', subscriptions: function () { return Meteor.subscribe ( 'categories }, onBeforeAction: function () { if (!Meteor.userId ()) { this.render ( 'loginRequest' ); } else { this.next (); } }, action: function () { if (this.ready ()) { this.render ( 'addLink' ); } else { this.render ( 'Loading categories' } }, data: function () { return { categories: CategoriesCollehttps://github.com/yauh/meteor-with-style
  • 2. S T E P H A N H O C H H A U S @ YA U H W H O A R E Y O U ? Being a style icon
  • 3. # 1 Q U A L I T Y # 2 U N D E R S TA N D I N G # 3 S C A L I N G W H Y TA L K A B O U T S T Y L E ?
  • 4. R E M E M B E R G O T O FA I L ? { ... if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0) goto fail; if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) goto fail; goto fail; if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0) goto fail; ... fail: SSLFreeBuffer(&signedHashes); SSLFreeBuffer(&hashCtx); return err; } http://opensource.apple.com/source/Security/Security-55471/libsecurity_ssl/lib/sslKeyExchange.c
  • 5. L O O K AT Y O U R C O D E
  • 6. N O W A S K Y O U R S E L F T W O Q U E S T I O N S
  • 7. I S I T L E G A L ? I S I T S T Y L I S H ?
  • 8. P O I N T O U T S U S P I C I O U S C O D E A V O I D S T U P I D E R R O R S - L I N E S A F T E R A R E T U R N
  • 9. • Missing semicolons • if, for, while without curly braces • Curly braces without if, for, while • Unreachable code after a return, throw, continue, or break • switch/case statements without break • Comments within comments. • Ambiguity whether two adjacent lines are part of the same statement. • Unnecessary code • … L O O K F O R
  • 10. M A I N TA I N U N I F O R M S T Y L E C O N S I S T E N T LY U S I N G 2 S PA C E S , N O TA B S
  • 11. A = B + 1 N O T A = B + 1 F U N C T I O N ( A , B , C ) { R E T U R N 1 ; } N O T F U N C T I O N ( A , B , C ) { R E T U R N 1 ; } F O R ( I = 0 ; I < 3 ; I + + ) N O T F O R ( I = 0 ; I < 3 ; I + + ) A ( 1 , 2 , 3 ) N O T A ( 1 , 2 , 3 ) { A : 1 , B : 2 } N O T { A : 1 , B : 2 } I F ( A ) N O T I F ( A ) … D O M I N A T I N G S T Y L E
  • 12. T H E D Y N A M I C D U O Style CorrectnessFocus on *100 *69 *number of rules
  • 13. T H E D Y N A M I C D U O + T H E N E W K I D Style CorrectnessFocus on ESLint *146 *100 *69 *number of rules
  • 14. N P M A D D I N G L I N T E R S $ npm install -g jshint $ npm install -g jscs $ npm install -g eslint
  • 15. AT O M . I O A D D I N G L I N T E R S
  • 16. B U T W H Y W O U L D Y O U ? You can have as many linters as you like
  • 17. W H AT ’ S W R O N G W I T H M Y C O D E ? S TA R T S M A L L A N D I N T R O D U C E R U L E S A S N E E D E D
  • 18. P L U G G A B L E A R C H I T E C T U R E & C U S T O M R U L E S T H I S I S J U S T T H E T I P O F T H E M O U N TA I N
  • 19. Look, I found some code to fix my code! $ npm install -g js-beautify $ npm install -g esformatter
  • 20. C O D E F I X E R S # of settings* Ease of use esformatter Editorconfig *6 *17 *286
  • 22. AT O M . I O A D D I N G F O R M A T T I N G H E L P E R S
  • 23. C O N F I G U R I N G T H E T O O L S T H E P O W E R O F T H E I N V I S I B L E
  • 24. T L ; D L • Write code that • is valid JavaScript • uses the same style across the team • Use tools to support the writing process • editorconfig • js-beautify • Use ESLint to check style adherence and slowly introduce rules
  • 25. E V E N T U A L LY C O N T I N U O U S I N T E G R A T I O N
  • 26. E V E N T U A L LY C O N T I N U O U S I N T E G R A T I O N
  • 27.
  • 28. W H AT A B O U T C O F F E E ? U S E C O F F E E L I N T !
  • 29. F U R T H E R R E A D I N G • https://github.com/meteor/meteor/wiki/Meteor-Style- Guide • http://jsbeautifier.org/ • http://davidwalsh.name/eslint