rrdelaney / jadelint

:dragon: A linter for the Jade templating language
https://rrdelaney.github.io/jadelint
MIT License
6 stars 1 forks source link

Add support for linting directories #3

Closed pdehaan closed 9 years ago

pdehaan commented 9 years ago

I tried running jadelint@0.2.3 against my views/ directory and got the following error:

➜  idea-town git:(master) ✗ jadelint views

fs.js:488
  var r = binding.read(fd, buffer, offset, length, position);
                  ^
Error: EISDIR, illegal operation on a directory
    at Object.fs.readSync (fs.js:488:19)
    at Object.fs.readFileSync (fs.js:322:28)
    at module.exports.jadelint (/Users/pdehaan/.npm-packages/lib/node_modules/jadelint/target/jadelint.js:27:19)
    at Object.<anonymous> (/Users/pdehaan/.npm-packages/lib/node_modules/jadelint/bin/jadelint:3:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)

Not sure if you need to add a couple more checks to src/jadelint.coffee to see if the filename is a file or directory before trying to call fs.readFileSync().

Workaround:

➜  idea-town git:(master) ✗ jadelint views/*.jade

views/layout.jade
  ✖  line 1  Only HTML doctypes are allowed

✖  1 warning
rrdelaney commented 9 years ago

Added and published

pdehaan commented 9 years ago

Nice! Left a comment https://github.com/rrdelaney/jadelint/commit/1aac5455e38c89e58dd7aa9f76bac591943981c0#commitcomment-12596787 (re: path.join())

Here's my current output (which shows the double "//" in the path since I tried linting views/):

➜  idea-town git:(master) ✗ npm run jadelint

> idea-town@0.0.1 jadelint /Users/pdehaan/dev/github/idea-town
> jadelint views/

views//includes/header.jade
  ✖  line 2  Only use UTF-8 as charset

views//layout.jade
  ✖  line 1  Only HTML doctypes are allowed

✖  2 warnings
rrdelaney commented 9 years ago

I added your fix