{"id":715,"date":"2018-10-03T15:22:50","date_gmt":"2018-10-03T14:22:50","guid":{"rendered":"https:\/\/www.thebanners.uk\/standard8\/?p=715"},"modified":"2018-11-25T18:57:07","modified_gmt":"2018-11-25T18:57:07","slug":"whats-next-for-eslint-on-firefox-source-code","status":"publish","type":"post","link":"https:\/\/thebanners.uk\/standard8\/2018\/10\/03\/whats-next-for-eslint-on-firefox-source-code\/","title":{"rendered":"What&#8217;s next for ESLint on Firefox Source Code?"},"content":{"rendered":"<h2>History<\/h2>\n<p>Around 2015 a couple of projects had started using ESLint in mozilla-central. In the last quarter of 2015, there was a big push to enable ESLint for browser\/ and toolkit\/ &#8211; the two main directories containing the javascript source behind Firefox.<\/p>\n<p>Since then, we have come a long way. We have <a href=\"https:\/\/firefox-source-docs.mozilla.org\/tools\/lint\/usage.html#using-the-command-line\">commands<\/a> and <a href=\"https:\/\/firefox-source-docs.mozilla.org\/tools\/lint\/usage.html#using-a-vcs-hook\">hooks<\/a> for developers to use, checks during the <a href=\"https:\/\/static-analysis.moz.tools\/#\/stats\">review phase<\/a>, and <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/QA\/Automated_testing#Linting\">automatic tests<\/a> that run against our review tools and our continuous integration branches. Not only that, but we\u2019ve also expanded our coverage to more directories, and expanded the amount of rules that are enabled.<\/p>\n<p>As we\u2019ve done this work, we\u2019ve caught <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1312716\">lots<\/a> <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1341571\">of<\/a> <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1487246#c2\">bugs<\/a> in the code or in our tests (there\u2019s much more than just those links). Some of those have been small, some have been user facing issues. There are also now the countless potential bugs that we don\u2019t get to see where ESLint catches issues for us before they even hit the core source trees. All this helps to save developer time and leaves more for fixing bugs and implementing new features.<\/p>\n<h2>Where to next?<\/h2>\n<p>There are several things high on the list that we should have as the next, future goals:<\/p>\n<ol>\n<li><strong>Finish enabling ESLint on all our JavaScript code in mozilla-central<\/strong><\/li>\n<\/ol>\n<p>We are already covering the vast majority of production code in mozilla-central, however there are still a lot of unit tests that aren\u2019t covered. Increasing linting coverage here will help to ensure these are functioning as we expect.<\/p>\n<p>There\u2019s always a few things it won\u2019t make sense for, e.g. third-party imports, or the occasional piece of preprocessed code, but I think we should strive towards 100% coverage where we sensibly can.<\/p>\n<ol start=\"2\">\n<li><strong>Harmonize our rules<\/strong><\/li>\n<\/ol>\n<p>Whilst we have a <a href=\"https:\/\/searchfox.org\/mozilla-central\/rev\/bdc89dfd7869e418d788b28eb60ab8d94e708a15\/tools\/lint\/eslint\/eslint-plugin-mozilla\/lib\/configs\/recommended.js\">core set of rules<\/a>, various directories are overriding and extending the rules. We should aim for having the majority of rules being the same everywhere, with additional rules being only occasional (e.g. experimental).<\/p>\n<p>This will make it far easier for developers working across modules to be able to work in a consistent style, and help spread the useful rules across the tree.<\/p>\n<p>Example rules that fall into this category: <a href=\"https:\/\/firefox-source-docs.mozilla.org\/tools\/lint\/linters\/eslint-plugin-mozilla.html#var-only-at-top-level\">mozilla\/var-only-at-top-level<\/a>, <a href=\"https:\/\/eslint.org\/docs\/rules\/block-scoped-var\">block-scoped-var<\/a>, <a href=\"https:\/\/eslint.org\/docs\/rules\/no-shadow\">no-shadow<\/a>, <a href=\"https:\/\/eslint.org\/docs\/rules\/no-throw-literal\">no-throw-literal<\/a>, <a href=\"https:\/\/eslint.org\/docs\/rules\/no-unused-expressions\">no-unused-expressions<\/a>, <a href=\"https:\/\/eslint.org\/docs\/rules\/yoda\">yoda<\/a><\/p>\n<ol start=\"3\">\n<li><strong>Improve developer tools<\/strong><\/li>\n<\/ol>\n<p>For me, I find most use for ESLint when it is <a href=\"https:\/\/eslint.org\/docs\/user-guide\/integrations\">integrated into my editor<\/a>. However, there\u2019s various other occasions where we\u2019re not doing quite enough to make it <a href=\"https:\/\/bugzilla.mozilla.org\/showdependencytree.cgi?id=1427845&amp;hide_resolved=1\">easy for developers<\/a>, e.g. <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1295833\">automatically installing hooks<\/a>, or setting up <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1349000\">editor support automatically<\/a>.<\/p>\n<p>These help developers to catch issues earlier whilst the developer is still focussed on the patch, reducing context switching. We should be getting these working as seamlessly as possible.<\/p>\n<ol start=\"4\">\n<li><strong>Improve automatic fixing<\/strong><\/li>\n<\/ol>\n<p>Currently the automatic fixing doesn\u2019t work fully if you run it across the whole tree (you can run it in segments), we <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1411914\">should fix it<\/a> to help make applying new rules globally a lot easier.<\/p>\n<h2>We need your help!<\/h2>\n<ul>\n<li>Find a problem with ESLint that is stopping you using it efficiently? Please <a href=\"https:\/\/bugzilla.mozilla.org\/enter_bug.cgi?component=Lint%20and%20Formatting&amp;product=Firefox%20Build%20System\">file a bug<\/a>. Alternately, come talk to me about issues that are slowing you down or getting in the way.<\/li>\n<li>Reasonably regularly I file <a href=\"https:\/\/bugzilla.mozilla.org\/buglist.cgi?list_id=14337549&amp;emailtype1=substring&amp;short_desc_type=allwordssubstr&amp;email1=standard8%40mozilla.com&amp;emailbug_mentor1=1&amp;short_desc=eslint&amp;resolution=---&amp;query_format=advanced\">mentored bugs<\/a> for enabling new directories or rules, which are great to get you started. However, if you\u2019re interested in working with me on getting larger chunks going, please let me know (in the comments or ping Standard8 on <a href=\"https:\/\/wiki.mozilla.org\/Irc\">IRC<\/a>).<\/li>\n<li>Anything I&#8217;ve missed or discussions points? Please add a comment.<\/li>\n<\/ul>\n<h2>Thank you<\/h2>\n<p>I\u2019d like to say a big thank you to all those that have helped bring ESLint to where it is today. Special thanks go to Dave Townsend for his encouragement and many reviews.<\/p>\n<p>There\u2019s many more people that have been involved from the various teams that work on Firefox, as well as first-time contributors &#8211; too many to name, so thank you all!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>History Around 2015 a couple of projects had started using ESLint in mozilla-central. In the last quarter of 2015, there was a big push to enable ESLint for browser\/ and toolkit\/ &#8211; the two main directories containing the javascript source behind Firefox. Since then, we have come a long way. We have commands and hooks &hellip; <a href=\"https:\/\/thebanners.uk\/standard8\/2018\/10\/03\/whats-next-for-eslint-on-firefox-source-code\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;What&#8217;s next for ESLint on Firefox Source Code?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,4,6],"tags":[17,18,25,26,31],"class_list":["post-715","post","type-post","status-publish","format-standard","hentry","category-eslint","category-firefox","category-mozilla","tag-eslint","tag-firefox","tag-mozilla-2","tag-productivity","tag-tools"],"_links":{"self":[{"href":"https:\/\/thebanners.uk\/standard8\/wp-json\/wp\/v2\/posts\/715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thebanners.uk\/standard8\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thebanners.uk\/standard8\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thebanners.uk\/standard8\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thebanners.uk\/standard8\/wp-json\/wp\/v2\/comments?post=715"}],"version-history":[{"count":4,"href":"https:\/\/thebanners.uk\/standard8\/wp-json\/wp\/v2\/posts\/715\/revisions"}],"predecessor-version":[{"id":719,"href":"https:\/\/thebanners.uk\/standard8\/wp-json\/wp\/v2\/posts\/715\/revisions\/719"}],"wp:attachment":[{"href":"https:\/\/thebanners.uk\/standard8\/wp-json\/wp\/v2\/media?parent=715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thebanners.uk\/standard8\/wp-json\/wp\/v2\/categories?post=715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thebanners.uk\/standard8\/wp-json\/wp\/v2\/tags?post=715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}