Commit 07758b72 authored by Guillaume's avatar Guillaume Committed by GitHub
Browse files

JSHint: enforce more rules (#323)

* Add jshint rules esversion, browser, devel, undef, forin, freeze, nocomma and nonew
* Update some comments
* Enforce strict equality
* Remove laxcomma and laxbreak
* Removed comment in .jshintrc
* Update grunt-contrib-jshint
* Better CONTRIBUTING
parent 4c207b47
{
"jquery": true, // true: use jQuery
"unused": true, // true: Warns about declared variable not used
"nonbsp": true, // true: Warns about "non-breaking whitespace" characters
"latedef": true, // true: Require variables/functions to be defined before being used
"noarg": true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
"esversion": 3,
"jquery": true,
"browser": true,
"laxcomma": true, // true: allow unsafe line breakings
"laxbreak": true, // true: allow comma-first coding style
"devel": true,
"undef": true,
"unused": true,
"nonbsp": true,
"latedef": true,
"noarg": true,
"eqeqeq": true,
"forin": true,
"freeze": true,
"nocomma": true,
"nonew": true,
"globals": {
"define": true, // for AMD
"require": true, // for CommonJS
"module": true, // for CommonJS
"exports": true, // for CommonJS
"Raphael": true // for Raphael.js
"define": true,
"require": true,
"module": true,
"exports": true,
"Raphael": true
}
}
Contributing
------------
# Contributing
You want to contribute to Mapael? That's great, first of all, thank you !
......@@ -17,10 +16,79 @@ There are several ways you can contribute :
- **You want to help, but don't know what to do?** Check the [TODO list](https://github.com/neveldo/jQuery-Mapael/wiki/TODO-list) for features/issues we need/are working on.
_ _ _
Here are some readings: <https://guides.github.com/activities/contributing-to-open-source>
Here are some readings:
---
1. <https://guides.github.com/activities/contributing-to-open-source>
# Dev information
2. <http://kbroman.org/github_tutorial/pages/fork.html>
## Cloning the repository
Before making any modification to Mapael, you will need your own Mapael fork!
Here are some reading to get a local Mapael:
1. <https://help.github.com/articles/fork-a-repo/>
1. <http://kbroman.org/github_tutorial/pages/fork.html>
## Environment
Mapael uses [NPM](https://www.npmjs.com/) to manage package dependencies
and [Grunt](https://gruntjs.com/) to run development tasks.
After cloning locally the Mapael repository, run this command-line:
```
npm install
```
Then you will be able to run all related Grunt tasks.
## Code quality
Mapael uses [JSHint](http://jshint.com/about/) to check code quality.
The rules are [explained in the Wiki](https://github.com/neveldo/jQuery-Mapael/wiki/JSHint).
You can run this check with the following command-line:
```
grunt jshint
```
## Test suite
There is a test suite in the `/test` folder, power by [QUnit](http://qunitjs.com/).
While not broken, it is, however, very light. We sadly don't have the time to expand it for now.
When submitting a new PR, it is not expected from you to add any tests.
But if you feel like you can, please do so.
You can run this check with the following command-line
(note: it will run JSHint, then the Test Suite):
```
grunt test
```
## Build (minimified version)
Mapael is distributed as a minified file for production (`jquery.mapael.min.js`).
[UglifyJS](http://lisperator.net/uglifyjs/) is used for this operation.
You can build it with the following command-line
(note: it will run JSHint, then build the minimified files):
```
grunt build
```
When submitting a new PR, it is not expected from you to provide the minified version.
This version is usually generated by maintainers before tagging a new release.
## Continuous Integration (CI)
When submitting a new PR, you will see that [Travis](https://travis-ci.org/) (the CI tool)
will automatically run some tests on your code. It performs two tests:
1. Run JSHint to check code quality
2. Run the Test Suite to check regression
You will be able to check the result then, and perform adjustements if necessary
(by pushing a new commit to the branch).
These two tests are expected to pass when submitting a new PR.
Please check your code so
......@@ -91,6 +91,10 @@ Here is the simplest example that shows how to display an empty map of the world
* [Map with some transformations performed on SVG plotted points](https://rawgit.com/neveldo/jQuery-Mapael/master/examples/advanced/transformations_on_svg_plots.html)
* [Allow the user to add some cities by double-clicking on the map](https://rawgit.com/neveldo/jQuery-Mapael/master/examples/advanced/add_cities_on_map_by_double_click.html)
## Contributing
Want to contribute? See the [CONTRIBUTING](https://github.com/neveldo/jQuery-Mapael/blob/master/CONTRIBUTING.md) file.
## License
Copyright (C) 2013-2017 [Vincent Brouté](https://www.vincentbroute.fr)
......
This diff is collapsed.
......@@ -4,7 +4,7 @@
* Requires jQuery and Mapael
*
* Map of USA by state
*
*
* @source http://the55.net/_11/sketch/us_map
*/
(function (factory) {
......@@ -21,7 +21,7 @@
}(function ($, Mapael) {
"use strict";
$.extend(true, Mapael,
{
maps :{
......@@ -29,9 +29,9 @@
width : 959,
height : 593,
latLngToGrid: function(lat, lng, phi1, phi2, midLng, scale) {
var pi =Math.PI
, midLat = (phi1 + phi2) / 2
, n, tmp1, tmp2, tmp3, x, y, p;
var pi =Math.PI;
var midLat = (phi1 + phi2) / 2;
var n, tmp1, tmp2, tmp3, x, y, p;
n = (Math.sin(phi1 / 180 * pi) + Math.sin(phi2 / 180 * pi)) / 2;
tmp1 = Math.sqrt(Math.cos(phi1 / 180 * pi)) + 2 * n * Math.sin(phi1 / 180 * pi);
......@@ -40,7 +40,7 @@
p = scale * Math.pow(tmp1 - 2 * n * Math.sin(lat / 180 * pi),0.5) / n;
x = p * Math.sin(tmp3 / 180 * pi);
y = tmp2 - p * Math.cos(tmp3 / 180 * pi);
return([x,y]);
},
getCoords : function (lat, lon) {
......@@ -145,4 +145,4 @@
return Mapael;
}));
\ No newline at end of file
}));
......@@ -30,7 +30,7 @@
},
"devDependencies": {
"grunt": "^1.0",
"grunt-contrib-jshint": "^1.0",
"grunt-contrib-jshint": "^1.1",
"grunt-contrib-qunit": "^1.2",
"grunt-contrib-uglify": "^2.0"
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment