Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use custom .jshintrc options if they exist

If a custom .jshintrc exists use options defined there
instead of default options.

Look in the following places and if .jshintrc exists
return those options.

env.TM_DIRECTORY
- the directory of the current textmate file

env.TM_PROJECT_DIRECTORY
- the directory of the current text mate project

env.HOME
- users home dir

Otherwise return default options.
  • Loading branch information...
commit 1662e0062ae6ceab0f8b2f898d42eae846c76238 1 parent ad5de0c
@stepheneb stepheneb authored
Showing with 35 additions and 4 deletions.
  1. +35 −4 Support/jshint_options.js
View
39 Support/jshint_options.js
@@ -1,5 +1,8 @@
+var fs = require('fs');
+var env = process.env || process.ENV;
+
module.exports = function() {
- var options = {
+ var default_options = {
"es5": true,
"forin": true,
"predef": [
@@ -14,6 +17,34 @@ module.exports = function() {
"__dirname"
]
};
-
- return options;
-}
+
+ var current_dir = env.TM_DIRECTORY;
+ var project_dir = env.TM_PROJECT_DIRECTORY;
+ var home_dir = env.HOME;
+ var options;
+
+ function readCustomOptions(path) {
+ if (fs.existsSync(path)) {
+ return fs.readFileSync(path, 'utf8');
+ } else {
+ return false;
+ }
+ }
+
+ if (current_dir) {
+ options = readCustomOptions(current_dir + '.jslintrc');
+ if (options) return options;
+ }
+
+ if (project_dir) {
+ options = readCustomOptions(project_dir + '.jslintrc');
+ if (options) return options;
+ }
+
+ if (home_dir) {
+ options = readCustomOptions(home_dir + '.jslintrc');
+ if (options) return options;
+ }
+
+ return default_options;
+};
Please sign in to comment.
Something went wrong with that request. Please try again.