{"id":7087,"date":"2019-05-22T20:05:15","date_gmt":"2019-05-22T20:05:15","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=7087"},"modified":"2019-05-22T20:05:15","modified_gmt":"2019-05-22T20:05:15","slug":"using-eslint-on-typescript-files","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/using-eslint-on-typescript-files\/","title":{"rendered":"Using ESLint on TypeScript files"},"content":{"rendered":"<p>Assuming you already have a project set-up. If you don&#8217;t have typescript within your node modules, add it using<\/p>\n<ul>\n<li>yarn add typescript<\/li>\n<\/ul>\n<p>Next up we&#8217;ll add eslint and it&#8217;s typescript plugins (to the dev dependencies)<\/p>\n<ul>\n<li>yarn add &#8211;dev eslint<\/li>\n<li>yarn add &#8211;dev @typescript-eslint\/parser<\/li>\n<li>yarn add &#8211;dev @typescript-eslint\/eslint-plugin<\/li>\n<\/ul>\n<p>ESList uses a configuration file in the shape of a .eslintrc.js file which should be placed in root folder of your project. Below is a sample<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nmodule.exports = {\r\n    &quot;parser&quot;: '@typescript-eslint\/parser',\r\n    &quot;plugins&quot;: &#x5B;'@typescript-eslint'],\r\n    &quot;extends&quot;: &#x5B;'plugin:@typescript-eslint\/recommended'],\r\n    &quot;rules&quot;: {\r\n        &quot;@typescript-eslint\/no-parameter-properties&quot;: &quot;off&quot;,\r\n        &quot;@typescript-eslint\/no-explicit-any&quot;: &quot;off&quot;\r\n    },\r\n};\r\n<\/pre>\n<p>In the above we&#8217;ve turned off a couple of rules (the rule name will be listed alongside output from eslint when it&#8217;s run). <\/p>\n<p>Now, to run eslint we use the following command<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n.\\node_modules\\.bin\\eslint .\/src\/*.ts\r\n<\/pre>\n<p><strong>References<\/strong><\/p>\n<p><a href=\"https:\/\/eslint.org\/docs\/rules\/\" rel=\"noopener noreferrer\" target=\"_blank\">ESLint Rules<\/a><br \/>\n<a href=\"https:\/\/github.com\/typescript-eslint\/typescript-eslint\/tree\/master\/packages\/eslint-plugin\" rel=\"noopener noreferrer\" target=\"_blank\">ESLint Plugin<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Assuming you already have a project set-up. If you don&#8217;t have typescript within your node modules, add it using yarn add typescript Next up we&#8217;ll add eslint and it&#8217;s typescript plugins (to the dev dependencies) yarn add &#8211;dev eslint yarn add &#8211;dev @typescript-eslint\/parser yarn add &#8211;dev @typescript-eslint\/eslint-plugin ESList uses a configuration file in the shape [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[248,46],"tags":[],"class_list":["post-7087","post","type-post","status-publish","format-standard","hentry","category-lint","category-typescript"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=7087"}],"version-history":[{"count":5,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7087\/revisions"}],"predecessor-version":[{"id":7103,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7087\/revisions\/7103"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=7087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=7087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=7087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}