Skip to content

Commit

Permalink
change jshint to eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Trufi committed Mar 31, 2015
1 parent 26cc863 commit 44f7e89
Show file tree
Hide file tree
Showing 42 changed files with 204 additions and 184 deletions.
34 changes: 34 additions & 0 deletions .eslintrc
@@ -0,0 +1,34 @@
{
"rules": {
"eqeqeq": 0,
"camelcase": 2,
"quotes": [2, "single"],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"space-after-function-name": 2,
"space-in-parens": 2,
"space-in-brackets": 2,
"space-before-blocks": 2,
"space-after-keywords": 2,
"no-lonely-if": 2,
"comma-style": 2,
"indent": 2,
"no-underscore-dangle": 0,
"no-use-before-define": "nofunc",
"no-constant-condition": 0,
"no-multi-spaces": 0,
"strict": 0,
"key-spacing": 0,
"no-shadow": 0
},
"globals": {
"dust": true,
"DG": true,
"L": true,
"baron": true,
"module": false,
"define": false
},
"env": {
"browser": true
}
}
54 changes: 0 additions & 54 deletions .jshintrc

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -274,7 +274,7 @@
## Стандарты кодирования

### JavaScript
Основные требования к JavaScript коду обеспечиваются синтаксическим анализатором и описаны в конфигурационом файле [jsHint](https://github.com/2gis/maps-api-2.0/blob/master/.jshintrc). В процессе разработки мы стараемся придерживаться соглашений, схожими с [Airbnb style guide](https://github.com/airbnb/javascript), за исключением соглашений о [пробелах](https://github.com/airbnb/javascript#whitespace) и [комментариях](https://github.com/airbnb/javascript#comments).
Основные требования к JavaScript коду обеспечиваются синтаксическим анализатором и описаны в конфигурационом файле [ESLint](https://github.com/2gis/maps-api-2.0/blob/master/.eslintrc). В процессе разработки мы стараемся придерживаться соглашений, схожими с [Airbnb style guide](https://github.com/airbnb/javascript), за исключением соглашений о [пробелах](https://github.com/airbnb/javascript#whitespace) и [комментариях](https://github.com/airbnb/javascript#comments).

### HTML и CSS
#### Определения
Expand Down
2 changes: 1 addition & 1 deletion gulp/tasks/help.js
Expand Up @@ -3,7 +3,7 @@ var gulp = require('gulp');

gulp.task('help', function () {
util.log('Tasks list:');
util.log('gulp lint # Check JS files for errors with JSHint');
util.log('gulp lint # Check JS files for errors with ESLint');
util.log('gulp build # Lint, combine and minify source files, update doc, copy assets');
util.log('gulp doc # Generate documentation from .md files');
util.log('gulp test # Rebuild source and run unit tests');
Expand Down
8 changes: 3 additions & 5 deletions gulp/tasks/lintJS.js
@@ -1,13 +1,11 @@

var eslint = require('gulp-eslint');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();

var error = require('../util/error');

gulp.task('lintJS', function () {
return gulp.src('src/**/src/**/*.js')
.pipe(error.handle())
.pipe($.cache($.jshint('.jshintrc')))
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.jshint.reporter('fail'));
.pipe(eslint())
.pipe(eslint.format());
});
2 changes: 0 additions & 2 deletions gulp/util/csslint/gulp-csslint.js
@@ -1,5 +1,3 @@
/*jshint node:true */

'use strict';

var gutil = require('gulp-util');
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -30,6 +30,7 @@
"gulp-bump": "0.1.13",
"gulp-cache": "0.2.4",
"gulp-concat": "^2.2.0",
"gulp-eslint": "^0.7.0",
"gulp-file": "0.2.0",
"gulp-flatten": "0.0.4",
"gulp-footer": "^1.0.5",
Expand All @@ -38,7 +39,6 @@
"gulp-header": "^1.2.2",
"gulp-if": "^1.2.5",
"gulp-imagemin": "^2.2.0",
"gulp-jshint": "^1.9.2",
"gulp-karma": "0.0.4",
"gulp-less": "^3.0.0",
"gulp-load-plugins": "^0.8.0",
Expand All @@ -55,7 +55,6 @@
"happen": "0.1.3",
"html5shiv": "^3.7.2",
"image-size": "0.3.5",
"jshint-stylish": "^1.0.0",
"less": "^2.4.0",
"lodash": "^2.4.1",
"map-stream": "0.1.0",
Expand Down
11 changes: 8 additions & 3 deletions src/DGAjax/src/DGAjax.js
Expand Up @@ -334,7 +334,7 @@ DG.ajax = (function () {
} catch (e) {
// can't assign this in IE<=8, just ignore
}
/*jshint evil:true */
/* eslint-disable no-eval */
if (r) {
switch (type) {
case 'json':
Expand All @@ -355,7 +355,7 @@ DG.ajax = (function () {
break;
}
}
/*jshint evil:false */
/* eslint-enable no-eval */
self._responseArgs.resp = resp;
complete(resp);
}
Expand Down Expand Up @@ -412,7 +412,12 @@ DG.ajax = (function () {
enc = encodeURIComponent,
add = function (key, value) {
// If value is a function, invoke it and return its value
value = ('function' === typeof value) ? value() : (value ? value : '');
if (typeof value == 'function') {
value = value();
} else {
value = value || '';
}

s[s.length] = enc(key) + '=' + enc(value);
};

Expand Down
4 changes: 3 additions & 1 deletion src/DGAttribution/src/DGAttribution.js
Expand Up @@ -6,6 +6,7 @@ DG.Control.Attribution.include({
},

_getLink: function (linkType) {
/* eslint-disable camelcase */
var dictionary = {
ru: {
copyright_logo: 'http://info.2gis.ru/?utm_source=copyright&utm_medium=map&utm_campaign=partners',
Expand Down Expand Up @@ -43,6 +44,7 @@ DG.Control.Attribution.include({
copyright_license: 'http://law.2gis.ae/licensing-agreement/'
}
};
/* eslint-enable camelcase */

var countryCode = (this._countryCode in dictionary) ? this._countryCode : 'ru';

Expand Down Expand Up @@ -106,7 +108,7 @@ DG.Control.Attribution.include({
},
/* global __DGAttribution_TMPL__ */
_tmpl: DG.dust(__DGAttribution_TMPL__),
_getData: function (lang, osm) {
_getData: function (lang) {
return {
'osm': this._osm,
'work_on': this.t('work_on'),
Expand Down
10 changes: 6 additions & 4 deletions src/DGCore/src/DGCore.js
Expand Up @@ -23,12 +23,12 @@ DG.version = window.__dgApi__.version;
DG.debug = window.__dgApi__.debug;
DG.Icon.Default.imagePath = '../img/vendors/leaflet';

/* jshint ignore:start */
/* eslint-disable */
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','__GOOGLE_ANALYTICS__','ga');
/* jshint ignore:end */
/* eslint-enable */

/*global ga:false*/
ga('create', '__GA_CODE__', 'none');
Expand All @@ -43,7 +43,7 @@ newImg.src = '__ANALYTICS__?' +
// Improve IHandler
DG.Map.include({
addHandler: function (name, HandlerClass) {
if (!HandlerClass) { return; }
if (!HandlerClass) { return this; }

var options = this.options[name],
param = (options === Object(options)) ? options : null,
Expand All @@ -61,5 +61,7 @@ DG.Map.include({

// Apply class to map container for detect when we dont need hover effects
DG.Map.addInitHook(function () {
!DG.Browser.touch && DG.DomUtil.addClass(this._container, 'no-touch');
if (!DG.Browser.touch) {
DG.DomUtil.addClass(this._container, 'no-touch');
}
});
6 changes: 4 additions & 2 deletions src/DGCore/src/DGthen.js
@@ -1,11 +1,11 @@
var handlers = window.__dgApi__.callbacks || [],
chain = Promise.resolve();

//dont pollute global space!
// dont pollute global space!
try {
delete window.__dgApi__;
} catch(e) {
window.__dgApi__ = undefined; //ie8 cant delete from window object
window.__dgApi__ = undefined; // ie8 cant delete from window object
}

handlers.forEach(function (handlers) {
Expand All @@ -17,6 +17,8 @@ DG.then = function (resolve, reject) {
};

// IE8 throw error if `chain.catch`
/* eslint-disable dot-notation, no-console */
chain['catch'](function(err) {
console.error(err);
});
/* eslint-enable dot-notation, no-console */
4 changes: 1 addition & 3 deletions src/DGCustomization/src/DGCustomization.js
@@ -1,7 +1,5 @@
//Inject observing localization change
var controlAddTo = DG.Control.prototype.addTo,
panBy = DG.Map.prototype.panBy,
getBoundsZoom = DG.Map.prototype.getBoundsZoom;
var controlAddTo = DG.Control.prototype.addTo;

DG.Control.include({
addTo: function (map) {
Expand Down
5 changes: 3 additions & 2 deletions src/DGCustomization/src/DGMap.BaseLayer.js
Expand Up @@ -12,15 +12,16 @@
DG.Map.addInitHook(function () {
this.baseLayer = new BaseLayer('__TILE_SERVER__', {
subdomains: '0123',
errorTileUrl: this.getLang() == 'ru' ? errorRuUrl : errorUrl,
errorTileUrl: this.getLang() === 'ru' ? errorRuUrl : errorUrl,
/* global __DETECT_RETINA__ */
detectRetina: __DETECT_RETINA__,
maxZoom: 19,
maxNativeZoom: 19
}
).addTo(this);

this.on('langchange', function(ev) {
if (ev.lang == 'ru') {
if (ev.lang === 'ru') {
this.baseLayer.options.errorTileUrl = errorRuUrl;
} else {
this.baseLayer.options.errorTileUrl = errorUrl;
Expand Down
10 changes: 8 additions & 2 deletions src/DGCustomization/src/DGMap.js
Expand Up @@ -113,7 +113,11 @@ DG.Map.include({
_updateTileLayers: function (e) {
if (!(e.layer instanceof DG.TileLayer) || e.layer._isDg) { return; }

e.type === 'layeradd' ? this._tileLayersNumber++ : this._tileLayersNumber--;
if (e.type === 'layeradd') {
this._tileLayersNumber++;
} else {
this._tileLayersNumber--;
}
},

_restrictZoom: function (coords) {
Expand All @@ -128,7 +132,9 @@ DG.Map.include({
if (isMapMaxZoom) {
if (!this._mapMaxZoomCache) { this._mapMaxZoomCache = mapOptions.maxZoom; }
mapOptions.maxZoom = (this._mapMaxZoomCache && project) ? this._mapMaxZoomCache : '__PROJECT_LEAVE_MAX_ZOOM__';
project && (this._mapMaxZoomCache = mapOptions.maxZoom);
if (project) {
this._mapMaxZoomCache = mapOptions.maxZoom;
}

return mapOptions.maxZoom;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/DGDust/src/DGDust.js
Expand Up @@ -14,4 +14,4 @@ DG.dust = function (tmpl) {
};
};

if (DG.debug) { dust.debugLevel = 'ERROR'; }
if (DG.debug) { dust.debugLevel = 'ERROR'; }
7 changes: 3 additions & 4 deletions src/DGEntrance/src/Arrow.js
@@ -1,10 +1,9 @@
DG.Entrance.Arrow = DG.Polyline.extend({

initialize: function (latlngs, options) { // (Array, Object)
options = options || {};

this._setLatLngs(latlngs);
/*jshint shadow: true */
var options = options || {};
/*jshint shadow: false */

if (DG.Path.ANIMATION_AVAILABLE) {
options.animation = this.getArrowAnimation(this._convertLatLngs(latlngs));
}
Expand Down
2 changes: 1 addition & 1 deletion src/DGEntrance/src/ArrowSVG.VML.js
Expand Up @@ -28,4 +28,4 @@ DG.Entrance.Arrow.SVG.include(!L.Browser.vml ? {} : {
container.style.visibility = options.visibility;
}
}
});
});
13 changes: 10 additions & 3 deletions src/DGEntrance/src/ArrowSVG.js
Expand Up @@ -35,9 +35,14 @@ DG.Entrance.Arrow.SVG = DG.SVG.extend({
marker.setAttribute('markerUnits', 'userSpaceOnUse');
marker.setAttribute('stroke-width', '0');

markerStyle.path && marker.appendChild(this._getMarkerChild('path', markerStyle.path, layer));
if (markerStyle.path) {
marker.appendChild(this._getMarkerChild('path', markerStyle.path, layer));
}

if (markerStyle.polygon) {
marker.appendChild(this._getMarkerChild('polygon', markerStyle.polygon, layer));
}

markerStyle.polygon && marker.appendChild(this._getMarkerChild('polygon', markerStyle.polygon, layer));

layer._markers.push(marker);
this._getDefs().appendChild(marker);
Expand Down Expand Up @@ -115,7 +120,9 @@ L.Map.include({
renderer = this._arrowRenderer = new DG.Entrance.Arrow.SVG();
}

!this.hasLayer(renderer) && this.addLayer(renderer);
if (!this.hasLayer(renderer)) {
this.addLayer(renderer);
}

return renderer;
}
Expand Down
2 changes: 1 addition & 1 deletion src/DGEntrance/src/DGEntrance.js
Expand Up @@ -132,7 +132,7 @@ DG.Entrance = DG.Layer.extend({
},

_isAllowedZoom: function () {
return !(this._map.getZoom() < DG.Entrance.SHOW_FROM_ZOOM); // jshint ignore:line
return this._map.getZoom() >= DG.Entrance.SHOW_FROM_ZOOM;
},

_getArrowStrokeOptions: function () {
Expand Down

0 comments on commit 44f7e89

Please sign in to comment.