-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
Added linting for JavaScript tests. #5192
Conversation
Thanks for the patch. I think it would be great if we could add automatic linting to the tests to prevent future regressions in this area. Do you think you could apply the below patch and fix all the errors? @treyhunner -- sound good? diff --git a/package.json b/package.json
index d926bdc..04da8db 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "Django",
"private": true,
"scripts": {
- "pretest": "eslint django/",
+ "pretest": "eslint django/ js_tests/admin",
"test": "grunt test --verbose"
},
"devDependencies": { |
155cd94
to
210118c
Compare
Alright, I just added a new commit adding that line to |
I'm not sure why the jenkins build is showing new eslint errors. I used the latest version of eslint (version 1.2.1). |
You aren't able to reproduce the errors reported in http://djangoci.com/job/pull-requests-javascript/944/console? |
Correct, |
How about with |
I just ran |
Not sure... could you put the commands output in a pastebin? |
Sure, here's what it looks like: http://dpaste.com/133CK1M |
|
|
Maybe we should. I'm not an expert, but from what I read, "The ^ in the version is a shorthand for >=0.22.1 < 1.0.0. " I guess the rationale is that backwards compatibility should be provided through the next major release. We'll see if Trey chimes in (he did the original work). Did 1.2.1 get installed through |
Ah okay. It was my mistake then. I interpreted "^0.22.1" as "0.22.1 and up", and installed the latest version of eslint in my home directory from outside of the django directory. I just installed eslint via |
@timgraham I agree. I do think the check should be separate from the test check so it fails independently. |
@@ -1,6 +1,7 @@ | |||
module('admin.RelatedObjectLookups'); | |||
|
|||
test('html_unescape', function(assert) { | |||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are all test files, I think all these 'use strict'
statements at the top of each function could be replaced with a single 'use strict'
at the top of each file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I try that I get these errors:
js_tests/admin/RelatedObjectLookups.test.js
3:0 warning Use the function form of "use strict" strict
3:0 error Use the function form of "use strict" global-strict
'use_strict' in every test does seem like boilerplate. Any other alternatives? |
Yeah, I agree it's pretty unnecessary. We could add |
I guess it could be nice to enforce strictness on the JavaScript code, but not the tests? |
In that case we can add |
That seems okay and the PR otherwise looks okay to me. Trey, any comments? |
This works, but I would prefer to enforce strict mode on all code if possible. I would either suppress the warnings about the global |
I've added a new commit to use the global form of |
Looks good to me. Okay with you, Trey? |
👍 looks good An aside: ESLint 1.0 was released about a month ago. global-strict and some other properties will be removed in 1.0 as properties are merged together. |
That's good to know. Maybe I'll make a new PR for eslint 1.x once this is merged. |
Sounds great about updating to eslint 1.x. Merged in 722bf23, thanks! |
No description provided.