Skip to content

Commit

Permalink
Merge pull request #1012 from AnalyticalGraphicsInc/updateJSHintOptions
Browse files Browse the repository at this point in the history
Convert JSHint settings to a .jshintrc file.
  • Loading branch information
mramato committed Aug 5, 2013
2 parents 8ced966 + a7b773b commit fa2cccb
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 28 deletions.
45 changes: 45 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"bitwise": false,
"camelcase": false,
"curly": true,
"eqeqeq": true,
"es3": true,
"forin": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"noempty": false,
"nonew": true,
"plusplus": false,
"quotmark": false,
"regexp": false,
"undef": true,
"unused": false,
"strict": true,
"trailing": true,
"asi": false,
"boss": false,
"debug": false,
"eqnull": false,
"esnext": false,
"evil": false,
"expr": false,
"funcscope": false,
"globalstrict": false,
"iterator": false,
"lastsemic": false,
"laxbreak": false,
"laxcomma": false,
"loopfunc": false,
"moz": false,
"multistr": true,
"proto": false,
"regexdash": false,
"scripturl": false,
"smarttabs": false,
"shadow": false,
"sub": false,
"supernew": false,
"browser": true
}
1 change: 0 additions & 1 deletion .settings/com.eclipsesource.jshint.ui.prefs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
eclipse.preferences.version=1
excluded=Apps/Sandcastle/ThirdParty//*\:Source/ThirdParty//*\:Source/Workers/cesiumWorkerBootstrapper.js\:ThirdParty//*\:Tools/build.js
included=//*.js
options=bitwise \: false,\r\ncamelcase \: false,\r\ncurly \: true,\r\neqeqeq \: true,\r\nes3 \: true,\r\nforin \: true,\r\nimmed \: true,\r\nlatedef \: true,\r\nnewcap \: true,\r\nnoarg \: true,\r\nnoempty \: false,\r\nnonew \: true,\r\nplusplus \: false,\r\nquotmark \: false,\r\nregexp \: false,\r\nundef \: true,\r\nunused \: false,\r\nstrict \: true,\r\ntrailing \: true,\r\nasi \: false,\r\nboss \: false,\r\ndebug \: false,\r\neqnull \: false,\r\nesnext \: false,\r\nevil \: false,\r\nexpr \: false,\r\nfuncscope \: false,\r\nglobalstrict \: false,\r\niterator \: false,\r\nlastsemic \: false,\r\nlaxbreak \: false,\r\nlaxcomma \: false,\r\nloopfunc \: false,\r\nmoz \: false,\r\nmultistr \: true,\r\nproto \: false,\r\nregexdash \: false,\r\nscripturl \: false,\r\nsmarttabs \: false,\r\nshadow \: false,\r\nsub \: false,\r\nsupernew \: false,\r\nbrowser \: true
projectSpecificOptions=true
10 changes: 2 additions & 8 deletions Tools/buildTasks/createSandcastleJsHintOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ importClass(Packages.org.mozilla.javascript.tools.shell.Main); /*global Main*/
Main.exec(['-e', '{}']);
var load = Main.global.load;

load(project.getProperty('tasksDirectory') + '/shared.js'); /*global forEachFile,readFileContents,writeFileContents,File,FileReader,FileWriter,FileUtils*/
load(project.getProperty('tasksDirectory') + '/shared.js'); /*global forEachFile,readFileContents,writeFileContents,loadJsHintOptionsFile,File,FileReader,FileWriter,FileUtils*/

function loadJsHintOptions() {
"use strict";
/*jshint evil:true*/
return eval('({' + attributes.get('jshintoptions') + '})');
}

var jsHintOptions = loadJsHintOptions();
var jsHintOptions = loadJsHintOptionsFile(attributes.get('jshintoptionspath'));

jsHintOptions.predef = ['require', 'console', 'Sandcastle', 'Cesium'];

Expand Down
16 changes: 4 additions & 12 deletions Tools/buildTasks/runJsHint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,16 @@ importClass(Packages.org.mozilla.javascript.tools.shell.Main); /*global Main*/
Main.exec(['-e', '{}']);
var load = Main.global.load;

