diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000000..223eda1d0c9 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,26 @@ +{ + "env": { + "browser": true, + "es6": true, + "mocha": true, + "jasmine": true + }, + "plugins": [ + "html" + ], + "rules": { + "curly": ["error"], + "eqeqeq": ["error"], + "guard-for-in": ["error"], + "new-cap": ["error", {"properties": false}], + "no-caller": ["error"], + "no-empty": ["error"], + "no-extend-native": ["error"], + "no-irregular-whitespace": ["error"], + "no-new": ["error"], + "no-undef": ["error"], + "no-unused-vars": ["error", {"vars": "all", "args": "none"}], + "strict": ["error"], + "wrap-iife": ["error", "any"] + } +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 9d360ee6532..00000000000 --- a/.jshintrc +++ /dev/null @@ -1,62 +0,0 @@ -{ - "bitwise": false, - "camelcase": false, - "curly": true, - "eqeqeq": true, - "forin": true, - "freeze": true, - "immed": true, - "latedef": false, - "newcap": true, - "noarg": true, - "noempty": true, - "nonbsp": true, - "nonew": true, - "plusplus": false, - "quotmark": false, - "undef": true, - "unused": "vars", - "strict": true, - "asi": false, - "boss": false, - "debug": false, - "eqnull": false, - "esnext": false, - "moz": false, - "evil": false, - "expr": false, - "funcscope": false, - "globalstrict": false, - "iterator": false, - "lastsemic": false, - "laxbreak": false, - "laxcomma": false, - "loopfunc": false, - "multistr": true, - "noyield": false, - "notypeof": false, - "proto": false, - "scripturl": false, - "shadow": false, - "sub": false, - "supernew": false, - "validthis": false, - "browser": true, - "browserify": false, - "couch": false, - "devel": true, - "dojo": false, - "jasmine": true, - "jquery": false, - "mocha": true, - "mootools": false, - "node": false, - "nonstandard": false, - "prototypejs": false, - "qunit": false, - "rhino": false, - "shelljs": false, - "worker": false, - "wsh": false, - "yui": false -} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 1d33074b1e5..4ff7b4d829b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,9 +11,9 @@ script: - npm run deploy-status -- --status pending --message 'Waiting for build' - echo -en 'travis_fold:end:script.deployPending\\r' - - echo 'jsHint' && echo -en 'travis_fold:start:script.jsHint\\r' - - npm run jsHint -- --failTaskOnError - - echo -en 'travis_fold:end:script.jsHint\\r' + - echo 'eslint' && echo -en 'travis_fold:start:script.eslint\\r' + - npm run eslint -- --failTaskOnError + - echo -en 'travis_fold:end:script.eslint\\r' - echo 'test webgl-stub' && echo -en 'travis_fold:start:script.test\\r' - npm run test -- --browsers Electron --webgl-stub --failTaskOnError --suppressPassed diff --git a/Apps/.eslintrc b/Apps/.eslintrc new file mode 100644 index 00000000000..e9371560110 --- /dev/null +++ b/Apps/.eslintrc @@ -0,0 +1,6 @@ +{ + "extends": "../.eslintrc", + "env": { + "jasmine": false + } +} diff --git a/Apps/.jshintrc b/Apps/.jshintrc index 24762c7dc74..ad12e9a7e03 100644 --- a/Apps/.jshintrc +++ b/Apps/.jshintrc @@ -1,4 +1,62 @@ { - "extends": "../.jshintrc", - "jasmine": false + "bitwise": false, + "camelcase": false, + "curly": true, + "eqeqeq": true, + "forin": true, + "freeze": true, + "immed": true, + "latedef": false, + "newcap": true, + "noarg": true, + "noempty": true, + "nonbsp": true, + "nonew": true, + "plusplus": false, + "quotmark": false, + "undef": true, + "unused": "vars", + "strict": true, + "asi": false, + "boss": false, + "debug": false, + "eqnull": false, + "esnext": false, + "moz": false, + "evil": false, + "expr": false, + "funcscope": false, + "globalstrict": false, + "iterator": false, + "lastsemic": false, + "laxbreak": false, + "laxcomma": false, + "loopfunc": false, + "multistr": true, + "noyield": false, + "notypeof": false, + "proto": false, + "scripturl": false, + "shadow": false, + "sub": false, + "supernew": false, + "validthis": false, + "browser": true, + "browserify": false, + "couch": false, + "devel": true, + "dojo": false, + "jasmine": false, + "jquery": false, + "mocha": true, + "mootools": false, + "node": false, + "nonstandard": false, + "prototypejs": false, + "qunit": false, + "rhino": false, + "shelljs": false, + "worker": false, + "wsh": false, + "yui": false } diff --git a/Apps/CesiumViewer/CesiumViewerStartup.js b/Apps/CesiumViewer/CesiumViewerStartup.js index 0860c9af7df..f387d66ce37 100644 --- a/Apps/CesiumViewer/CesiumViewerStartup.js +++ b/Apps/CesiumViewer/CesiumViewerStartup.js @@ -1,4 +1,5 @@ /*global require*/ +/*eslint-disable strict*/ require({ baseUrl : '.', paths : { diff --git a/Apps/Sandcastle/.eslintrc b/Apps/Sandcastle/.eslintrc new file mode 100644 index 00000000000..2fb0cba37fb --- /dev/null +++ b/Apps/Sandcastle/.eslintrc @@ -0,0 +1,13 @@ +{ + "extends": "../../.eslintrc", + "globals": { + "JSON": true, + "require": true, + "console": true, + "Sandcastle": true, + "Cesium": true + }, + "rules": { + "no-unused-vars": ["off"] + } +} diff --git a/Apps/Sandcastle/CesiumSandcastle.js b/Apps/Sandcastle/CesiumSandcastle.js index e4fc6c538f7..7bf3a2a6423 100644 --- a/Apps/Sandcastle/CesiumSandcastle.js +++ b/Apps/Sandcastle/CesiumSandcastle.js @@ -367,6 +367,7 @@ require({ } // make a copy of the options, JSHint modifies the object it's given var options = JSON.parse(JSON.stringify(sandcastleJsHintOptions)); + /*eslint-disable new-cap*/ if (!JSHINT(getScriptFromEditor(false), options)) { var hints = JSHINT.errors; for (i = 0, len = hints.length; i < len; ++i) { @@ -377,7 +378,7 @@ require({ errorLines.push(line); } } - } + }/*eslint-enable new-cap*/ } function scheduleHint() { diff --git a/Apps/Sandcastle/Sandcastle-client.js b/Apps/Sandcastle/Sandcastle-client.js index 0cee2b145c7..97560508fe5 100644 --- a/Apps/Sandcastle/Sandcastle-client.js +++ b/Apps/Sandcastle/Sandcastle-client.js @@ -64,8 +64,8 @@ if (lineEnd1 > lineStart) { try { lineNumber = parseInt(stack.substring(lineStart + 1, lineEnd1), 10); - } catch (ex) { - } + } catch (ex) {/*eslint-disable no-empty*/ + }/*eslint-enable no-empty*/ } } } @@ -100,8 +100,8 @@ pos += 12; lineNumber = parseInt(errorMsg.substring(pos), 10); } - } catch (ex) { - } + } catch (ex) {/*eslint-disable no-empty*/ + }/*eslint-enable no-empty*/ } window.parent.postMessage({ 'error' : errorMsg, @@ -145,8 +145,8 @@ 'lineNumber' : lineNumber }); } - } catch (ex) { - } + } catch (ex) {/*eslint-disable no-empty*/ + }/*eslint-enable no-empty*/ }; Sandcastle.highlight = function(obj) { diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 185d020b070..17c1e1d5d30 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,7 +52,7 @@ We love pull requests. We strive to promptly review them, provide feedback, and Before we can merge a pull request, we require a signed Contributor License Agreement. There is a CLA for: -* [individuals](Documentation/Contributors/CLAs/individual-cla-agi-v1.0.txt) and +* [individuals](Documentation/Contributors/CLAs/individual-cla-agi-v1.0.txt) and * [corporations](Documentation/Contributors/CLAs/corporate-cla-agi-v1.0.txt). This only needs to be completed once. The CLA ensures you retain copyright to your contributions, and we have the right to use them and incorporate them into Cesium using the [Apache 2.0 License](LICENSE.md). @@ -72,7 +72,7 @@ Our code is our lifeblood so maintaining Cesium's high code quality is important * Once you are done making new commits to address feedback, add a comment to the pull request such as `"this is ready"` since GitHub doesn't notify us about commits. * Code and tests * Follow the [Coding Guide](Documentation/Contributors/CodingGuide/README.md). - * Verify your code passes [JSHint](http://www.jshint.com/). Run JSHint for all of Cesium with `npm run jsHint` or automatically run JSHint when files are saved with `npm run jsHint-watch`. See the [Build Guide](Documentation/Contributors/BuildGuide/README.md). + * Verify your code passes [ESLint](http://www.eslint.org/). Run ESLint for all of Cesium with `npm run eslint` or automatically run ESLint when files are saved with `npm run eslint-watch`. See the [Build Guide](Documentation/Contributors/BuildGuide/README.md). * Verify that all tests pass, and write new tests with excellent code coverage for new code. Follow the [Testing Guide](Documentation/Contributors/TestingGuide/README.md). * If you added new identifiers to the Cesium API: * Update [CHANGES.md](CHANGES.md). diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 19eeef970de..63a278af5f7 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -138,3 +138,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Heiko Thiel](https://github.com/SunBlack) * [Sravan Kumar Kilaru](https://github.com/kilarusravankumar) * [Ryan King](https://github.com/ryki2658) +* [Jason Wohlgemuth](https://github.com/jhwohlgemuth) diff --git a/Documentation/Contributors/BuildGuide/README.md b/Documentation/Contributors/BuildGuide/README.md index 2a19759ac5b..721ce500ba1 100644 --- a/Documentation/Contributors/BuildGuide/README.md +++ b/Documentation/Contributors/BuildGuide/README.md @@ -45,7 +45,7 @@ Cesium ships with a simple HTTP server for testing, run `npm start` after buildi ``` npm start -``` +``` Then browse to [http://localhost:8080/](http://localhost:8080/). The landing page includes apps and tools commonly used during development, including: @@ -56,7 +56,7 @@ Then browse to [http://localhost:8080/](http://localhost:8080/). The landing pag Cesium can be used in two different ways. Cesium can be either a set of modules using [Asynchronous Module Definition (AMD)](https://github.com/amdjs/amdjs-api/wiki/AMD), or it can be built as one combined file containing all modules. The basics: -* `npm run build` will build AMD Cesium. This also builds Cesium Viewer and Sandcastle. +* `npm run build` will build AMD Cesium. This also builds Cesium Viewer and Sandcastle. * `npm run minifyRelease` creates the built version of Cesium. This also builds Hello World. Read the complete list of build scripts below for more details. @@ -92,7 +92,7 @@ Here's the full set of scripts and what they do. * **Build scripts** -- build and package the source code and documentation * `build` - A fast, developer-oriented build that prepares the source tree for use as standard [Asynchronous Module Definition (AMD)](https://github.com/amdjs/amdjs-api/wiki/AMD) modules, suitable for running tests and most examples (some Sandcastle examples require running `combine`). Run this when a GLSL shader is changed since the .glsl file is converted to a .js file with a string for the GLSL source. This runs automatically when saving files in Eclipse. - * `build-watch` - A never-ending task that watches your file system for changes to Cesium and runs `build` on the source code as needed. + * `build-watch` - A never-ending task that watches your file system for changes to Cesium and runs `build` on the source code as needed. * `combine` - Runs `build`, plus the [the RequireJS optimizer](http://requirejs.org/docs/optimization.html) to combine Cesium and [the Almond AMD loader](http://requirejs.org/docs/faq-optimization.html#wrap) to produce all-in-one files in the `Build/Cesium` directory that exposes the entire Cesium API attached to a single global `Cesium` object. This version is useful if you don't want to use the modules directly with a standard AMD loader. * `minify` - Runs `combine`, plus [minifies](http://en.wikipedia.org/wiki/Minification_\(programming\)) Cesium.js using [UglifyJS2](https://github.com/mishoo/UglifyJS2) for a smaller deployable file. * `combineRelease` - Runs `combine`, plus uses the optimizer to remove debugging code that validates function input and throws DeveloperErrors. The removed sections are marked with `//>>includeStart('debug', pragmas.debug);` blocks in the code. @@ -104,8 +104,8 @@ Here's the full set of scripts and what they do. * `makeZipFile` - Builds a zip file containing all release files. This includes the source tree (suitable for use from an AMD-aware application), plus the combined and minified Cesium.js files, the generated documentation, the test suite, and the example applications (in both built and source form). * **Utility scripts** -- code coverage, static code analysis, and other utilities * `instrumentForCoverage` - Runs [JSCoverage](http://siliconforks.com/jscoverage/) on the source tree to allow running tests with coverage information. Use the link in index.html. Currently Windows only. - * `jsHint` - Runs [JSHint](http://www.jshint.com/), a static code analysis tool, on the entire source tree. - * `jsHint-watch` - A never-ending task that watches your file system for changes to Cesium and runs JSHint on any changed source files. + * `eslint` - Runs [ESLint](http://eslint.org/), a static code analysis tool, on the entire source tree. + * `eslint-watch` - A never-ending task that watches your file system for changes to Cesium and runs ESLint on any changed source files. * `clean` - Removes all generated build artifacts. * `cloc` - Runs [CLOC](https://github.com/AlDanial/cloc) to count the lines of code on the Source and Specs directories. This requires [Perl](http://www.perl.org/) to execute. * `sortRequires` - Alphabetically sorts the list of required modules in every `js` file. It also makes sure that the top of every source file uses the same formatting. diff --git a/Documentation/Contributors/CodeReviewGuide/README.md b/Documentation/Contributors/CodeReviewGuide/README.md index 9a0323a4ead..b4096f8e111 100644 --- a/Documentation/Contributors/CodeReviewGuide/README.md +++ b/Documentation/Contributors/CodeReviewGuide/README.md @@ -47,7 +47,7 @@ This guide describes best practices for code reviews. ## Merging -* Cesium uses Travis CI for continuous integration. Travis automatically builds Cesium, runs JSHint, and generates the documentation for each branch pushed to GitHub. Before merging a pull request, verify that all Travis checks pass, indicated by the green check-mark and green `Merge pull request` button: +* Cesium uses Travis CI for continuous integration. Travis automatically builds Cesium, runs ESLint, and generates the documentation for each branch pushed to GitHub. Before merging a pull request, verify that all Travis checks pass, indicated by the green check-mark and green `Merge pull request` button: ![](Travis.jpg) @@ -99,7 +99,7 @@ When in doubt, merge. Futher Reading: [Merge vs Rebase](https://www.derekgourlay.com/blog/git-when-to-merge-vs-when-to-rebase/). #### Merge -With merge, your commits will become interleaved with other target branch commits based on timestamp. +With merge, your commits will become interleaved with other target branch commits based on timestamp. ``` git fetch --all # Fetch updates from all remotes git merge upstream/target diff --git a/LICENSE.md b/LICENSE.md index 533e3f8154e..87a7ae3f740 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -424,6 +424,31 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +### ESLint + +http://www.eslint.org/ + +> Copyright JS Foundation and other contributors, https://js.foundation + +> Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +> The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + Tests ===== @@ -558,11 +583,11 @@ www.bigbuckbunny.org https://github.com/dataarts/webgl-globe > Copyright 2011 Google Data Arts Team -> +> > Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at -> +> > http://www.apache.org/licenses/LICENSE-2.0 -> +> > Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ### Wooden Watch Tower ### diff --git a/Source/Core/OrientedBoundingBox.js b/Source/Core/OrientedBoundingBox.js index 53e0f48e28e..53e6441b483 100644 --- a/Source/Core/OrientedBoundingBox.js +++ b/Source/Core/OrientedBoundingBox.js @@ -182,7 +182,7 @@ define([ v3 = Cartesian3.multiplyByScalar(v3, 0.5 * (l3 + u3), v3); var center = Cartesian3.add(v1, v2, result.center); - center = Cartesian3.add(center, v3, center); + Cartesian3.add(center, v3, center); var scale = scratchCartesian3; scale.x = u1 - l1; diff --git a/Source/DataSources/CzmlDataSource.js b/Source/DataSources/CzmlDataSource.js index 6b08a323235..64b9c5d83cc 100644 --- a/Source/DataSources/CzmlDataSource.js +++ b/Source/DataSources/CzmlDataSource.js @@ -497,7 +497,6 @@ define([ function unwrapInterval(type, czmlInterval, sourceUri) { // The associations in this function need to be kept in sync with the // associations in getPropertyType - /*jshint sub:true*/ switch (type) { case Array: return czmlInterval.array; diff --git a/Source/DataSources/GeoJsonDataSource.js b/Source/DataSources/GeoJsonDataSource.js index 9434069a73a..a9a71a4f3f4 100644 --- a/Source/DataSources/GeoJsonDataSource.js +++ b/Source/DataSources/GeoJsonDataSource.js @@ -81,7 +81,6 @@ define([ var defaultStrokeWidthProperty = new ConstantProperty(defaultStrokeWidth); var defaultStrokeMaterialProperty = new ColorMaterialProperty(defaultStroke); - var defaultFillMaterialProperty = new ColorMaterialProperty(defaultFill); var sizes = { small : 24, @@ -627,7 +626,6 @@ define([ }, set : function(value) { defaultFill = value; - defaultFillMaterialProperty = new ColorMaterialProperty(defaultFill); } }, /** diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js index 3f092b8346f..4cb1af04e5e 100644 --- a/Source/Renderer/Context.js +++ b/Source/Renderer/Context.js @@ -138,11 +138,10 @@ define([ var glWrapper = {}; - /*jslint forin: true*/ - /*jshint forin: false*/ - // JSLint normally demands that a for..in loop must directly contain an if, + // JavaScript linters normally demand that a for..in loop must directly contain an if, // but in our loop below, we actually intend to iterate all properties, including // those in the prototype. + /*eslint-disable guard-for-in*/ for (var propertyName in gl) { var property = gl[propertyName]; @@ -152,7 +151,7 @@ define([ } else { Object.defineProperty(glWrapper, propertyName, makeGetterSetter(gl, propertyName, logFunction)); } - } + }/*eslint-enable guard-for-in*/ return glWrapper; } diff --git a/Source/Scene/DebugCameraPrimitive.js b/Source/Scene/DebugCameraPrimitive.js index 90030e73a2f..b5f4cb09f24 100644 --- a/Source/Scene/DebugCameraPrimitive.js +++ b/Source/Scene/DebugCameraPrimitive.js @@ -151,7 +151,6 @@ define([ for (var i = 0; i < 4; ++i) { var corner = Cartesian4.clone(frustumCornersNDC[i], scratchFrustumCorners[i]); - var worldCoords; if (!defined(inverseViewProjection)) { if (defined(frustum._offCenterFrustum)) { frustum = frustum._offCenterFrustum; @@ -171,7 +170,7 @@ define([ corner.z = (corner.z * (near - far) - near - far) * 0.5; corner.w = 1.0; - worldCoords = Matrix4.multiplyByVector(inverseView, corner, corner); + Matrix4.multiplyByVector(inverseView, corner, corner); } else { corner = Matrix4.multiplyByVector(inverseViewProjection, corner, corner); diff --git a/Source/Scene/UrlTemplateImageryProvider.js b/Source/Scene/UrlTemplateImageryProvider.js index 4ed3a72bb76..1abdc818076 100644 --- a/Source/Scene/UrlTemplateImageryProvider.js +++ b/Source/Scene/UrlTemplateImageryProvider.js @@ -950,7 +950,6 @@ define([ return; } - var projected; if (imageryProvider.tilingScheme instanceof GeographicTilingScheme) { longitudeLatitudeProjectedScratch.x = CesiumMath.toDegrees(longitude); longitudeLatitudeProjectedScratch.y = CesiumMath.toDegrees(latitude); @@ -958,7 +957,7 @@ define([ var cartographic = cartographicScratch; cartographic.longitude = longitude; cartographic.latitude = latitude; - projected = imageryProvider.tilingScheme.projection.project(cartographic, longitudeLatitudeProjectedScratch); + imageryProvider.tilingScheme.projection.project(cartographic, longitudeLatitudeProjectedScratch); } longitudeLatitudeProjectedScratchComputed = true; diff --git a/Source/Scene/createTileMapServiceImageryProvider.js b/Source/Scene/createTileMapServiceImageryProvider.js index bc71467d1d2..51e36a2bcfe 100644 --- a/Source/Scene/createTileMapServiceImageryProvider.js +++ b/Source/Scene/createTileMapServiceImageryProvider.js @@ -105,8 +105,7 @@ define([ var tileSetRegex = /tileset/i; var tileSetsRegex = /tilesets/i; var bboxRegex = /boundingbox/i; - var srsRegex = /srs/i; - var format, bbox, tilesets, srs; + var format, bbox, tilesets; var tilesetsList = []; //list of TileSets // Allowing options properties (already copied to that) to override XML values @@ -128,8 +127,6 @@ define([ } } else if (bboxRegex.test(nodeList.item(i).nodeName)) { bbox = nodeList.item(i); - } else if (srsRegex.test(nodeList.item(i).nodeName)) { - srs = nodeList.item(i).textContent; } } diff --git a/Specs/Core/GeometryPipelineSpec.js b/Specs/Core/GeometryPipelineSpec.js index 71470fd08ff..0980b1c8048 100644 --- a/Specs/Core/GeometryPipelineSpec.js +++ b/Specs/Core/GeometryPipelineSpec.js @@ -345,7 +345,7 @@ defineSuite([ } }); - geometry = GeometryPipeline.reorderForPreVertexCache(geometry); + GeometryPipeline.reorderForPreVertexCache(geometry); }).toThrowDeveloperError(); }); diff --git a/Specs/Core/loadTextSpec.js b/Specs/Core/loadTextSpec.js index 272c89ea71d..74c417d48a7 100644 --- a/Specs/Core/loadTextSpec.js +++ b/Specs/Core/loadTextSpec.js @@ -1,4 +1,3 @@ -/* jshint jasmine: true*/ /*global defineSuite*/ defineSuite([ 'Core/loadText', diff --git a/Specs/DataSources/CzmlDataSourceSpec.js b/Specs/DataSources/CzmlDataSourceSpec.js index f5a0e191d46..58f4d10f22e 100644 --- a/Specs/DataSources/CzmlDataSourceSpec.js +++ b/Specs/DataSources/CzmlDataSourceSpec.js @@ -3384,7 +3384,6 @@ defineSuite([ it('checks validation document', function() { return CzmlDataSource.load('Data/CZML/ValidationDocument.czml').then(function(dataSource) { - /*jshint -W120 */ var e; var date; var documentStartDate = JulianDate.fromIso8601('2016-06-17T12:00:00Z'); diff --git a/Specs/DataSources/GeometryVisualizerSpec.js b/Specs/DataSources/GeometryVisualizerSpec.js index 9157d46e4aa..bd3721b2083 100644 --- a/Specs/DataSources/GeometryVisualizerSpec.js +++ b/Specs/DataSources/GeometryVisualizerSpec.js @@ -700,7 +700,7 @@ defineSuite([ var entityCollection = new EntityCollection(); var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, entityCollection); expect(entityCollection.collectionChanged.numberOfListeners).toEqual(1); - visualizer = visualizer.destroy(); + visualizer.destroy(); expect(entityCollection.collectionChanged.numberOfListeners).toEqual(0); }); diff --git a/Specs/DataSources/LabelVisualizerSpec.js b/Specs/DataSources/LabelVisualizerSpec.js index 591f0fe8409..d7be189c3ad 100644 --- a/Specs/DataSources/LabelVisualizerSpec.js +++ b/Specs/DataSources/LabelVisualizerSpec.js @@ -89,7 +89,7 @@ defineSuite([ var entityCollection = new EntityCollection(); var visualizer = new LabelVisualizer(entityCluster, entityCollection); expect(entityCollection.collectionChanged.numberOfListeners).toEqual(1); - visualizer = visualizer.destroy(); + visualizer.destroy(); expect(entityCollection.collectionChanged.numberOfListeners).toEqual(0); }); diff --git a/Specs/DataSources/ModelVisualizerSpec.js b/Specs/DataSources/ModelVisualizerSpec.js index dc27918c272..55d59dff7f8 100644 --- a/Specs/DataSources/ModelVisualizerSpec.js +++ b/Specs/DataSources/ModelVisualizerSpec.js @@ -80,9 +80,9 @@ defineSuite([ it('removes the listener from the entity collection when destroyed', function() { var entityCollection = new EntityCollection(); - var visualizer = new ModelVisualizer(scene, entityCollection); + visualizer = new ModelVisualizer(scene, entityCollection); expect(entityCollection.collectionChanged.numberOfListeners).toEqual(1); - visualizer = visualizer.destroy(); + visualizer.destroy(); expect(entityCollection.collectionChanged.numberOfListeners).toEqual(0); }); diff --git a/Specs/DataSources/PathVisualizerSpec.js b/Specs/DataSources/PathVisualizerSpec.js index 7fc1bcc61c3..8c575b0af1d 100644 --- a/Specs/DataSources/PathVisualizerSpec.js +++ b/Specs/DataSources/PathVisualizerSpec.js @@ -85,9 +85,9 @@ defineSuite([ it('removes the listener from the entity collection when destroyed', function() { var entityCollection = new EntityCollection(); - var visualizer = new PathVisualizer(scene, entityCollection); + visualizer = new PathVisualizer(scene, entityCollection); expect(entityCollection.collectionChanged.numberOfListeners).toEqual(1); - visualizer = visualizer.destroy(); + visualizer.destroy(); expect(entityCollection.collectionChanged.numberOfListeners).toEqual(0); }); diff --git a/Specs/DataSources/PointVisualizerSpec.js b/Specs/DataSources/PointVisualizerSpec.js index 4878402f662..b2319720d66 100644 --- a/Specs/DataSources/PointVisualizerSpec.js +++ b/Specs/DataSources/PointVisualizerSpec.js @@ -118,9 +118,9 @@ defineSuite([ it('removes the listener from the entity collection when destroyed', function() { var entityCollection = new EntityCollection(); - var visualizer = new PointVisualizer(entityCluster, entityCollection); + visualizer = new PointVisualizer(entityCluster, entityCollection); expect(entityCollection.collectionChanged.numberOfListeners).toEqual(1); - visualizer = visualizer.destroy(); + visualizer.destroy(); expect(entityCollection.collectionChanged.numberOfListeners).toEqual(0); }); diff --git a/Specs/Scene/FrameRateMonitorSpec.js b/Specs/Scene/FrameRateMonitorSpec.js index d85faff842a..540e5fcfd58 100644 --- a/Specs/Scene/FrameRateMonitorSpec.js +++ b/Specs/Scene/FrameRateMonitorSpec.js @@ -29,10 +29,9 @@ defineSuite([ }); function spinWait(milliseconds) { - /*jshint noempty: false*/ var endTime = getTimestamp() + milliseconds; - while (getTimestamp() < endTime) { - } + while (getTimestamp() < endTime) {/*eslint-disable no-empty*/ + }/*eslint-enable no-empty*/ } it('throws when constructed without a scene', function() { diff --git a/Specs/Scene/ModelSpec.js b/Specs/Scene/ModelSpec.js index e9d07dc4735..90325e25c8b 100644 --- a/Specs/Scene/ModelSpec.js +++ b/Specs/Scene/ModelSpec.js @@ -1917,7 +1917,6 @@ defineSuite([ } Matrix4.multiplyByMatrix3(m.modelMatrix, rotate, m.modelMatrix); - /* jshint loopfunc: true */ expect(scene).toRenderAndCall(function(rgba) { expect(rgba).not.toEqual([0, 0, 0, 255]); expect(rgba).not.toEqual(oldPixelColor); diff --git a/Specs/Scene/ShadowMapSpec.js b/Specs/Scene/ShadowMapSpec.js index 7033e26fce2..d442827ecef 100644 --- a/Specs/Scene/ShadowMapSpec.js +++ b/Specs/Scene/ShadowMapSpec.js @@ -494,9 +494,7 @@ defineSuite([ // Move the camera into the shadowed area scene.camera.moveRight(0.2); - var shadowedColor; renderAndCall(function(rgba) { - shadowedColor = rgba; expect(rgba).not.toEqual(backgroundColor); expect(rgba).not.toEqual(unshadowedColor); }); @@ -712,7 +710,6 @@ defineSuite([ ]; for (var i = 0; i < 6; ++i) { - /* jshint loopfunc: true */ var box = scene.primitives.add(Model.fromGltf({ url : boxUrl, modelMatrix : Transforms.headingPitchRollToFixedFrame(origins[i], new HeadingPitchRoll()), diff --git a/Specs/Scene/createTileMapServiceImageryProviderSpec.js b/Specs/Scene/createTileMapServiceImageryProviderSpec.js index cacd63f6216..6b00519e904 100644 --- a/Specs/Scene/createTileMapServiceImageryProviderSpec.js +++ b/Specs/Scene/createTileMapServiceImageryProviderSpec.js @@ -235,8 +235,7 @@ defineSuite([ }); }); - it('routes resource request through a proxy if one is specified', function() { - /*jshint unused: false*/ + it('routes resource request through a proxy if one is specified', function() {/*eslint-disable no-unused-vars*/ var proxy = new DefaultProxy('/proxy/'); var requestMetadata = when.defer(); spyOn(loadWithXhr, 'load').and.callFake(function(url, responseType, method, data, headers, deferred, overrideMimeType) { @@ -252,10 +251,9 @@ defineSuite([ return requestMetadata.promise.then(function(url) { expect(url.indexOf(proxy.getURL('server.invalid'))).toEqual(0); }); - }); + });/*eslint-enable no-unused-vars*/ - it('resource request takes a query string', function() { - /*jshint unused: false*/ + it('resource request takes a query string', function() {/*eslint-disable no-unused-vars*/ var requestMetadata = when.defer(); spyOn(loadWithXhr, 'load').and.callFake(function(url, responseType, method, data, headers, deferred, overrideMimeType) { requestMetadata.resolve(url); @@ -269,7 +267,7 @@ defineSuite([ return requestMetadata.promise.then(function(url) { expect(/\?query=1$/.test(url)).toEqual(true); }); - }); + });/*eslint-enable no-unused-vars*/ it('routes tile requests through a proxy if one is specified', function() { var proxy = new DefaultProxy('/proxy/'); diff --git a/Specs/Widgets/PerformanceWatchdog/PerformanceWatchdogViewModelSpec.js b/Specs/Widgets/PerformanceWatchdog/PerformanceWatchdogViewModelSpec.js index b4b01dbe706..340be19bd5f 100644 --- a/Specs/Widgets/PerformanceWatchdog/PerformanceWatchdogViewModelSpec.js +++ b/Specs/Widgets/PerformanceWatchdog/PerformanceWatchdogViewModelSpec.js @@ -33,7 +33,7 @@ defineSuite([ }); function spinWait(milliseconds) { - /*jshint noempty: false*/ + /*eslint-disable no-empty*/ var endTime = getTimestamp() + milliseconds; while (getTimestamp() < endTime) { } diff --git a/Specs/karma.conf.js b/Specs/karma.conf.js index 4c12124fdd5..374f114dded 100644 --- a/Specs/karma.conf.js +++ b/Specs/karma.conf.js @@ -1,4 +1,4 @@ -/*jshint node:true*/ +/*eslint-env node*/ "use strict"; module.exports = function(config) { diff --git a/gulpfile.js b/gulpfile.js index 27cd4b73e29..4e2d802ad12 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,4 +1,5 @@ /*jslint node: true, latedef: nofunc*/ +/*eslint-env node*/ 'use strict'; var fs = require('fs'); @@ -11,7 +12,7 @@ var readline = require('readline'); var request = require('request'); var globby = require('globby'); -var jshint = require('gulp-jshint'); +var eslint = require('gulp-eslint'); var gulpTap = require('gulp-tap'); var rimraf = require('rimraf'); var glslStripComments = require('glsl-strip-comments'); @@ -66,7 +67,7 @@ var buildFiles = ['Specs/**/*.js', '!Specs/SpecList.js', 'Source/Shaders/**/*.glsl']; -var jsHintFiles = ['Source/**/*.js', +var eslintFiles = ['Source/**/*.js', '!Source/Shaders/**', '!Source/ThirdParty/**', '!Source/Workers/cesiumWorkerBootstrapper.js', @@ -233,24 +234,21 @@ gulp.task('instrumentForCoverage', ['build'], function(done) { }); }); -gulp.task('jsHint', ['build'], function() { - var stream = gulp.src(jsHintFiles) - .pipe(jshint.extract('auto')) - .pipe(jshint()) - .pipe(jshint.reporter('jshint-stylish')); - +gulp.task('eslint', ['build'], function() { + var stream = gulp.src(eslintFiles) + .pipe(eslint()) + .pipe(eslint.format()); if (yargs.argv.failTaskOnError) { - stream = stream.pipe(jshint.reporter('fail')); + stream = stream.pipe(eslint.failAfterError()); } return stream; }); -gulp.task('jsHint-watch', function() { - gulp.watch(jsHintFiles).on('change', function(event) { +gulp.task('eslint-watch', function() { + gulp.watch(eslintFiles).on('change', function(event) { gulp.src(event.path) - .pipe(jshint.extract('auto')) - .pipe(jshint()) - .pipe(jshint.reporter('jshint-stylish')); + .pipe(eslint()) + .pipe(eslint.format()); }); }); @@ -677,8 +675,7 @@ gulp.task('generateStubs', ['build'], function(done) { var contents = '\ /*global define,Cesium*/\n\ (function() {\n\ -\'use strict\';\n\ -/*jshint sub:true*/\n'; +\'use strict\';\n'; var modulePathMappings = []; globby.sync(sourceFiles).forEach(function(file) { @@ -1095,7 +1092,6 @@ function createCesiumJs() { /*global define*/\n\ define([' + moduleIds.join(', ') + '], function(' + parameters.join(', ') + ') {\n\ \'use strict\';\n\ - /*jshint sub:true*/\n\ var Cesium = {\n\ VERSION : "' + version + '",\n\ _shaders : {}\n\ @@ -1115,7 +1111,7 @@ function createSpecList() { specs.push("'" + filePathToModuleId(file) + "'"); }); - var contents = '/*jshint unused: false*/\nvar specs = [' + specs.join(',') + '];'; + var contents = '/*eslint-disable no-unused-vars*/\nvar specs = [' + specs.join(',') + '];'; fs.writeFileSync(path.join('Specs', 'SpecList.js'), contents); } @@ -1175,7 +1171,7 @@ var gallery_demos = [' + demoJSONs.join(', ') + '];'; } function createJsHintOptions() { - var primary = JSON.parse(fs.readFileSync('.jshintrc', 'utf8')); + var primary = JSON.parse(fs.readFileSync(path.join('Apps', '.jshintrc'), 'utf8')); var gallery = JSON.parse(fs.readFileSync(path.join('Apps', 'Sandcastle', '.jshintrc'), 'utf8')); primary.jasmine = false; primary.predef = gallery.predef; diff --git a/index.js b/index.js index b4de7a383d7..06588baa35e 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -/*jshint node:true*/ +/*eslint-env node*/ 'use strict'; var path = require('path'); diff --git a/package.json b/package.json index 1291179187a..88e316c039e 100644 --- a/package.json +++ b/package.json @@ -39,21 +39,20 @@ "compressible": "^2.0.9", "compression": "^1.6.2", "electron": "^1.6.1", + "eslint-plugin-html": "^2.0.3", "event-stream": "^3.3.4", "express": "^4.15.0", "globby": "^6.1.0", "glsl-strip-comments": "^1.0.0", "gulp": "^3.9.1", + "gulp-eslint": "^3.0.1", "gulp-insert": "^0.5.0", - "gulp-jshint": "^2.0.4", "gulp-rename": "^1.2.2", "gulp-replace": "^0.5.4", "gulp-tap": "^0.4.1", "gulp-zip": "^4.0.0", "jasmine-core": "^2.5.2", "jsdoc": "^3.4.3", - "jshint": "^2.9.4", - "jshint-stylish": "^2.2.1", "karma": "^1.3.0", "karma-chrome-launcher": "^2.0.0", "karma-detect-browsers": "^2.2.3", @@ -84,8 +83,8 @@ "requirejs": "gulp requirejs", "generateDocumentation": "gulp generateDocumentation", "instrumentForCoverage": "gulp instrumentForCoverage", - "jsHint": "gulp jsHint", - "jsHint-watch": "gulp jsHint-watch", + "eslint": "gulp eslint", + "eslint-watch": "gulp eslint-watch", "makeZipFile": "gulp makeZipFile", "minify": "gulp minify", "minifyRelease": "gulp minifyRelease", diff --git a/server.js b/server.js index 5b8b5be287b..99db4c78ef5 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,6 @@ +/*eslint-env node*/ (function() { 'use strict'; - /*jshint node:true*/ var express = require('express'); var compression = require('compression');