Ͳ͏ͬͯESLintઃఆ͢Δʁ ? How would you like to configure ESLint? (Use arrow keys) Answer questions about your style › Use a popular style guide Inspect your JavaScript file(s) // ͍͔ͭ͘ͷ࣭ʹ͑Δ // ਓؾͷελΠϧΨΠυΛ༻͢Δ // طଘͷJavascriptΛݕࠪ͢Δ
? How would you like to configure ESLint? Use a popular style guide ? Which style guide do you want to follow? (Use arrow keys) › Google Airbnb Standard ͲͷελΠϧʹै͏ʁ
? How would you like to configure ESLint? Use a popular style guide ? Which style guide do you want to follow? Google ? What format do you want your config file to be in? JavaScript › YAML JSON ※ΤσΟλʹΑͬͯಛఆͷܗࣜͰ͔͠ิػೳ͕͑ͳ͔ͬͨΓ͠·͢ɻ IntellijWebStormyamlܗࣜͰิͯ͘͠Ε·ͤΜɻ ઃఆϑΝΠϧͷܗࣜʁ
ྫ͑͜ͷίʔυʹର࣮ͯ͠ߦ var printTime = function() { var date = new Date(); var time = date.getTime(); var unixtime = Math.floor(date.getTime() / 1000) console.log('time: ' + time); console.log("unixtime: " + unixtime) } printTime(); Πϯσϯτἧ͍ͬͯͳ͍ ηϛίϩϯ͕ແ͍ ΫΥςʔγϣϯ͕ἧ͍ͬͯͳ͍
࣮ߦ݁Ռ 1:1 error Unexpected var, use let or const instead no-var 2:3 error Unexpected var, use let or const instead no-var 3:1 error Unexpected var, use let or const instead no-var 4:5 error Unexpected var, use let or const instead no-var 4:53 error Missing semicolon semi 7:17 error Strings must use singlequote quotes 7:41 error Missing semicolon semi 8:2 error Missing semicolon semi ✖ 8 problems (8 errors, 0 warnings) 8 errors, 0 warnings potentially fixable with the `--fix` option. ΠϯσϯτͰΤϥʔ͕ग़͍ͯͳ͍ʂʂ ࣍ʹઆ໌͢ΔϧʔϧͷઃఆͰΧόʔ͠·͢
rulesΛઃఆ $ vi .eslintrc.yml extends: google rules: indent: - error - 2 quotes: - error - double no-var: off w Πϯσϯτ͕εϖʔε̎ͭͰͳ͚ΕΤϥʔ w μϒϧΫΥςʔγϣϯͰͳ͚ΕΤϥʔ w WBSΛ༻ͯ͠ΤϥʔʹͳΒͳ͍
࣮ߦ݁Ռ 3:1 error Expected indentation of 2 spaces but found 0 indent 4:1 error Expected indentation of 2 spaces but found 4 indent 4:53 error Missing semicolon semi 6:1 error Expected indentation of 2 spaces but found 4 indent 6:17 error Strings must use doublequote quotes 7:1 error Expected indentation of 2 spaces but found 4 indent 7:41 error Missing semicolon semi 8:2 error Missing semicolon semi ✖ 8 problems (8 errors, 0 warnings) 8 errors, 0 warnings potentially fixable with the `--fix` option. w Πϯσϯτ͕εϖʔε̎Ͱͳ͍͔ΒΤϥʔ w μϒϧΫΥʔςʔγϣϯ͡Όͳ͍͔ΒΤϥʔ w WBSېࢭͷΤϥʔ͕ඇදࣔʹͳͬͨ
ରͷίʔυʢ࣮ߦલʣ var printTime = function() { var date = new Date(); var time = date.getTime(); var unixtime = Math.floor(date.getTime() / 1000) console.log('time: ' + time); console.log("unixtime: " + unixtime) } printTime(); Πϯσϯτ ηϛίϩϯ ΫΥςʔγϣϯ
ରͷίʔυʢ࣮ߦޙʣ var printTime = function() { var date = new Date(); var time = date.getTime(); var unixtime = Math.floor(date.getTime() / 1000); console.log("time: " + time); console.log("unixtime: " + unixtime); }; printTime(); ࣗಈमਖ਼͞Εͨʂ