Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

goodparts

Package Overview
Dependencies
Maintainers
5
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

goodparts

An ESLint Style that only allows JavaScript the Good Parts (and "Better Parts") in your codebase.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
314
decreased by-4.27%
Maintainers
5
Weekly downloads
 
Created
Source

goodparts contributions welcome Travis

An ESLint Style that only allows JavaScript the Good Parts (and "Better Parts") in your code you can sleep at night.

Why?

Because this is the best way we know how to write consistent, predictable and error free JavaScript code.

Our guiding principal is:

"perfection is attained not when there is nothing more to add,
but when there is
nothing more to remove" ~ Antoine de Saint-Exupéry

we subscribe to the "code is for humans to read" idea:

"Programs must be written for people to read, and only incidentally for machines to execute." ~ Harold Abelson

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." ~ Martin Fowler

Also, we agree with:

"constraints can actually boost creativity". Martin Villeneuve

The 3 biggest advantages of using goodparts in your code:

  1. Readability - using fewer ECMAScript (JS) language features means people reading your code can get to the heart of what it does rather than waste time trying to understand how its been written.
  2. Shoshin - using fewer JS features also means a complete beginner has less to learn before they understand your code. This is essential in Open Source if you want to make something that anyone can use/modify/extend.
  3. Portability - "Old" Browsers/Devices are a fact, even if it's "only a small percentage" of people, we chose to empathize with them by writing code that Works EverywhereTM.

What?

A one-line install that will ensure your project's code works everywhere. (or your money back!)

What is ESLint?

ESLint is a Linting tool started by Nicholas C. Zakas, it has become the defacto linter in the JS community. see: http://eslint.org/docs/about/

How?

Simply install our configuration

$ npm i --save-dev goodparts

Then you can add the following script to your package.json:

{
  "lint": "node_modules/.bin/goodparts path/to/files/for/linting"
}

See the discussion we've had on each issue here

(Frequently Asked) Questions?

