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

Code Smell: Unexpected var, use let or const instead. #22

Open
andritowmega opened this issue Dec 10, 2024 · 0 comments
Open

Code Smell: Unexpected var, use let or const instead. #22

andritowmega opened this issue Dec 10, 2024 · 0 comments

Comments

@andritowmega
Copy link
Owner

/app.js

var fastMvpApiRouter = require('./fastmvpcore/routes/api');

ECMAScript 2015 introduced the let and const keywords for block-scope variable declaration. Using const creates a read-only (constant) variable.

The distinction between the variable types created by var and by let is significant, and a switch to let will help alleviate many of the variable scope issues which have caused confusion in the past.

Because these new keywords create more precise variable types, they are preferred in environments that support ECMAScript 2015. However, some refactoring may be required by the switch from var to let, and you should be aware that they raise SyntaxErrors in pre-ECMAScript 2015 environments.

This rule raises an issue when var is used instead of const or let.
Noncompliant Code Example

var color = "blue";
var size = 4;

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

No branches or pull requests

1 participant