Skip to content

Commit

Permalink
Replace JSHint with ESLint
Browse files Browse the repository at this point in the history
- Added .eslintrc configuration files
- Added eslint and eslint-watch gulp tasks (added gulp-eslint and eslint-plugin-html deps)
- Removed jshint gulp tasks (and dependencies)
- Refactored inline disable comments in ESLint syntax
- Cleared all new lint errors
- Updated build and test documentation
- Added ESLint to license file
  • Loading branch information
jhwohlgemuth committed May 19, 2017
1 parent 29d9d29 commit 43578fe
Show file tree
Hide file tree
Showing 39 changed files with 200 additions and 154 deletions.
26 changes: 26 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -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"]
}
}
62 changes: 0 additions & 62 deletions .jshintrc

This file was deleted.

6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Apps/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../.eslintrc",
"env": {
"jasmine": false
}
}
62 changes: 60 additions & 2 deletions Apps/.jshintrc
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions Apps/CesiumViewer/CesiumViewerStartup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*global require*/
/*eslint-disable strict*/
require({
baseUrl : '.',
paths : {
Expand Down
13 changes: 13 additions & 0 deletions Apps/Sandcastle/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../.eslintrc",
"globals": {
"JSON": true,
"require": true,
"console": true,
"Sandcastle": true,
"Cesium": true
},
"rules": {
"no-unused-vars": ["off"]
}
}
3 changes: 2 additions & 1 deletion Apps/Sandcastle/CesiumSandcastle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -377,7 +378,7 @@ require({
errorLines.push(line);
}
}
}
}/*eslint-enable new-cap*/
}

function scheduleHint() {
Expand Down
12 changes: 6 additions & 6 deletions Apps/Sandcastle/Sandcastle-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
}
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -145,8 +145,8 @@
'lineNumber' : lineNumber
});
}
} catch (ex) {
}
} catch (ex) {/*eslint-disable no-empty*/
}/*eslint-enable no-empty*/
};

Sandcastle.highlight = function(obj) {
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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).
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 5 additions & 5 deletions Documentation/Contributors/BuildGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions Documentation/Contributors/CodeReviewGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
31 changes: 28 additions & 3 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
=====

Expand Down Expand Up @@ -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 ###
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/OrientedBoundingBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion Source/DataSources/CzmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 43578fe

Please sign in to comment.