SlideShare a Scribd company logo
TOOLING JAVASCRIPT 

TO ENSURE 

CONSISTENCY IN CODING STYLE
Dmitry Sheiko
CODING CONVENTIONS
Coding conventions mean
guidelines for a specific
programming language that
recommend programming style
indentation
comments
white-spaces
namingconventions
etc.
CODING STANDARDS
When coding conventions are adopted they
make a coding standard
JAVASCRIPT CODING STANDARDS


jQuery JavaScript 

Style Guide


Idiomatic.js


Dojo Style Guide



Google JavaScript 

Style Guide
DOES IT REALLY MATTER?
“No programmer is an island”
Code conventions improve the
readability and maintainability
of the software, enabling
engineers to understand the
code more quickly
I RUN JS*INT, SO I’M FINE…
Linter is to detect the code
that may cause potential
problems. To check the coding
style one needs a code sniffer.
JS_CODESNIFFER
JSCodeSniffer is a tool that checks JavaScript
code style consistency according to a provided
coding style
It feels like PHP_CodeSniffer, but for JavaScript.
LET’S ROCK IT
Installation:

$sudo npm install jscodesniffer -g
Get detailed report on a target (file or directory)
coding style according to jQuery JavaScript Style
Guide:

$jscs ./js/source/main.js --standard=Jquery 

--report-full
Tooling JavaScript to ensure consistency in coding style
Get summary report on a target:

$jscs ./js/source --standard=Jquery --report-
summary
Tooling JavaScript to ensure consistency in coding style
Get a report suitable for Jenkins CI-server:

$jscs ./js/source --standard=Jquery —
report=checkstyle —report-file=./build/
checkstyle.xml
Enforce a coding standard in the code:

// Your source code
/* jscs standard:Jquery */
SETTING UP CUSTOM RULE-SET
1. Take a rule-set file in ./standard directory
2. Copy it under the name of your custom
standard (MyConventions)
3. Modify the JSON to fulfil your requirements
Check your code:

$jscs ./js/source --standard=MyConventions
I FOLLOW JQUERY CODING STYLE, BUT NOT
STRICTLY…
JUST SET RELAXING OPTIONS IN RUN-TIME
CONFIGURATION
Place in the root of the project file .jscsrc:

{
"Indentation": false,
"QuoteConventions": false
}
WHAT ABOUT CONTINUOUS INTEGRATION?
Apache Ant setup:



<target name="jscs-ci"
description="Find coding standard violations using JS_CodeSniffer and
print human readable output.">
<exec executable="jscs">
<arg value="--standard=Jquery" />
<arg value="--report=checkstyle" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
<arg path="${basedir}/src" />
</exec>
</target>
Grunt setup:

grunt.loadNpmTasks('grunt-contrib-jscs');
grunt.initConfig({
// Validate against jQuery coding standard
jscs: {
options: {
"standard": "Jquery"
},
all: ["js-folder"]
}
});
JS CodeSniffer
https://github.com/dsheiko/jscodesniffer


JS CodeSniffer Grunt task
https://github.com/dsheiko/grunt-contrib-jscs
!
My credits to flaticon.com for these amazing icons
Thank you!
DMITRY SHEIKO
dsheiko.com
@sheiko
https://github.com/dsheiko

More Related Content

PDF
Eclipse Neon Webinar - JSDT 2.0
PDF
JSDT 2.0 Eclipse DemoCamp (Walldorf)
PDF
Best Practices For Writing Super Readable Code
PDF
It's all about behaviour, also in php - phpspec
PPTX
code documentation
KEY
Jsx language-notes
PDF
MongoDB World 2018: A Swift Introduction to Swift
PPTX
iOS Development at Scale @Chegg
Eclipse Neon Webinar - JSDT 2.0
JSDT 2.0 Eclipse DemoCamp (Walldorf)
Best Practices For Writing Super Readable Code
It's all about behaviour, also in php - phpspec
code documentation
Jsx language-notes
MongoDB World 2018: A Swift Introduction to Swift
iOS Development at Scale @Chegg

