rrdelaney / jadelint

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

linter should walk from file path up to find .jadelintrc #14

Closed ghost closed 9 years ago

ghost commented 9 years ago

per d9d/atom-linter-jade#3, the linter only looks in the current directory for the .jadelintrc file. It should start from the file directory (not cwd) and walk up.

This is also an issue from the command line if calling the linter on a file in a different directory, e.g.:

jadelint src/file.jade

Alternatively, can you fork the config file loading code so that I can easily do something like .setConfig(json|fileName) and not have to duplicate this block of code:

try {
  conf = JSON.parse(fs.readFileSync('.jadelintrc'));
  try {
    for (rule in conf) {
      level = conf[rule];
      rules.rules[rule].prototype.level = level;
    }
  } catch (_error) {}
} catch (_error) {}
ghost commented 9 years ago

And upon fixing this for my linter plugin, I realized that there is a single global rules object. This basically makes it impossible to selectively enable/disable rules in a single process (e.g. without restarting node) without resorting to absurdly ugly hacks like changing rule[name].prototype.level and then resetting it after the linter runs.

rrdelaney commented 9 years ago

jadelint will have support for config objects in version 0.3

dustinblackman commented 9 years ago

:+1:

rrdelaney commented 9 years ago

I just release v0.3. The linter doesn't look up the tree for a .jadelintrc, but you can provide your own config object. I recommend looking at the API documentation. If you need help implementing the linter with the new API, I made a gitter room

ghost commented 9 years ago

Thanks, I don't think this issue should be closed though.

jadelint src/file.jade

doesn't work.

rrdelaney commented 9 years ago

I just tried that locally, and it worked fine.

Can you run npm ls -g jadelint and also tell me what OS you are on?

ghost commented 9 years ago

Okay, sorry -- it now works as long as the .jadelintrc is in the same directory. That's not a very useful setup to me :) I currently have about 30 folders under one views folder in a project. It's not feasible to copy the .jadelintrc to every one

The linter working is a different piece.

rrdelaney commented 9 years ago

I'm working on a linter that will move up the dir tree now

ghost commented 9 years ago

Can I suggest taking a look at eslint and maybe stealing code from it?

It does a very beautiful thing where it merges config files up the tree.

rrdelaney commented 9 years ago

That functionality has been added. I haven't tested it on a windows machine, but it should work fine on a *nix device. Try it in v0.3.2