Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ESLint presentation

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.
Avatar for HeikkiAlanen HeikkiAlanen
September 12, 2014

ESLint presentation

ESLint presentation

Avatar for HeikkiAlanen

HeikkiAlanen

September 12, 2014
Tweet

Other Decks in Programming

Transcript

  1. ESLint  Kehitetty 2013  Staattinen lähdekoodin tarkistus  syntaksi,

    muotoilu, käyttämättömät muuttujat tai funktiot yms.  Kaksi vaihetta  Koodin jäsentäminen  Sääntöjen tarkistaminen  Sääntöjä voi itse muokata ja kehittää  Kategorioita: Errors, Best practices, Variables, Node.js, Stylistic issues, Legacy
  2. Konfigurointi  Jokainen sääntö voidaan määritellä erikseen  Säännöllä kolme

    mahdollista tilaa  Pois päältä (disabled, 0)  Varoitus (warning, 1)  Virhe (Error, 2)  Konfigurointitiedosto helposti muokattavissa tarpeen mukaan
  3. Konfigurointi  eslint.json: … "rules": { "no-alert": 2, "no-array-constructor": 2,

    "no-bitwise": 0, "no-caller": 2, "no-catch-shadow": 2, "no-comma-dangle": 2, "no-cond-assign": 2, "no-console": 2, …
  4. Käyttö Task-3-2.js: var fs = require('fs'); module.exports = function (file)

    { if (fs.existsSync("./" + file)) { var stats = fs.statSync("./" + file); return(stats.mtime); } return(false); };
  5. Käyttö  $ eslint task-3-2.js task-3-2.js 5:40 error Trailing spaces

    not allowed no-trailing-spaces 1:9 error 'require' is not defined no-undef 3:0 error 'module' is not defined no-undef 9:1 error Newline required at end of file but not found eol-last 1:17 error Strings must use doublequote quotes 6:2 error Keyword "return" must be followed by whitespace space-return-throw-case 8:1 error Keyword "return" must be followed by whitespace space-return-throw-case ✖ 7 problems