Q: If the intention is to use only the Good Parts, why not use JSLint and not bother with this tool?
A: the simple answer is JSLint (DC's tool), does not allow you to include a project-wide configuration file, so you need to specify your environment e.g: /*jslint node: true */ in every file, which gets old fast.

tl;dr

Why (extended version)

Why Should Anyone Listen to Douglas Crockford?

There are many places you can go to learn JavaScript, unsurprisingly they all claim to teach you the "right way", and as a beginner it's virtually impossible to detect which is the "right" path because there is a lot of marketing hype which can easily be mistaken for "fact".

The only way a beginner can determine if the source of learning is any good is by listening to their their peers or failing that, "gut feeling", neither of which are a reliable measure of quality.

Crockford is the Master Yoda of JavaScript, he has truly mastered the craft.
He is a member of "TC39" (the ECMAScript Technical Committee) responsible for setting the language standard to be implemented by web browser makers; to say that DC "knows" JavaScript inside-out is an understatement. He invented JavaScript Object Notation ("JSON") data format (the Standard for REST APIs) and wrote the first JSON parser. He painstakingly scoured the entire ECMAScript specification in order to compile his list of Good (and Bad) Parts, a subset of the language that can be trusted and used reliably anywhere. He has been lead engineer at Yahoo and Paypal and run his own web consulting company specialising in JS applications.

Most people will not look at http://javascript.crockford.com and think: "yes, this looks like the place to learn JavaScript..." and that's a shame because its "plainness" (lack of pictures or medium-style presentation) does not do justice to the insight he shares.

Better Parts

Selected Quotes Quotes

Highlights from Douglas Crockford's "Better Parts" Talk: https://youtu.be/bo36MrBfTk4
(first presented at JSConfUY 15th March 2014)

  • "Programs must be perfect or they are not right." - 02:21

  • "The Good Parts are what's left when you remove all the bad parts" - 02:30

  • "Criteria for deciding if something is a good part or not is this: if a feature is sometimes useful and sometimes dangerous, and if there is a better option, always use the better option." - 02:41

  • "this is maybe the most important idea tonight:
    We are not paid to use every feature of the language we are paid to write programs that work well and are free of error - 03:10

  • "People don't like programs with errors in them and they wish we would stop doing that." 03:21

  • "Sometimes we work against our own interest, in trying to demonstrate mastery over the language, but we are actually making things worse not better" - 03:29

  • "This will save you some day, if you comply with it..." - 07:47

  • "It's not just a matter of opinion, there is a good reason for everything that JSLint asks you to do"

  • "I'm only telling you not to use the tools that are unnecessary and dangerous" - 07:50

  • "Eventually, we want to be writing with one voice, we want all of the software we develop in a project to look as though it was developed by the same person, and that person is really smart" - k 08:39

  • "Keystroking time is irrelevant, so if you're doing something stupid to shave keystrokes, that's counter-productive." - 09:17

  • "There's a good reason those features were added to the language. I can tell you reliably, that is absolutely not true." - 09:55

  • "Just because a 'foot gun' is in the language, doesn't mean you want to shoot your foot off" - 10:26

Videos

Background Reading


Should We Use ECMAScript 2015 (AKA "ES6")?

When you see someone trying to use all the latest features of ECMAScript 2015, its clear they are just trying to look smart to their piers and have not stopped to think/ask:

  • "will this code work everywhere?"
  • "did the users ask me to use this (new) language feature? (or is there an existing way of doing this reliably...?)"
  • "if I'm just going to transpile this through babel or add a pollyfill (for cross-browser compatibility) which means users have to load more bytes of code in their browser, what is true the advantage...?"

Why does this matter / should I care?

If you are lucky enough to be building an internal web app (*e.g: an intranet or "internal tools") and you "know" that everyone in the company is using Chrome that's awesome, thank your lucky stars and enjoy using all the latest & greatest features!

If, like us, you live in the "real world" and build applications/websites that need to be accessible by and work consistently on any device/browser, then using only the goodparts is a good idea.

We are not suggesting that you (your team/company) should (explicitly) support IE8 running on Windows XP! (heavens no!) Simply that there is an easy way to ensure that your code will work everywhere so you don't have to think about it.

But caniuse.com says ...

Caniuse.com is a fantastic website. The UI is brilliant and for "informal" (i.e. non-scientific) discussions about which HTML5 features are available in a browser, we use it often! But caniuse.com bases it's pretty graphs on the data from statcounter.com which is good but has several flaws in data collection methodology:

  1. Small sample size - StatCounter collects data for a
    "_network of more than 3 million websites" if you know anything about the internet you will realize that this is a drop in the ocean. 3M sites is less than 0.3% of websites on the internet1.

  2. Over counting - StatCounter counts all page views made by a given user (agent) which means that heavy users have higher representation in the sample. (If the website does not work on a given browser/device the person will obviously not get past the first page!) By contrast NetMarketShare only counts the first pageview which means it gives an equal weighting to each visitor.

1According to netcraft.com there are over a billion (active) websites online in May 2016. It is unclear which websites StatCounter is sourcing its data from, please don't take their usage tables as "gospel" because they are flawed.

Browser Stats Facts

Most of us live in a technology bubble, we take it for granted that we always have Wifi or 4G and assume that because many of our friends/colleagues are using MacBook Pros or iPhone 6s that everyone is in the same situation.

At the time of writing Internet Explorer 8 still has a 5.95% (global) Market Share (according to netmarketshare.com April 2016)

browser-facts-pie-chart

Even if we think that "everyone" has switched to Chrome, the facts (stats) are clearly not supporting this hypothesis!

Operating System Market Share

58% of people are still using an Operating System that is no longer supported by Microsoft (Windows 7 & XP market share = 58.45%) ... Microsoft ended "mainstream" support for Windows 7 on Jan 13 2015 so even if they want to force everyone to upgrade to "Edge", they cannot; which means we are relying on non-technical people to manually upgrade their browser... If you have ever been in Tech support and had a person ask "what is a browser?" you will know that might take a while...

Wikipedia as a Representative Sample of all Web Traffic

If you want a representative sample of all internet users, you cannot do better than Wikipedia which has content for almost everyone and does its data-collection server-side (so users without JavaScript or those who have JS disabled are still counted)

Browser / VersionVistors
Internet Explorer 71.65%
Internet Explorer 81.31%
Internet Explorer 91.28%
Total Legacy IE4.24%

See: https://stats.wikimedia.org/wikimedia/squids/SquidReportClients.htm
https://analytics.wikimedia.org/dashboards/browsers/#all-sites-by-browser

If you want to dive a bit deeper into the methodology used by StatCounter see: http://www.zdnet.com/article/net-market-share-vs-statcounter-whose-online-measurements-can-you-trust/

FAQs

Package last updated on 01 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc