Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #17 from sharky3112/issue#12
Browse files Browse the repository at this point in the history
Resolve issue #12: .jshintrc is found all the way up the file tree
  • Loading branch information
Joe Warren committed Mar 12, 2014
2 parents 6687d7c + 65b832a commit a12a597
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This package will run against your currently open file as you type and when you
Included features
===
* Supports jshintConfig in package.json
* Supports custom .jshintrc file in project root
* Supports custom .jshintrc file in project root and all parent directories
* Line number turns red when error on that line
* Once you move your cursor to a line with an error, it will show in the status bar.
* Configure how you want JSHint to run.
Expand Down
23 changes: 15 additions & 8 deletions lib/atom-jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var JSHINT_Worker = null;

var Subscriber = require('emissary').Subscriber;
var fs = require('fs');
var path = require('path');

module.exports = AtomJshint = (function(){
JSHINT_Worker = cp.fork(__dirname + '/worker.js');
Expand Down Expand Up @@ -152,15 +153,21 @@ module.exports = AtomJshint = (function(){
return this.setConfig(packageJson.jshintConfig);
}
}
if( fs.existsSync(atom.project.path + '/.jshintrc') ){
var configFile = fs.readFileSync(atom.project.path + '/.jshintrc','UTF8');
var conf = {};
try {
conf = JSON.parse(configFile);
} catch(e){
console.error('error parsing config file');
var workingPath = atom.project.path || '';
var dirs = workingPath.split(path.sep);
while ( dirs.length >= 1 ) {
var configPath = path.join(dirs.join(path.sep), '/.jshintrc');
if( fs.existsSync(configPath) ){
var configFile = fs.readFileSync(configPath, 'UTF8');
var conf = {};
try {
conf = JSON.parse(configFile);
} catch(e){
console.error('error parsing config file');
}
return this.setConfig(conf);
}
return this.setConfig(conf);
dirs.pop();
}
};

Expand Down

0 comments on commit a12a597

Please sign in to comment.