Viewers also liked (20)

PPTX
Intro to Library Research for IB History Students
PDF
The Magic of Offal in Chef mag
PDF
Reporting at GWA Parents
PDF
Eco actu n°18
PDF
PPT
GE Money Work Life Balance
PDF
La venta y el servicio por teléfono por José Holmer Torres - www.josehtorresc...
PPT
HSF 1987-2012
PPS
Coches electricos
PDF
oVirt 3.5 - Einführung und Evaluierungsergebnisse
PPT
Gm crops world hunger
PDF
Kieran Pehm | How to reduce complaints from patients with low health literacy?
PDF
E twinning september_2010_web
PPT
Legislacion Adiestrador y Educador de Perros Potencialmente Peligrosos. Comun...
PPT
Making Money With Affiliate Programs for Beginners
PDF
Cerrajeros En Alella 651 novecientos ochenta y dos 619 Apertura De Puertas E...
ODP
Reunion rfc 201415 10_15_v2.0 (presentacion)
PDF
Aire comprimido #48
PPT
Cv Guillermo Grebe Ok
PDF
Diez razones para contratar un agente inmobiliario
Intro to Library Research for IB History Students
The Magic of Offal in Chef mag
Reporting at GWA Parents
Eco actu n°18
GE Money Work Life Balance
La venta y el servicio por teléfono por José Holmer Torres - www.josehtorresc...
HSF 1987-2012
Coches electricos
oVirt 3.5 - Einführung und Evaluierungsergebnisse
Gm crops world hunger
Kieran Pehm | How to reduce complaints from patients with low health literacy?
E twinning september_2010_web
Legislacion Adiestrador y Educador de Perros Potencialmente Peligrosos. Comun...
Making Money With Affiliate Programs for Beginners
Cerrajeros En Alella 651 novecientos ochenta y dos 619 Apertura De Puertas E...
Reunion rfc 201415 10_15_v2.0 (presentacion)
Aire comprimido #48
Cv Guillermo Grebe Ok
Diez razones para contratar un agente inmobiliario
Ad

More from Dmitry Sheiko (7)

PPTX
The Flavor of TypeScript
PPTX
Writing Scalable and Maintainable CSS
PDF
JavaScript MV* Framework - Making the Right Choice
PDF
Modular JavaScript with CommonJS Compiler
PDF
TypeScript Introduction
PDF
A Quick Start - Version Control with Git
PPTX
Bringing classical OOP into JavaScript
The Flavor of TypeScript
Writing Scalable and Maintainable CSS
JavaScript MV* Framework - Making the Right Choice
Modular JavaScript with CommonJS Compiler
TypeScript Introduction
A Quick Start - Version Control with Git
Bringing classical OOP into JavaScript
Ad

Recently uploaded (20)

PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PPT
tcp ip networks nd ip layering assotred slides
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PPTX
presentation_pfe-universite-molay-seltan.pptx
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PPTX
SAP Ariba Sourcing PPT for learning material
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
Introduction to Information and Communication Technology
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
DOCX
Unit-3 cyber security network security of internet system
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
522797556-Unit-2-Temperature-measurement-1-1.pptx
tcp ip networks nd ip layering assotred slides
Cloud-Scale Log Monitoring _ Datadog.pdf
presentation_pfe-universite-molay-seltan.pptx
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Slides PPTX World Game (s) Eco Economic Epochs.pptx
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
Decoding a Decade: 10 Years of Applied CTI Discipline
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
SAP Ariba Sourcing PPT for learning material
An introduction to the IFRS (ISSB) Stndards.pdf
Introduction to Information and Communication Technology
Design_with_Watersergyerge45hrbgre4top (1).ppt
introduction about ICD -10 & ICD-11 ppt.pptx
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PptxGenJS_Demo_Chart_20250317130215833.pptx
Unit-3 cyber security network security of internet system
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
Slides PDF The World Game (s) Eco Economic Epochs.pdf

Tooling JavaScript to ensure consistency in coding style