-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add convention to always declare 'use strict' #117
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#115 It has been an unwritten rule for some time now that we always add 'use strict' to the top of our JavaScript files. Why? > JavaScript's strict mode is a way to opt in to a restricted variant of JavaScript, thereby implicitly opting-out of "sloppy mode". > [MSDN docs - Strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) When the alternate mode is named 'sloppy', would you want to use it!? The docs do provide some further explanation of what declaring strict mode means > Strict mode makes several changes to normal JavaScript semantics: > > 1. Eliminates some JavaScript silent errors by changing them to throw errors. > 2. Fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that's not strict mode. > 3. Prohibits some syntax likely to be defined in future versions of ECMAScript. For these reasons we've had it as an unwritten convention to add it to all files for some time. This change is just to 'resolves' that state and make it a written convention!
Cruikshanks
added a commit
to DEFRA/water-abstraction-system
that referenced
this pull request
May 12, 2024
DEFRA/water-abstraction-team#115 It is currently an unwritten convention (we are [working on](DEFRA/water-abstraction-team#117) fixing that!) to add 'use strict' to the top of all our files. Why? > JavaScript's strict mode is a way to opt in to a restricted variant of JavaScript, thereby implicitly opting-out of "sloppy mode". > [MSDN docs - Strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) When the alternate mode is named 'sloppy', would you want to use it!? The docs do provide some further explanation of what declaring strict mode means > Strict mode makes several changes to normal JavaScript semantics: > > 1. Eliminates some JavaScript silent errors by changing them to throw errors. > 2. Fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that's not strict mode. > 3. Prohibits some syntax likely to be defined in future versions of ECMAScript. For these reasons, this change updates our ESLint rules to ensure we do this.
Eek! Ok, we don't go into detail but we already specify all files should start with a To be honest, that will do it. No need to add more words! |
Cruikshanks
added a commit
to DEFRA/water-abstraction-system
that referenced
this pull request
May 13, 2024
DEFRA/water-abstraction-team#115 It is currently an unwritten convention (we are [working on](DEFRA/water-abstraction-team#117) fixing that!) to add 'use strict' to the top of all our files. Why? > JavaScript's strict mode is a way to opt in to a restricted variant of JavaScript, thereby implicitly opting-out of "sloppy mode". > [MSDN docs - Strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) When the alternate mode is named 'sloppy', would you want to use it!? The docs do provide some further explanation of what declaring strict mode means > Strict mode makes several changes to normal JavaScript semantics: > > 1. Eliminates some JavaScript silent errors by changing them to throw errors. > 2. Fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that's not strict mode. > 3. Prohibits some syntax likely to be defined in future versions of ECMAScript. For these reasons, this change updates our ESLint rules to ensure we do this.
Cruikshanks
added a commit
to DEFRA/water-abstraction-system
that referenced
this pull request
May 13, 2024
DEFRA/water-abstraction-team#115 It is currently an unwritten convention (we are [working on](DEFRA/water-abstraction-team#117) fixing that!) to add 'use strict' to the top of all our files. Why? > JavaScript's strict mode is a way to opt in to a restricted variant of JavaScript, thereby implicitly opting-out of "sloppy mode". > [MSDN docs - Strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) When the alternate mode is named 'sloppy', would you want to use it!? The docs do provide some further explanation of what declaring strict mode means > Strict mode makes several changes to normal JavaScript semantics: > > 1. Eliminates some JavaScript silent errors by changing them to throw errors. > 2. Fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that's not strict mode. > 3. Prohibits some syntax likely to be defined in future versions of ECMAScript. For these reasons, this change updates our ESLint rules to ensure we do this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#115
It has been an unwritten rule for some time now that we always add 'use strict' to the top of our JavaScript files. Why?
When the alternate mode is named 'sloppy', would you want to use it!?
The docs do provide some further explanation of what declaring strict mode means
For these reasons, we've had it as an unwritten convention to add it to all files for some time. This change is to 'resolve' that state of affairs and make it a written convention!