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

Add lint rule to prefer constants over variables #640

Closed
kumar303 opened this issue Nov 18, 2016 · 6 comments
Closed

Add lint rule to prefer constants over variables #640

kumar303 opened this issue Nov 18, 2016 · 6 comments

Comments

@kumar303
Copy link
Contributor

kumar303 commented Nov 18, 2016

Is this a bug or feature request?

feature

What is the current behavior?

When contributors submit pull requests, @kumar303 always tells them to use const instead of let when they are not modifying the variable.

What is the expected or desired behavior?

We should let the robots tell them this instead! Let's add this rule and fix up the code:

diff --git a/.eslintrc b/.eslintrc
index 24680cd..66c4e3c 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -100,6 +100,7 @@
       "allowMultiplePropertiesPerLine": true
     }],
     "one-var": [2, "never"],
+    "prefer-const": 2,
     "prefer-template": 2,
     "quote-props": [1, "consistent-as-needed"],
     "quotes": [2, "single", "avoid-escape"],````
@pragyes31
Copy link

pragyes31 commented Nov 23, 2016

Hi,

I will work on this issue.

@kumar303
Copy link
Contributor Author

great, thanks! Let me know if you run into any trouble before submitting a pull request.

@shubheksha
Copy link
Contributor

@kumar303, wouldn't this require changing the variables which aren't being reassigned anywhere to const? Eslint will keep complaining otherwise as is evident in #661

@kumar303
Copy link
Contributor Author

@shubheksha yes, exactly. @aniketkudale, sorry for the late reply. I just now had a chance to look at your patch and I pointed out some additional changes needed.

@kewisch
Copy link

kewisch commented Dec 13, 2016

@pragyes31 are you still working on this bug? I'd love to hear back from you!

@pragyes31
Copy link

@kewisch I am. Will submit the PR probably by this weekend.

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

No branches or pull requests

6 participants