Skip to content

Commit

Permalink
Merge pull request #715 from CartoDB/add-semistandard-eslint
Browse files Browse the repository at this point in the history
feat: Add semistandard rules
  • Loading branch information
elenatorro authored Jul 17, 2018
2 parents 6a6f8a1 + b9fed8a commit c374e0e
Show file tree
Hide file tree
Showing 145 changed files with 1,645 additions and 1,588 deletions.
10 changes: 8 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
"node": true,
"jasmine": true
},
"extends": "eslint:recommended",
"extends": ["semistandard"],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2017
},
"globals": {
"before": true,
"after": true
},
"rules": {
"indent": [
"error",
Expand All @@ -30,6 +34,8 @@
],
"no-console": "off",
"no-useless-escape": "off",
"no-var": "error"
"no-var": "error",
"no-new": "off",
"import/no-duplicates": "off"
}
}
51 changes: 23 additions & 28 deletions examples/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ strokeWidth: 2*zoom()/50000`,
`width: sqrt(clusterSum($amount)/50000)*20*(zoom()/4000+0.01)*1.5
color: ramp(clusterMode($category), PRISM)
strokeColor: rgba(0,0,0,0.7)
strokeWidth: 2*zoom()/50000`,
strokeWidth: 2*zoom()/50000`
];