load(project.getProperty('tasksDirectory') + '/shared.js'); /*global forEachFile,readFileContents,writeFileContents,File,FileReader,FileWriter,FileUtils*/
load(project.getProperty('tasksDirectory') + '/shared.js'); /*global forEachFile,readFileContents,writeFileContents,loadJsHintOptionsFile,File,FileReader,FileWriter,FileUtils*/

/*global window:true*/
var window = window || {};

var jsHintPath = attributes.get('jshintpath');
load(jsHintPath); /*global JSHINT*/
load(attributes.get('jshintpath')); /*global JSHINT*/

function loadJsHintOptions() {
"use strict";
/*jshint evil:true*/
return eval('({' + attributes.get('jshintoptions') + '})');
}

var jsHintOptions = loadJsHintOptions();
var jsHintOptions = loadJsHintOptionsFile(attributes.get('jshintoptionspath'));

var sandcastleJsHintOptionsPath = attributes.get('sandcastlejshintoptionspath');
load(sandcastleJsHintOptionsPath);/*global sandcastleJsHintOptions*/
load(attributes.get('sandcastlejshintoptionspath')); /*global sandcastleJsHintOptions*/

var errors = [];

Expand Down
8 changes: 7 additions & 1 deletion Tools/buildTasks/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ function writeFileContents(filename, contents, writeIfUnchanged) {
writer.write(contents);
writer.close();
}
}
}

function loadJsHintOptionsFile(path) {
"use strict";
/*jshint evil:true*/
return eval('(' + readFileContents(path) + ')');
}
11 changes: 5 additions & 6 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<demos dir="${galleryDirectory}" includes="**/*.html" />
</createGalleryList>

<createSandcastleJsHintOptions output="${sandcastleDirectory}/jsHintOptions.js" jshintoptions="${jsHintEclipseSettings.options}" />
<createSandcastleJsHintOptions output="${sandcastleDirectory}/jsHintOptions.js" jshintoptionspath="${jsHintOptionsPath}" />
</target>

<target name="combine" depends="build,combineJavaScript" description="Combines all source files into a single stand-alone script.">
Expand Down Expand Up @@ -128,6 +128,7 @@
<property name="jsdoc3Directory" location="${toolsDirectory}/jsdoc3" />
<property name="webProxyDirectory" location="${toolsDirectory}/proxy" />
<property name="jsHintPath" location="${thirdPartyDirectory}/jshint-2.1.2/jshint-2.1.2.js" />
<property name="jsHintOptionsPath" location=".jshintrc" />

<!-- properties controlling documentation source-->
<property name="githubRepoLink" value="https://github.com/AnalyticalGraphicsInc/cesium/" />
Expand Down Expand Up @@ -184,21 +185,19 @@

<scriptdef name="createSandcastleJsHintOptions" language="javascript" src="${tasksDirectory}/createSandcastleJsHintOptions.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
<attribute name="output" />
<attribute name="jshintoptions" />
<attribute name="jshintoptionspath" />
</scriptdef>

<scriptdef name="runJsHint" language="javascript" src="${tasksDirectory}/runJsHint.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">
<attribute name="jshintpath" />
<attribute name="jshintoptions" />
<attribute name="jshintoptionspath" />
<attribute name="sandcastlejshintoptionspath" />
<attribute name="failureproperty" />
<element name="sourcefiles" type="fileset" />
</scriptdef>

<property file="${basedir}/.settings/com.eclipsesource.jshint.ui.prefs" prefix="jsHintEclipseSettings" />

<target name="jsHint" depends="build" description="Runs JSHint on the entire source tree.">
<runJsHint jshintpath="${jsHintPath}" jshintoptions="${jsHintEclipseSettings.options}" sandcastlejshintoptionspath="${sandcastleDirectory}/jsHintOptions.js" failureproperty="jsHint.failure">
<runJsHint jshintpath="${jsHintPath}" jshintoptionspath="${jsHintOptionsPath}" sandcastlejshintoptionspath="${sandcastleDirectory}/jsHintOptions.js" failureproperty="jsHint.failure">
<sourcefiles dir="${basedir}">
<include name="Source/**/*.js" />
<exclude name="Source/Shaders/**" />
Expand Down

0 comments on commit fa2cccb

Please sign in to comment.