Alright, it is time for some developer stuff again! 🤓 Ever heard of "**Linting**"? It´s basically checking out your code for potential errors. As always in the JavaScript world, there are a lot of different tools to choose from and they can do the Linting **on the fly while you type your code**: The most famouse ones probably are "**JSLint**", followed by "**JSHint**" (a fork of JSLint, less opinionated and with more options) and then "**ESLint**". Forget about JSLint and JSHint, ESLint is all you need, because it is highly modifiable and it´s the only Linter that supports plugins. Which is great if you want to use **React** (like all smart people), because there is [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react).  ## Setup If you just want to use ESLint in all your projects (and i highly recommend that!), just install all the necessary tools globally with npm: * `npm install -g eslint` * `npm install -g eslint-plugin-react` * `npm install -g babel-eslint` You can also just combine them, of course: * `npm install -g eslint eslint-plugin-react babel-eslint` This will install ESLint, the ESLint React Plugin and a special parser that understands experimental/new JavaScript features. If you don´t know what **Babel** is: It turns new JavaScript code into older one for older browsers not supporting all the fancy features. ## Example .eslintrc We´re all set up with the tools we need, there is only one thing left to do: Place a **.eslintrc** file in the root folder of all your projects. It tells ESLint which parser and plugins to use, and which rules to apply to your code. Here is an example how that file could look like: ```JSON { //choose babel parser instead of default one "parser": "babel-eslint", //activate react plugin "plugins": [ "react" ], //set default/recommended rules as basis "extends": ["eslint:recommended", "plugin:react/recommended"], //additional parser options: https://eslint.org/docs/user-guide/configuring "parserOptions": { "ecmaVersion": 8, "sourceType": "module", "ecmaFeatures": { "jsx": true, "experimentalObjectRestSpread": true } }, //this sets some predefined global vars depending on the environment "env": { "browser": true, "node": true, "es6": true }, //set global vars "globals": { "Phaser": false, "Steemit": true //true means that you are allowed to override it }, //http://eslint.org/docs/rules/ //0 - off, 1 - warn, 2 - error "rules": { "quotes": [2, "single"], "indent": [2, "tab", {"SwitchCase": 1}], "max-statements": [1, 20], "max-depth": [1, 3], "complexity": [1, 10], "no-unused-vars": [1, {"varsIgnorePattern": "styles|React"}], "no-console": 2, "semi": 2, "no-empty": 1, "react/prop-types": 1, "react/no-array-index-key": 1, "jsx-quotes": [2, "prefer-double"], "no-multiple-empty-lines": [2, {"max": 1, "maxEOF": 1}], "no-var": 2 } } ``` Check out the docs for additional information about a specific rule or feel free to ask me about the existing ones in the file! You are probably using some editor/IDE like **Atom** or **Webstorm** already/hopefully. In Webstorm you can just activate ESLint in the settings, in Atom there is a plugin for it. They all take the .eslintrc file from the root folder. Are you using ESLint (or something else) already? What´s your configuration and why?
author | luschn |
---|---|
permlink | eslint-and-the-beauty-of-javascript-linting |
category | development |
json_metadata | {"tags":["development","javascript","dev"],"image":["https://steemitimages.com/DQmYrpGZqdTS1JotjpoYx39BEbZt1WivdWcymkcRtjmNNVC/032f30a0-f2e1-11e5-8676-4676c2ca102a.png"],"links":["https://www.npmjs.com/package/eslint-plugin-react"],"app":"steemit/0.1","format":"markdown"} |
created | 2018-05-01 21:51:51 |
last_update | 2018-05-03 13:50:57 |
depth | 0 |
children | 3 |
last_payout | 2018-05-08 21:51:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 121.825 HBD |
curator_payout_value | 39.724 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 3,753 |
author_reputation | 19,362,064,963,957 |
root_title | "ESLint and the beauty of JavaScript Linting" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 53,317,388 |
net_rshares | 28,249,278,084,923 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
freeyourmind | 0 | 1,715,825,244,935 | 100% | ||
corina | 0 | 24,204,318,598 | 100% | ||
snowflake | 0 | 1,755,771,542,420 | 100% | ||
sticker | 0 | 26,433,014,550 | 100% | ||
xaero1 | 0 | 3,528,232,393,951 | 26% | ||
someonewhoisme | 0 | 302,550,288,895 | 17% | ||
shafay | 0 | 21,470,673,768 | 100% | ||
driptorchpress | 0 | 17,353,375,722 | 100% | ||
motoengineer | 0 | 886,635,273,251 | 100% | ||
inceptionally | 0 | 703,879,839,156 | 71% | ||
davidding | 0 | 8,318,810,440,899 | 100% | ||
champagnecrypto | 0 | 126,557,571,562 | 100% | ||
luna33 | 0 | 100,841,320,513 | 100% | ||
schlees | 0 | 27,493,621,430 | 25% | ||
lamex | 0 | 79,533,952,473 | 100% | ||
hentikage | 0 | 18,448,030,079 | 100% | ||
asena | 0 | 20,566,481,997 | 100% | ||
bikergirl | 0 | 18,034,826,198 | 100% | ||
yoonwonlim | 0 | 772,965,084,362 | 100% | ||
marty-art | 0 | 19,588,435,757 | 100% | ||
pearica | 0 | 19,919,284,580 | 100% | ||
limnade | 0 | 24,451,483,900 | 100% | ||
indurkin | 0 | 91,963,151,072 | 100% | ||
dreamer.golos | 0 | 17,109,107,581 | 100% | ||
doughtaker | 0 | 16,880,816,295 | 50% | ||
simonpeter35 | 0 | 153,112,493,008 | 100% | ||
minnowbooster | 0 | 6,154,744,508,070 | 10% | ||
uzgo | 0 | 386,705,626,273 | 39% | ||
investingpennies | 0 | 22,532,093,050 | 82% | ||
stevenmosoes | 0 | 17,453,170,861 | 100% | ||
goals | 0 | 20,967,801,867 | 100% | ||
khammar | 0 | 21,195,045,291 | 100% | ||
onur1s | 0 | 19,021,378,230 | 100% | ||
palani | 0 | 21,076,334,707 | 100% | ||
cannonwar | 0 | 28,650,003,117 | 39% | ||
ajulu | 0 | 32,998,068,693 | 100% | ||
asihelp | 0 | 18,839,613,231 | 100% | ||
sailingtohappy | 0 | 113,062,552,919 | 100% | ||
beauknows | 0 | 26,014,168,913 | 100% | ||
singhrajat | 0 | 21,278,280,684 | 100% | ||
bahadirk | 0 | 22,026,735,550 | 100% | ||
nokodemion | 0 | 175,204,558,948 | 100% | ||
sonny.dharmawan | 0 | 75,860,364,309 | 100% | ||
taug | 0 | 2,731,557,521 | 100% | ||
fiducia | 0 | 80,993,844,926 | 100% | ||
bestbroplayer | 0 | 45,400,832,541 | 100% | ||
duartenunes | 0 | 32,523,391,664 | 100% | ||
ikrahch | 0 | 462,597,994,229 | 100% | ||
chronocrypto | 0 | 578,511,121,491 | 100% | ||
iqbal15 | 0 | 22,944,760,134 | 100% | ||
techchat | 0 | 75,558,104,207 | 100% | ||
limesoda | 0 | 177,183,253,637 | 100% | ||
cryptoburner | 0 | 518,211,682,049 | 100% | ||
christopherxc | 0 | 587,154,760 | 100% | ||
nissla | 0 | 18,140,331,183 | 100% | ||
maybelater | 0 | 602,511,508 | 100% | ||
annikafried | 0 | 17,071,951,512 | 100% | ||
berndpfeiffer | 0 | 20,886,359,306 | 100% | ||
highmech | 0 | 7,361,442,278 | 100% | ||
njoy.thejourney | 0 | 3,337,911,203 | 100% | ||
machnbirdsparo | 0 | 42,600,937,042 | 100% | ||
mahsumakbas | 0 | 16,391,836,937 | 100% | ||
chaimyu | 0 | 26,887,674,005 | 100% | ||
vaquita | 0 | 83,401,129,105 | 100% | ||
mrshev | 0 | 18,963,301,238 | 100% | ||
grammarnazi | 0 | 50,767,364 | 50% | ||
patternbot | 0 | 1,905,308,032 | 100% | ||
lipraproductions | 0 | 1,431,994,102 | 100% | ||
techupdate | 0 | 6,126,966,990 | 100% | ||
retroboy | 0 | 611,594,294 | 100% |
You have a minor misspelling in the following sentence: <blockquote>), just install all the neccessary tools globally with npm:.</blockquote> It should be <i>necessary</i> instead of <i>neccessary</i>.
author | grammarnazi |
---|---|
permlink | re-luschn-eslint-and-the-beauty-of-javascript-linting-20180501t215156586z |
category | development |
json_metadata | {"app":"steemit"} |
created | 2018-05-01 21:51:54 |
last_update | 2018-05-01 21:51:54 |
depth | 1 |
children | 1 |
last_payout | 2018-05-08 21:51:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.020 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 201 |
author_reputation | -144,064,903,190 |
root_title | "ESLint and the beauty of JavaScript Linting" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 53,317,398 |
net_rshares | 4,329,561,226 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
luschn | 0 | 4,329,561,226 | 100% |
oops, corrected :)
author | luschn |
---|---|
permlink | re-grammarnazi-re-luschn-eslint-and-the-beauty-of-javascript-linting-20180501t215334106z |
category | development |
json_metadata | {"tags":["development"],"app":"steemit/0.1"} |
created | 2018-05-01 21:53:33 |
last_update | 2018-05-01 21:53:33 |
depth | 2 |
children | 0 |
last_payout | 2018-05-08 21:53:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 18 |
author_reputation | 19,362,064,963,957 |
root_title | "ESLint and the beauty of JavaScript Linting" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 53,317,645 |
net_rshares | 0 |
Good writing! I think you have very good potential here. Check out [my post](https://steemit.com/introduceyourself/@itsadel/reintroducing-myself-plans-getting-ready-for-a-summer-of-photography) as well
author | steem881 |
---|---|
permlink | re-eslint-and-the-beauty-of-javascript-linting-20180503t151805 |
category | development |
json_metadata | "" |
created | 2018-05-03 15:18:06 |
last_update | 2018-05-03 15:18:06 |
depth | 1 |
children | 0 |
last_payout | 2018-05-10 15:18:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 201 |
author_reputation | -796,876,938,732 |
root_title | "ESLint and the beauty of JavaScript Linting" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 53,660,452 |
net_rshares | 0 |