const examples = [
Expand All @@ -78,7 +78,7 @@ const examples = [
const BASEMAPS = {
DarkMatter: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
Voyager: 'https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json',
Positron: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json',
Positron: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json'
};

const DEFAULT_BASEMAP = 'DarkMatter';
Expand All @@ -92,7 +92,7 @@ let map = new mapboxgl.Map({
style: { version: 8, sources: {}, layers: [] },
center: [0, 0],
zoom: 0,
dragRotate: false,
dragRotate: false
});

map.touchZoomRotate.disableRotation();
Expand All @@ -109,15 +109,15 @@ setInterval(() => {
map.on('zoom', updateMapInfo);
map.on('move', updateMapInfo);

function updateMapInfo() {
function updateMapInfo () {
let center = map.getCenter();
document.querySelector('.map-info').innerText = `Center: [${center.lng.toFixed(6)}, ${center.lat.toFixed(6)}] Zoom: ${map.getZoom().toFixed(6)}`;
}

map.on('load', () => {
updateMapInfo();

function updateViz(v) {
function updateViz (v) {
if (v.target) {
v = event.target.value;
}
Expand All @@ -141,7 +141,7 @@ map.on('load', () => {
}
}

function barcelona() {
function barcelona () {
document.getElementById('dataset').value = 'spend_data';
document.getElementById('user').value = 'cartovl';
document.getElementById('serverURL').value = 'https://{user}.carto.com';
Expand Down Expand Up @@ -181,15 +181,15 @@ map.on('load', () => {
map.on('moveend', saveConfig);
});

function saveConfig() {
function saveConfig () {
location.hash = getConfig();
}

function getConfig() {
function getConfig () {
return '#' + btoa(JSON.stringify(getJSONConfig()));
}

function getJSONConfig() {
function getJSONConfig () {
return {
a: document.getElementById('dataset').value,
b: '',
Expand All @@ -202,13 +202,13 @@ function getJSONConfig() {
};
}

function setConfig(input) {
function setConfig (input) {
let c = JSON.parse(atob(input));
if (c.c == 'dmanzanares-ded13') {
if (c.c === 'dmanzanares-ded13') {
c.c = 'cartovl';
c.d = 'https://{user}.carto.com';
}
if (c.d == 'carto.com') {
if (c.d === 'carto.com') {
c.d = 'https://{user}.carto.com';
}
document.getElementById('dataset').value = c.a;
Expand Down Expand Up @@ -258,7 +258,7 @@ const superRefresh = (opts) => {
}
};

function setupMap(opts) {
function setupMap (opts) {
opts = opts || {};
if (opts.zoom !== undefined) {
map.setZoom(opts.zoom);
Expand All @@ -270,14 +270,14 @@ function setupMap(opts) {
createBasemapElements();
}

function handleError(error) {
function handleError (error) {
const err = `Invalid viz: ${error}:${error.stack}`;
console.warn(err);
document.getElementById('feedback').innerText = err;
document.getElementById('feedback').style.display = 'block';
}

function createBasemapElements() {
function createBasemapElements () {
const basemapSelector = document.querySelector('#basemap');
basemapSelector.innerHTML = '';
Object.keys(BASEMAPS).forEach(id => {
Expand All @@ -303,7 +303,7 @@ function createBasemapElements() {
});
}

function setBasemap(id) {
function setBasemap (id) {
basemap = id;
map.setStyle(BASEMAPS[basemap]);
let added = false;
Expand All @@ -326,7 +326,7 @@ $fullscreenButton.onclick = () => {
}
};

function enterFullScreen() {
function enterFullScreen () {
$fullscreenButton.style.position = 'fixed';
$fullscreenButton.style.top = '10px';
$fullscreenButton.style.right = '10px';
Expand All @@ -342,7 +342,7 @@ function enterFullScreen() {
map.resize();
}

function exitFullScreen() {
function exitFullScreen () {
$fullscreenButton.style.position = '';
$fullscreenButton.style.top = '';
$fullscreenButton.style.right = '';
Expand All @@ -369,19 +369,17 @@ if ($exportMapButton) {
});
}


if ($copyHTMLButton) {
$copyHTMLButton.addEventListener('click', () => {
$mapTextarea.select();
document.execCommand('copy');
});
}


/**
* Generates an HTML template for the given map configuration
*/
function generateSnippet(config) {
function generateSnippet (config) {
const dataset = config.a;
const apiKey = config.b || 'default_public';
const username = config.c;
Expand All @@ -391,7 +389,6 @@ function generateSnippet(config) {
const zoom = config.g || 10;
const basemap = BASEMAPS[config.h] || 'https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json';


return `<!DOCTYPE html>
<html>
<head>
Expand Down Expand Up @@ -449,16 +446,15 @@ function generateSnippet(config) {
`;
}


function showLoader() {
function showLoader () {
document.querySelector('.loader').style.display = 'block';
}

function hideLoader() {
function hideLoader () {
document.querySelector('.loader').style.display = 'none';
}

function addExample(example) {
function addExample (example) {
const [name, code] = example;
let button = document.createElement('button');
button.innerText = name;
Expand All @@ -468,7 +464,6 @@ function addExample(example) {
document.getElementById('buttonlist').appendChild(button);
}


function mod(a, b) {
function mod (a, b) {
return ((a % b) + b) % b;
}
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,28 @@
},
"devDependencies": {
"@carto/mapbox-gl": "0.45.0-carto1",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"chai": "^4.1.2",
"eslint-config-semistandard": "^12.0.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"eslint": "^4.15.0",
"exquisite-sst": "^1.4.0",
"fastly": "^2.2.0",
"glob": "^7.1.2",
"http-server": "^0.11.1",
"jasmine-core": "^2.99.1",
"jsdoc": "^3.5.5",
"jsdoc-escape-at": "^1.0.1",
"karma": "^2.0.2",
"jsdoc": "^3.5.5",
"karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "^1.1.2",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.0",
"karma": "^2.0.2",
"lodash.template": "^4.4.0",
"mocha": "^5.0.0",
"puppeteer": "^1.1.0",
Expand All @@ -61,9 +67,9 @@
"sloc": "^0.2.0",
"svg-inline-loader": "^0.8.0",
"uglifyjs-webpack-plugin": "^1.2.7",
"webpack": "^4.0.0",
"webpack-cli": "^2.1.4",
"webpack-glsl-loader": "^1.0.1"
"webpack-glsl-loader": "^1.0.1",
"webpack": "^4.0.0"
},
"main": "src/index.js",
"module": "src/index.js",
Expand Down
8 changes: 4 additions & 4 deletions scripts/cdn/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ if (prerelease) {
uploadFiles('v' + major + '.' + minor + '.' + patch);
}

function uploadFiles(version) {
function uploadFiles (version) {
console.log('Publish', version);
let uploader = client.uploadDir({
localDir: 'dist',
Expand All @@ -73,12 +73,12 @@ function uploadFiles(version) {
Prefix: 'carto-vl/' + version + '/'
}
});
uploader.on('error', function(err) {
uploader.on('error', function (err) {
console.error('Error: unable to upload:', err.stack);
});
uploader.on('progress', function() {
uploader.on('progress', function () {
});
uploader.on('end', function() {
uploader.on('end', function () {
console.log('Done', version);
});
}
Loading

0 comments on commit c374e0e

Please sign in to comment.