Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: add use strict to use es5+ #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

coolaj86
Copy link
Contributor

@coolaj86 coolaj86 commented Jul 3, 2022

No description provided.

@markin-io
Copy link

@coolaj86 could you please explain the purpose of this change? Is something does not work without the "use strict"?

@coolaj86
Copy link
Contributor Author

coolaj86 commented Jul 12, 2022

Is something does not work without the "use strict"?

If you don't "use strict" then the JavaScript runs in ES3 mode rather than ES5 mode, which means the possibility of silent errors, odd behaviors, code that breaks the JIT compiler and wreaks havoc on performance for seemingly no reason.

If you have a linter integrated into your editor (jshint, eslint, etc), it would most likely catch things like accidental global scope, accidental modification of global this, accidental assignment to undefined, accidental corruption of prototypes, accidental use or parseInt of octals, modification of properties of strings, etc.

The problem with not having "use strict";, especially if you're not using a linter that enforces the strict rules, is that you just don't know when something is wrong.

Ex: You forget a new in front of a constructor-ish function and it works for the singleton, all tests pass, but then becomes impossible to debug when you have two instances of the object in the real application, or two objects with some same properties at runtime, etc.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

There's only upside, no downside, and it's required as part of the ES5 spec to run in ES5+ mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants