Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix inconsistent style and add EditorConfig file #2577

Closed
wants to merge 5 commits into from

3 participants

Trey Hunner Tim Graham Ramiro Morales
Trey Hunner

For ticket 22463.

I haven't yet analyzed the inconsistencies between final newlines in the JSON files.

Some more potential changes that could be made:

  • Change code style of JS files to all use 4 spaces for indentation
  • Explicitly list each code style (py, xml, js, rst, etc.) instead of using a * catch-all section
  • Analyze code in tests directory to determine whether some of the inconsistent files (json/xml/po files mostly) should be made consistent

You can confirm that this commit is purely a whitespace change (except for the addition of the .editorconfig file) by running git diff -w or using ?w=1 on Github.

Check http://editorconfig.org for more details on EditorConfig.

treyhunner added some commits
Trey Hunner treyhunner Add newlines to the ends of files missing them
Changes:
- Ensure all CSS files have a final newline
- Ensure all HTML files have a final newline
- Ensure all JavaScript files have a final newline
150f9be
Trey Hunner treyhunner Remove tab indentation (use spaces) 2785b48
Trey Hunner treyhunner Add EditorConfig file declaring current code style a6807f8
Trey Hunner treyhunner Add a basic JSHint configuration file for JS code
Install jshint with:

    npm install -g jshint

Check code with:

    jshint .
8f4eaff
Ramiro Morales
Collaborator

I'd simply ignore the .graffle files as they are machine-generated.

In the .graffle files will never be edited manually, I would just remove their reference from EditorConfig and treat them as if they were a binary file (note that .png and many other file types are not listed because they are binary).

Collaborator

Yes, that's what I meant. We are in agreement.

Trey Hunner treyhunner referenced this pull request in django/deps
Merged

Add DEP: JavaScript Tests #4

Tim Graham
Owner

I merged the newline/tab fixes. Are you still working on this? I think we should add documentation about the lint configs before we merge it.

Trey Hunner

@timgraham #3003 fixes most of the JS configuration so jshint works as expected. I made a branch that finishes the JS linting started by that pull request but I have not made a pull request for it: https://github.com/treyhunner/django/tree/fix-jshint-errors

Tim Graham
Owner

Okay, well I guess this PR (the editor config) cannot be merged as it is, so closing for now.

Tim Graham timgraham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 16, 2014
  1. Trey Hunner

    Add newlines to the ends of files missing them

    treyhunner authored
    Changes:
    - Ensure all CSS files have a final newline
    - Ensure all HTML files have a final newline
    - Ensure all JavaScript files have a final newline
  2. Trey Hunner
  3. Trey Hunner
  4. Trey Hunner

    Add a basic JSHint configuration file for JS code

    treyhunner authored
    Install jshint with:
    
        npm install -g jshint
    
    Check code with:
    
        jshint .
Commits on Apr 18, 2014
  1. Trey Hunner
This page is out of date. Refresh to see the latest.
Showing with 109 additions and 61 deletions.
  1. +41 −0 .editorconfig
  2. +2 −0  .jshintignore
  3. +5 −0 .jshintrc
  4. +1 −1  django/contrib/admin/static/admin/css/ie.css
  5. +3 −3 django/contrib/admin/static/admin/css/rtl.css
  6. +1 −1  django/contrib/auth/tests/templates/registration/logged_out.html
  7. +1 −1  django/contrib/auth/tests/templates/registration/login.html
  8. +1 −1  django/contrib/auth/tests/templates/registration/password_change_form.html
  9. +1 −1  django/contrib/auth/tests/templates/registration/password_reset_complete.html
  10. +1 −1  django/contrib/auth/tests/templates/registration/password_reset_done.html
  11. +1 −1  django/contrib/auth/tests/templates/registration/password_reset_form.html
  12. +1 −1  django/contrib/flatpages/tests/templates/404.html
  13. +1 −1  django/contrib/formtools/tests/templates/base.html
  14. +1 −1  django/contrib/gis/templates/gis/admin/osm.html
  15. +1 −1  django/contrib/gis/templates/gis/google/google-multi.js
  16. +1 −1  django/contrib/gis/templates/gis/google/google-single.js
  17. +1 −1  docs/_theme/djangodocs/genindex.html
  18. +1 −1  docs/_theme/djangodocs/layout.html
  19. +1 −1  docs/_theme/djangodocs/modindex.html
  20. +1 −1  docs/_theme/djangodocs/search.html
  21. +1 −1  docs/_theme/djangodocs/static/default.css
  22. +1 −1  docs/_theme/djangodocs/static/homepage.css
  23. +1 −1  tests/generic_views/templates/generic_views/apple_detail.html
  24. +1 −1  tests/generic_views/templates/generic_views/artist_detail.html
  25. +1 −1  tests/generic_views/templates/generic_views/artist_form.html
  26. +1 −1  tests/generic_views/templates/generic_views/author_confirm_delete.html
  27. +1 −1  tests/generic_views/templates/generic_views/author_detail.html
  28. +1 −1  tests/generic_views/templates/generic_views/author_form.html
  29. +1 −1  tests/generic_views/templates/generic_views/author_list.html
  30. +1 −1  tests/generic_views/templates/generic_views/author_objects.html
  31. +1 −1  tests/generic_views/templates/generic_views/author_view.html
  32. +1 −1  tests/generic_views/templates/generic_views/book_archive_day.html
  33. +1 −1  tests/generic_views/templates/generic_views/book_archive_month.html
  34. +1 −1  tests/generic_views/templates/generic_views/book_archive_week.html
  35. +1 −1  tests/generic_views/templates/generic_views/book_detail.html
  36. +1 −1  tests/generic_views/templates/generic_views/book_list.html
  37. +1 −1  tests/generic_views/templates/generic_views/confirm_delete.html
  38. +1 −1  tests/generic_views/templates/generic_views/detail.html
  39. +1 −1  tests/generic_views/templates/generic_views/form.html
  40. +1 −1  tests/generic_views/templates/generic_views/list.html
  41. +1 −1  tests/generic_views/templates/generic_views/page_template.html
  42. +1 −1  tests/generic_views/templates/registration/login.html
  43. +1 −1  tests/staticfiles_tests/project/documents/cached/absolute.css
  44. +1 −1  tests/staticfiles_tests/project/documents/cached/css/window.css
  45. +1 −1  tests/staticfiles_tests/project/documents/cached/relative.css
  46. +1 −1  tests/staticfiles_tests/project/documents/cached/styles.css
  47. +1 −1  tests/staticfiles_tests/project/documents/cached/styles_insensitive.css
  48. +1 −1  tests/staticfiles_tests/project/documents/cached/url.css
  49. +1 −1  tests/syndication_tests/templates/syndication/description.html
  50. +1 −1  tests/syndication_tests/templates/syndication/description_context.html
  51. +1 −1  tests/syndication_tests/templates/syndication/title.html
  52. +1 −1  tests/syndication_tests/templates/syndication/title_context.html
  53. +1 −1  tests/template_tests/templates/test_context.html
  54. +1 −1  tests/template_tests/templates/test_include_error.html
  55. +1 −1  tests/templates/base.html
  56. +1 −1  tests/templates/extended.html
  57. +1 −1  tests/templates/form_view.html
  58. +1 −1  tests/templates/login.html
  59. +1 −1  tests/templates/views/article_archive_month.html
  60. +1 −1  tests/templates/views/article_confirm_delete.html
  61. +1 −1  tests/templates/views/article_list.html
  62. +1 −1  tests/templates/views/datearticle_archive_month.html
41 .editorconfig
View
@@ -0,0 +1,41 @@
+# http://editorconfig.org
+
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+insert_final_newline = true
+trim_trailing_whitespace = true
+end_of_line = lf
+charset = utf-8
+
+# Use 2 spaces for the HTML files
+[*.html]
+indent_size = 2
+
+# The JSON files contain newlines inconsistently
+[*.json]
+indent_size = 2
+insert_final_newline = sometimes
+
+# These JS files use tabs instead of spaces
+[**/admin/js/{actions,collapse,jquery}.js]
+indent_style = tab
+
+# These JS files use 2 spaces instead of 4
+[**/admin/js/{inlines,openlayers}.js]
+indent_size = 2
+
+# Minified JavaScript files shouldn't be changed
+[**.min.js]
+indent_style = ignore
+insert_final_newline = ignore
+
+# Makefiles always use tabs for indentation
+[Makefile]
+indent_style = tab
+
+# Batch files and OmniGraffle files use tabs for indentation
+[*.{bat,graffle}]
+indent_style = tab
2  .jshintignore
View
@@ -0,0 +1,2 @@
+**/*/jquery.js
+**/*/*.min.js
5 .jshintrc
View
@@ -0,0 +1,5 @@
+{
+ "strict": false,
+ "browser": true,
+ "jquery": true
+}
2  django/contrib/admin/static/admin/css/ie.css
View
@@ -60,4 +60,4 @@
.change-list ul.toplinks li {
zoom: 1;
*display: inline;
-}
+}
6 django/contrib/admin/static/admin/css/rtl.css
View
@@ -85,8 +85,8 @@ table thead th.sorted .sortoptions {
}
thead th.sorted .text {
- padding-right: 0;
- padding-left: 42px;
+ padding-right: 0;
+ padding-left: 42px;
}
/* dashboard styles */
@@ -247,4 +247,4 @@ div.colM {
.submit-row input {
float: left;
-}
+}
2  django/contrib/auth/tests/templates/registration/logged_out.html
View
@@ -1 +1 @@
-Logged out
+Logged out
2  django/contrib/auth/tests/templates/registration/login.html
View
@@ -1 +1 @@
-{{ form.as_ul }}
+{{ form.as_ul }}
2  django/contrib/auth/tests/templates/registration/password_change_form.html
View
@@ -1 +1 @@
-{{ form }}
+{{ form }}
2  django/contrib/auth/tests/templates/registration/password_reset_complete.html
View
@@ -1 +1 @@
-Password reset successfully
+Password reset successfully
2  django/contrib/auth/tests/templates/registration/password_reset_done.html
View
@@ -1 +1 @@
-Email sent
+Email sent
2  django/contrib/auth/tests/templates/registration/password_reset_form.html
View
@@ -1 +1 @@
-{{ form }}
+{{ form }}
2  django/contrib/flatpages/tests/templates/404.html
View
@@ -1 +1 @@
-<h1>Oh Noes!</h1>
+<h1>Oh Noes!</h1>
2  django/contrib/formtools/tests/templates/base.html
View
@@ -1,2 +1,2 @@
{% block content %}
-{% endblock %}
+{% endblock %}
2  django/contrib/gis/templates/gis/admin/osm.html
View
@@ -1,2 +1,2 @@
{% extends "gis/admin/openlayers.html" %}
-{% block openlayers %}{% include "gis/admin/osm.js" %}{% endblock %}
+{% block openlayers %}{% include "gis/admin/osm.js" %}{% endblock %}
2  django/contrib/gis/templates/gis/google/google-multi.js
View
@@ -5,4 +5,4 @@
{% for dom_id in dom_ids %}{{ js_module }}.{{ dom_id }}_load();
{% endfor %}
}
-{% endblock %}
+{% endblock %}
2  django/contrib/gis/templates/gis/google/google-single.js
View
@@ -1,2 +1,2 @@
{% extends "gis/google/google-map.js" %}
-{% block vars %}{# No vars here because used within GoogleMapSet #}{% endblock %}
+{% block vars %}{# No vars here because used within GoogleMapSet #}{% endblock %}
2  docs/_theme/djangodocs/genindex.html
View
@@ -1,4 +1,4 @@
{% extends "basic/genindex.html" %}
{% block bodyclass %}{% endblock %}
-{% block sidebarwrapper %}{% endblock %}
+{% block sidebarwrapper %}{% endblock %}
2  docs/_theme/djangodocs/layout.html
View
@@ -125,4 +125,4 @@
{% block relbar2 %}{% endblock %}
{% block sidebar1 %}{% endblock %}
{% block sidebar2 %}{% endblock %}
-{% block footer %}{% endblock %}
+{% block footer %}{% endblock %}
2  docs/_theme/djangodocs/modindex.html
View
@@ -1,3 +1,3 @@
{% extends "basic/modindex.html" %}
{% block bodyclass %}{% endblock %}
-{% block sidebarwrapper %}{% endblock %}
+{% block sidebarwrapper %}{% endblock %}
2  docs/_theme/djangodocs/search.html
View
@@ -1,3 +1,3 @@
{% extends "basic/search.html" %}
{% block bodyclass %}{% endblock %}
-{% block sidebarwrapper %}{% endblock %}
+{% block sidebarwrapper %}{% endblock %}
2  docs/_theme/djangodocs/static/default.css
View
@@ -1,3 +1,3 @@
@import url(reset-fonts-grids.css);
@import url(djangodocs.css);
-@import url(homepage.css);
+@import url(homepage.css);
2  docs/_theme/djangodocs/static/homepage.css
View
@@ -19,4 +19,4 @@
#index #s-solving-specific-problems,
#index #s-reference,
#index #s-and-all-the-rest
- { clear: left; }
+ { clear: left; }
2  tests/generic_views/templates/generic_views/apple_detail.html
View
@@ -1 +1 @@
-This is a {% if tasty %}tasty {% endif %}{{ apple.color }} apple{{ extra }}
+This is a {% if tasty %}tasty {% endif %}{{ apple.color }} apple{{ extra }}
2  tests/generic_views/templates/generic_views/artist_detail.html
View
@@ -1 +1 @@
-This is an {{ artist }}.
+This is an {{ artist }}.
2  tests/generic_views/templates/generic_views/artist_form.html
View
@@ -1 +1 @@
-A form: {{ form }}
+A form: {{ form }}
2  tests/generic_views/templates/generic_views/author_confirm_delete.html
View
@@ -1 +1 @@
-Are you sure?
+Are you sure?
2  tests/generic_views/templates/generic_views/author_detail.html
View
@@ -1 +1 @@
-This is an {{ author }}.
+This is an {{ author }}.
2  tests/generic_views/templates/generic_views/author_form.html
View
@@ -1 +1 @@
-A form: {{ form }}
+A form: {{ form }}
2  tests/generic_views/templates/generic_views/author_list.html
View
@@ -1,3 +1,3 @@
{% for item in object_list %}
{{ item }}
-{% endfor %}
+{% endfor %}
2  tests/generic_views/templates/generic_views/author_objects.html
View
@@ -1,3 +1,3 @@
{% for item in object_list %}
{{ item }}
-{% endfor %}
+{% endfor %}
2  tests/generic_views/templates/generic_views/author_view.html
View
@@ -1 +1 @@
-This is an alternate template_name_suffix for an {{ author }}.
+This is an alternate template_name_suffix for an {{ author }}.
2  tests/generic_views/templates/generic_views/book_archive_day.html
View
@@ -1 +1 @@
-Archive for {{ day }}. Previous day is {{ previous_day }}
+Archive for {{ day }}. Previous day is {{ previous_day }}
2  tests/generic_views/templates/generic_views/book_archive_month.html
View
@@ -1 +1 @@
-Books in {{ month }}.
+Books in {{ month }}.
2  tests/generic_views/templates/generic_views/book_archive_week.html
View
@@ -1 +1 @@
-Archive for {{ week }}.
+Archive for {{ week }}.
2  tests/generic_views/templates/generic_views/book_detail.html
View
@@ -1 +1 @@
-This is {{ book }}.
+This is {{ book }}.
2  tests/generic_views/templates/generic_views/book_list.html
View
@@ -1,3 +1,3 @@
{% for item in object_list %}
{{ item }}
-{% endfor %}
+{% endfor %}
2  tests/generic_views/templates/generic_views/confirm_delete.html
View
@@ -1 +1 @@
-Generic: Are you sure?
+Generic: Are you sure?
2  tests/generic_views/templates/generic_views/detail.html
View
@@ -1 +1 @@
-Look, an {{ object }}.
+Look, an {{ object }}.
2  tests/generic_views/templates/generic_views/form.html
View
@@ -1 +1 @@
-A generic form: {{ form }}
+A generic form: {{ form }}
2  tests/generic_views/templates/generic_views/list.html
View
@@ -1,3 +1,3 @@
{% for item in object_list %}
{{ item }}
-{% endfor %}
+{% endfor %}
2  tests/generic_views/templates/generic_views/page_template.html
View
@@ -1 +1 @@
-This is some content: {{ content }}
+This is some content: {{ content }}
2  tests/generic_views/templates/registration/login.html
View
@@ -1 +1 @@
-An empty login template.
+An empty login template.
2  tests/staticfiles_tests/project/documents/cached/absolute.css
View
@@ -1,4 +1,4 @@
@import url("/static/cached/styles.css");
body {
background: #d3d6d8 url(/static/cached/img/relative.png);
-}
+}
2  tests/staticfiles_tests/project/documents/cached/css/window.css
View
@@ -1,3 +1,3 @@
body {
background: #d3d6d8 url("img/window.png");
-}
+}
2  tests/staticfiles_tests/project/documents/cached/relative.css
View
@@ -3,4 +3,4 @@
@import url("absolute.css#eggs");
body {
background: #d3d6d8 url(img/relative.png);
-}
+}
2  tests/staticfiles_tests/project/documents/cached/styles.css
View
@@ -1 +1 @@
-@import url("other.css");
+@import url("other.css");
2  tests/staticfiles_tests/project/documents/cached/styles_insensitive.css
View
@@ -1 +1 @@
-@IMporT uRL("other.css");
+@IMporT uRL("other.css");
2  tests/staticfiles_tests/project/documents/cached/url.css
View
@@ -1 +1 @@
-@import url("https://www.djangoproject.com/m/css/base.css");
+@import url("https://www.djangoproject.com/m/css/base.css");
2  tests/syndication_tests/templates/syndication/description.html
View
@@ -1 +1 @@
-Description in your templates: {{ obj }}
+Description in your templates: {{ obj }}
2  tests/syndication_tests/templates/syndication/description_context.html
View
@@ -1 +1 @@
-{{ obj }} (foo is {{ foo }})
+{{ obj }} (foo is {{ foo }})
2  tests/syndication_tests/templates/syndication/title.html
View
@@ -1 +1 @@
-Title in your templates: {{ obj }}
+Title in your templates: {{ obj }}
2  tests/syndication_tests/templates/syndication/title_context.html
View
@@ -1 +1 @@
-{{ obj }} (foo is {{ foo }})
+{{ obj }} (foo is {{ foo }})
2  tests/template_tests/templates/test_context.html
View
@@ -1 +1 @@
-obj:{{ obj }}
+obj:{{ obj }}
2  tests/template_tests/templates/test_include_error.html
View
@@ -1 +1 @@
-{% include "missing.html" %}
+{% include "missing.html" %}
2  tests/templates/base.html
View
@@ -5,4 +5,4 @@
{% block content %}
{% endblock %}
</body>
-</html>
+</html>
2  tests/templates/extended.html
View
@@ -2,4 +2,4 @@
{% block title %}Extended template{% endblock %}
{% block content %}
This is just a template extending the base.
-{% endblock %}
+{% endblock %}
2  tests/templates/form_view.html
View
@@ -12,4 +12,4 @@
</ul>
</form>
-{% endblock %}
+{% endblock %}
2  tests/templates/login.html
View
@@ -14,4 +14,4 @@
<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next }}" />
</form>
-{% endblock %}
+{% endblock %}
2  tests/templates/views/article_archive_month.html
View
@@ -1 +1 @@
-This template intentionally left blank
+This template intentionally left blank
2  tests/templates/views/article_confirm_delete.html
View
@@ -1 +1 @@
-This template intentionally left blank
+This template intentionally left blank
2  tests/templates/views/article_list.html
View
@@ -1 +1 @@
-{{ object_list }}
+{{ object_list }}
2  tests/templates/views/datearticle_archive_month.html
View
@@ -1 +1 @@
-This template intentionally left blank
+This template intentionally left blank
Something went wrong with that request. Please try again.