SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
The state of
JavaScript Linting
JS Syntax Checking and Validation
Michael Kühnel
- Doing web stuff since Netscape 4.7
- Frontend Developer at Micromata
- Twitter: @mkuehnel
- Website: www.michael-kuehnel.de
History
The (subjectively) »most important« Tools:
- JSLint (Release 2002)*
- JSHint (Initial release 2010)
- ESLint (Initial release 2013)
*JSLint only made it into this list for historical reasons.
Common facts
or what is this linting thing all about …
1. Same purpose - Quality
inspection
Syntax Checker and Validator (JavaScript und JSON)
Quality inspection
Syntax errors which will occur in the browser e.g.
- trailing comma in object literals
- Missing or unnecessary semicolons
- Lack of closing brackets
- Any kind of typing errors
Quality inspection
Prevention of logical errors / structural problems ➡️
Increment of maintainability e.g.
- Detection of unreachable code
- Globale variables by accident
- Unused parameters
- etc.
Quality inspection
Forcing adherence to coding conventions e.g.
- Indentation
- InitialCaps for constructors
- Use of eval()
- etc.
2. Same functionality
A. Finds errors
B. Describes the problem
C. Pointing to the position in code (line number)
3. Same language – same
environments
- Written in JavaScript:
- Browser
- node.js / Rhino
- JS based build tools (Grunt, gulp etc.)
- Editor Plugins
4. Doesn’t guarantee error-
free code
But reduce the potential sources of error by usage in
a convenient place within your Workflow:
- Everytime you save a file
- as pre-commit hook
- within the build Process
There is no error-free code
btw. 😎
Additional recommendations to ensure code quality
within your team:
- Unit-Tests
- Functional Tests
- Code Reviews
JSLint
(will hurt your feelings)
Initial release 2002
JSLint
- Author: JavaScript Guru Douglas Crockford
(»Inventor of JSON«, Developer of JSMin)
- Quote from Crockford: »JavaScript is a sloppy
language, but inside it there is an elegant, better
language.«
- Intention: Enforcing the »Good Parts« of JavaScript
- http://jslint.com
JSHint
(The »Gentler« JavaScript
Code Quality Tool)
Initial release 2010
JSHint
- Author: Anton Kovalyov
- Intention: A more flexible linting tool
- http://jshint.com
Main differences to JSLint:
- Community Driven (133 contributors)
- Test coverage of the source code (Unit-Tests)
- Less opinionated (http://anton.kovalyov.net/p/why-jshint)
- More Options (configurable)
- Support for ECMAScript 6
- Configuration via JavaScript comments or text files
(Recommendation .jshintrc ➡️ Team standard + »inheritance«)
JSHint ≠ JSLint
- Enforcing Options
- e.g. 'maxparams' lets you set the max number of formal
parameters allowed per function.
- Relaxing Options
- e.g. 'loopfunc' - suppresses warnings about functions inside of
loops.
- Environment options - pre-defined global variables for specific
environments
- e.g. 'jquery' - suppresses warnings about the usage of '$' und
'jQuery'.
JSHint - Options
Available as:
- Plugin for almost every editor/IDE
- Task for Grunt/gulp
- etc. See http://jshint.com/install
- Just for a quick test if it suits your needs: on the
website of JSHint
JSHint for all of you
Plans for the next major release (3.0)
- Remove all style-related options and warnings.
- If it makes sense they should be moved into
optional plugins.
- Build a foundation for plugins
See http://www.jshint.com/blog/jshint-3-plans/
JSHint - The future
JSHint - The future
- Strengthens »new« linting tools like:
- node-jscs (JavaScript Code Style checker)
- https://twitter.com/mikesherov/status/
419596672520318976
- https://github.com/mdevils/node-jscs
- ESLint
- http://eslint.org
ESLint

(The pluggable linting utility
for JavaScript)
Initial release 2013
ESLint
- Creator: Nicholas C. Zakas
- Intention:
- More flexible/ pluggable linting tool.
- Initially compatible to JSHint - in terms of
available options
- http://eslint.org
ESLint ≠ JSHint
Main differences to JSHint:
- API for plugging in your own rules
- Every rule is a plugin (even the default rules)
- Every rule can be able to be turned off or on!
- More rules than JSHint
- Ever rule can be set to be a warning or error individually
- Config files in JSON Format or YAML
- »More beautiful« linting reports in your terminal 😘
ESLint - Options
- Environments
- (browser/node/amd/mocha).
- An environment defines both global variables that are
predefined as well as which rules should be on or off by default.
- Globals
- Defining own globals so that ESLint will not warn about their
usage.
- Rules
- Activating rules and define the error-level individually.
ESLint - Overview of the
rules
1. Possible Errors:
- e.g. 'no-dupe-keys' – disallow duplicate keys when creating object literals
2. Best Practices:
- They either prescribe a better way of doing something or help you avoid
footguns.
- e.g. 'wrap-iife' – require immediate function invocation to be wrapped in
parentheses.
3. Strict Mode:
- These rules relate to using strict mode (ECMAScript5).
- e.g. 'no-extra-strict' – disallow unnecessary use of "use strict"; when already in
strict mode.
ESLint - Overview of the
rules
4. Variables:
- These rules have to do with variable declarations
- e.g. 'no-shadow' - disallow declaration of variables already declared in the
outer scope.
5. Node.js:
- These rules are specific to JavaScript running on Node.js
- e.g. 'no-process-exit' - disallow process.exit()
6. Stylistic Issues:
- These rules are purely matters of style and are quite subjective
- e.g. 'no-new-object' - disallow use of the Object constructor
Conclusion
ESLint – The way to go 🔥 – despite the early version (0.4.2)
- Huge set of rules with the most flexible configuration
- future-proof in terms of »style related warnings«
- Pluggability (e.g. company-specific rules to enforce coding
guidelines)
- Probably gathering the most contributors in the near future.
- The eco-system is ready: Even available as module for less know
JS build tools like Broccoli. Siehe http://eslint.org/docs/
integrations
Questions?!
Twitter: @mkuehnel
E-Mail: mail@michael-kuehnel.de
💭
Links I
- JavaScript: The Good Parts:
- http://www.amazon.de/JavaScript-Parts-Working-
Shallow-Grain/dp/0596517742
- JSLint:
- http://jslint.com
- https://github.com/douglascrockford/JSLint
Links II
- JSHint
- http://anton.kovalyov.net/p/why-jshint
- http://jshint.com
- http://jshint.com/docs/options
- https://github.com/jshint/jshint
- http://jshint.com/install
- https://github.com/sindresorhus/jshint-stylish
- https://twitter.com/jshint
Links III
- ESLint
- http://eslint.org
- https://github.com/eslint/eslint
- https://twitter.com/geteslint
- http://eslint.org/docs/configuring
- http://eslint.org/docs/rules/
- http://eslint.org/docs/integrations
Links IV
- CoffeeScript
- http://www.coffeelint.org

Contenu connexe

Tendances

WebdriverIO: the Swiss Army Knife of testing
WebdriverIO: the Swiss Army Knife of testingWebdriverIO: the Swiss Army Knife of testing
WebdriverIO: the Swiss Army Knife of testingDaniel Chivescu
 
Webdriver io presentation
Webdriver io presentationWebdriver io presentation
Webdriver io presentationJoão Nabais
 
Javascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stackJavascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stackRan Bar-Zik
 
PHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the codePHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the codeMichal Juhas
 
Breaking AngularJS Javascript sandbox
Breaking AngularJS Javascript sandboxBreaking AngularJS Javascript sandbox
Breaking AngularJS Javascript sandboxMathias Karlsson
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.jsRyan Anklam
 
Frontend automation and stability
Frontend automation and stabilityFrontend automation and stability
Frontend automation and stabilityMáté Nádasdi
 
Ruxmon feb 2013 what happened to rails
Ruxmon feb 2013   what happened to railsRuxmon feb 2013   what happened to rails
Ruxmon feb 2013 what happened to railssnyff
 
Server-side template injection- Slides
Server-side template injection- Slides Server-side template injection- Slides
Server-side template injection- Slides Amit Dubey
 
Understanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram KharviUnderstanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram KharviCysinfo Cyber Security Community
 
5 sample questions about Single Thread Model (Cx 310 083)
5 sample questions about Single Thread Model (Cx 310 083)5 sample questions about Single Thread Model (Cx 310 083)
5 sample questions about Single Thread Model (Cx 310 083)Maarten Storm
 
Cypress first impressions
Cypress first impressionsCypress first impressions
Cypress first impressionsHans Emmel
 
Nightwatch JS for End to End Tests
Nightwatch JS for End to End TestsNightwatch JS for End to End Tests
Nightwatch JS for End to End TestsSriram Angajala
 
libinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick Galbreathlibinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick GalbreathCODE BLUE
 
Breaking The Framework's Core #PHPKonf 2016
Breaking The Framework's Core #PHPKonf 2016Breaking The Framework's Core #PHPKonf 2016
Breaking The Framework's Core #PHPKonf 2016Mehmet Ince
 
Introduction to PhantomJS
Introduction to PhantomJSIntroduction to PhantomJS
Introduction to PhantomJSErol Selitektay
 
One step in the future: CSS variables
One step in the future: CSS variablesOne step in the future: CSS variables
One step in the future: CSS variablesGiacomo Zinetti
 

Tendances (20)

WebdriverIO: the Swiss Army Knife of testing
WebdriverIO: the Swiss Army Knife of testingWebdriverIO: the Swiss Army Knife of testing
WebdriverIO: the Swiss Army Knife of testing
 
Webdriver io presentation
Webdriver io presentationWebdriver io presentation
Webdriver io presentation
 
Javascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stackJavascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stack
 
PHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the codePHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the code
 
Breaking AngularJS Javascript sandbox
Breaking AngularJS Javascript sandboxBreaking AngularJS Javascript sandbox
Breaking AngularJS Javascript sandbox
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.js
 
Frontend automation and stability
Frontend automation and stabilityFrontend automation and stability
Frontend automation and stability
 
Ruxmon feb 2013 what happened to rails
Ruxmon feb 2013   what happened to railsRuxmon feb 2013   what happened to rails
Ruxmon feb 2013 what happened to rails
 
Server-side template injection- Slides
Server-side template injection- Slides Server-side template injection- Slides
Server-side template injection- Slides
 
Understanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram KharviUnderstanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
 
Flash it baby!
Flash it baby!Flash it baby!
Flash it baby!
 
5 sample questions about Single Thread Model (Cx 310 083)
5 sample questions about Single Thread Model (Cx 310 083)5 sample questions about Single Thread Model (Cx 310 083)
5 sample questions about Single Thread Model (Cx 310 083)
 
Cypress first impressions
Cypress first impressionsCypress first impressions
Cypress first impressions
 
Nightwatch JS for End to End Tests
Nightwatch JS for End to End TestsNightwatch JS for End to End Tests
Nightwatch JS for End to End Tests
 
Node.JS security
Node.JS securityNode.JS security
Node.JS security
 
libinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick Galbreathlibinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick Galbreath
 
How To Detect Xss
How To Detect XssHow To Detect Xss
How To Detect Xss
 
Breaking The Framework's Core #PHPKonf 2016
Breaking The Framework's Core #PHPKonf 2016Breaking The Framework's Core #PHPKonf 2016
Breaking The Framework's Core #PHPKonf 2016
 
Introduction to PhantomJS
Introduction to PhantomJSIntroduction to PhantomJS
Introduction to PhantomJS
 
One step in the future: CSS variables
One step in the future: CSS variablesOne step in the future: CSS variables
One step in the future: CSS variables
 

Similaire à The state of JavaScript Linting - English version

Sandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession LearnedSandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession LearnedMinded Security
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsLewis Ardern
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JSFestUA
 
The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9jClarity
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!Alessandro Giorgetti
 
Статический анализ кода в контексте SSDL
Статический анализ кода в контексте SSDLСтатический анализ кода в контексте SSDL
Статический анализ кода в контексте SSDLPositive Hack Days
 
Gatling - Stress test tool
Gatling - Stress test toolGatling - Stress test tool
Gatling - Stress test toolKnoldus Inc.
 
Writing code for people
Writing code for peopleWriting code for people
Writing code for peopleAlexey Ivanov
 
Expanding XPages with Bootstrap Plugins for Ultimate Usability
Expanding XPages with Bootstrap Plugins for Ultimate UsabilityExpanding XPages with Bootstrap Plugins for Ultimate Usability
Expanding XPages with Bootstrap Plugins for Ultimate UsabilityTeamstudio
 
Building Web Applications Without a Framework
Building Web Applications Without a FrameworkBuilding Web Applications Without a Framework
Building Web Applications Without a FrameworkAll Things Open
 
React & Redux JS
React & Redux JS React & Redux JS
React & Redux JS Hamed Farag
 

Similaire à The state of JavaScript Linting - English version (20)

The Java alternative to Javascript
The Java alternative to JavascriptThe Java alternative to Javascript
The Java alternative to Javascript
 
Gallio Crafting A Toolchain
Gallio Crafting A ToolchainGallio Crafting A Toolchain
Gallio Crafting A Toolchain
 
Spring IO 2015 Spock Workshop
Spring IO 2015 Spock WorkshopSpring IO 2015 Spock Workshop
Spring IO 2015 Spock Workshop
 
Sandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession LearnedSandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession Learned
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript Applications
 
ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
 
Greach 2015 Spock workshop
Greach 2015 Spock workshopGreach 2015 Spock workshop
Greach 2015 Spock workshop
 
The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!
 
Android develop guideline
Android develop guidelineAndroid develop guideline
Android develop guideline
 
Aurelia intro
Aurelia introAurelia intro
Aurelia intro
 
Статический анализ кода в контексте SSDL
Статический анализ кода в контексте SSDLСтатический анализ кода в контексте SSDL
Статический анализ кода в контексте SSDL
 
Gatling - Stress test tool
Gatling - Stress test toolGatling - Stress test tool
Gatling - Stress test tool
 
SAST_QSDL
SAST_QSDLSAST_QSDL
SAST_QSDL
 
Writing code for people
Writing code for peopleWriting code for people
Writing code for people
 
Expanding XPages with Bootstrap Plugins for Ultimate Usability
Expanding XPages with Bootstrap Plugins for Ultimate UsabilityExpanding XPages with Bootstrap Plugins for Ultimate Usability
Expanding XPages with Bootstrap Plugins for Ultimate Usability
 
Building Web Applications Without a Framework
Building Web Applications Without a FrameworkBuilding Web Applications Without a Framework
Building Web Applications Without a Framework
 
React & Redux JS
React & Redux JS React & Redux JS
React & Redux JS
 
TypeScript intro
TypeScript introTypeScript intro
TypeScript intro
 

Dernier

Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Dernier (20)

Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

The state of JavaScript Linting - English version

  • 1. The state of JavaScript Linting JS Syntax Checking and Validation
  • 2. Michael Kühnel - Doing web stuff since Netscape 4.7 - Frontend Developer at Micromata - Twitter: @mkuehnel - Website: www.michael-kuehnel.de
  • 3. History The (subjectively) »most important« Tools: - JSLint (Release 2002)* - JSHint (Initial release 2010) - ESLint (Initial release 2013) *JSLint only made it into this list for historical reasons.
  • 4. Common facts or what is this linting thing all about …
  • 5. 1. Same purpose - Quality inspection Syntax Checker and Validator (JavaScript und JSON)
  • 6. Quality inspection Syntax errors which will occur in the browser e.g. - trailing comma in object literals - Missing or unnecessary semicolons - Lack of closing brackets - Any kind of typing errors
  • 7. Quality inspection Prevention of logical errors / structural problems ➡️ Increment of maintainability e.g. - Detection of unreachable code - Globale variables by accident - Unused parameters - etc.
  • 8. Quality inspection Forcing adherence to coding conventions e.g. - Indentation - InitialCaps for constructors - Use of eval() - etc.
  • 9. 2. Same functionality A. Finds errors B. Describes the problem C. Pointing to the position in code (line number)
  • 10. 3. Same language – same environments - Written in JavaScript: - Browser - node.js / Rhino - JS based build tools (Grunt, gulp etc.) - Editor Plugins
  • 11. 4. Doesn’t guarantee error- free code But reduce the potential sources of error by usage in a convenient place within your Workflow: - Everytime you save a file - as pre-commit hook - within the build Process
  • 12. There is no error-free code btw. 😎 Additional recommendations to ensure code quality within your team: - Unit-Tests - Functional Tests - Code Reviews
  • 13. JSLint (will hurt your feelings) Initial release 2002
  • 14. JSLint - Author: JavaScript Guru Douglas Crockford (»Inventor of JSON«, Developer of JSMin) - Quote from Crockford: »JavaScript is a sloppy language, but inside it there is an elegant, better language.« - Intention: Enforcing the »Good Parts« of JavaScript - http://jslint.com
  • 15. JSHint (The »Gentler« JavaScript Code Quality Tool) Initial release 2010
  • 16. JSHint - Author: Anton Kovalyov - Intention: A more flexible linting tool - http://jshint.com
  • 17. Main differences to JSLint: - Community Driven (133 contributors) - Test coverage of the source code (Unit-Tests) - Less opinionated (http://anton.kovalyov.net/p/why-jshint) - More Options (configurable) - Support for ECMAScript 6 - Configuration via JavaScript comments or text files (Recommendation .jshintrc ➡️ Team standard + »inheritance«) JSHint ≠ JSLint
  • 18. - Enforcing Options - e.g. 'maxparams' lets you set the max number of formal parameters allowed per function. - Relaxing Options - e.g. 'loopfunc' - suppresses warnings about functions inside of loops. - Environment options - pre-defined global variables for specific environments - e.g. 'jquery' - suppresses warnings about the usage of '$' und 'jQuery'. JSHint - Options
  • 19. Available as: - Plugin for almost every editor/IDE - Task for Grunt/gulp - etc. See http://jshint.com/install - Just for a quick test if it suits your needs: on the website of JSHint JSHint for all of you
  • 20. Plans for the next major release (3.0) - Remove all style-related options and warnings. - If it makes sense they should be moved into optional plugins. - Build a foundation for plugins See http://www.jshint.com/blog/jshint-3-plans/ JSHint - The future
  • 21. JSHint - The future - Strengthens »new« linting tools like: - node-jscs (JavaScript Code Style checker) - https://twitter.com/mikesherov/status/ 419596672520318976 - https://github.com/mdevils/node-jscs - ESLint - http://eslint.org
  • 22. ESLint
 (The pluggable linting utility for JavaScript) Initial release 2013
  • 23. ESLint - Creator: Nicholas C. Zakas - Intention: - More flexible/ pluggable linting tool. - Initially compatible to JSHint - in terms of available options - http://eslint.org
  • 24. ESLint ≠ JSHint Main differences to JSHint: - API for plugging in your own rules - Every rule is a plugin (even the default rules) - Every rule can be able to be turned off or on! - More rules than JSHint - Ever rule can be set to be a warning or error individually - Config files in JSON Format or YAML - »More beautiful« linting reports in your terminal 😘
  • 25. ESLint - Options - Environments - (browser/node/amd/mocha). - An environment defines both global variables that are predefined as well as which rules should be on or off by default. - Globals - Defining own globals so that ESLint will not warn about their usage. - Rules - Activating rules and define the error-level individually.
  • 26. ESLint - Overview of the rules 1. Possible Errors: - e.g. 'no-dupe-keys' – disallow duplicate keys when creating object literals 2. Best Practices: - They either prescribe a better way of doing something or help you avoid footguns. - e.g. 'wrap-iife' – require immediate function invocation to be wrapped in parentheses. 3. Strict Mode: - These rules relate to using strict mode (ECMAScript5). - e.g. 'no-extra-strict' – disallow unnecessary use of "use strict"; when already in strict mode.
  • 27. ESLint - Overview of the rules 4. Variables: - These rules have to do with variable declarations - e.g. 'no-shadow' - disallow declaration of variables already declared in the outer scope. 5. Node.js: - These rules are specific to JavaScript running on Node.js - e.g. 'no-process-exit' - disallow process.exit() 6. Stylistic Issues: - These rules are purely matters of style and are quite subjective - e.g. 'no-new-object' - disallow use of the Object constructor
  • 28. Conclusion ESLint – The way to go 🔥 – despite the early version (0.4.2) - Huge set of rules with the most flexible configuration - future-proof in terms of »style related warnings« - Pluggability (e.g. company-specific rules to enforce coding guidelines) - Probably gathering the most contributors in the near future. - The eco-system is ready: Even available as module for less know JS build tools like Broccoli. Siehe http://eslint.org/docs/ integrations
  • 30. Links I - JavaScript: The Good Parts: - http://www.amazon.de/JavaScript-Parts-Working- Shallow-Grain/dp/0596517742 - JSLint: - http://jslint.com - https://github.com/douglascrockford/JSLint
  • 31. Links II - JSHint - http://anton.kovalyov.net/p/why-jshint - http://jshint.com - http://jshint.com/docs/options - https://github.com/jshint/jshint - http://jshint.com/install - https://github.com/sindresorhus/jshint-stylish - https://twitter.com/jshint
  • 32. Links III - ESLint - http://eslint.org - https://github.com/eslint/eslint - https://twitter.com/geteslint - http://eslint.org/docs/configuring - http://eslint.org/docs/rules/ - http://eslint.org/docs/integrations
  • 33. Links IV - CoffeeScript - http://www.coffeelint.org