Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jonataswalker committed Sep 26, 2020
1 parent 3f5e2be commit 17aba16
Show file tree
Hide file tree
Showing 41 changed files with 8,431 additions and 4,341 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.js

This file was deleted.

142 changes: 142 additions & 0 deletions .eslintrc.yaml
@@ -0,0 +1,142 @@
---
root: true
env:
browser: true
node: true
parser: babel-eslint
parserOptions:
ecmaVersion: 2020
ecmaFeatures:
impliedStrict: true
globals:
Geocoder: true
ol: true
extends:
- airbnb-base
- hardcore
- plugin:prettier/recommended
rules:
no-sync: 0
no-magic-numbers: 0
no-inline-comments: 0
line-comment-position: 0
max-statements: 0
no-process-env: 0
array-callback-return: 0
no-return-assign: 0
no-underscore-dangle: 0
no-nested-ternary: 0
no-negated-condition: 0
max-lines: 0
no-plusplus: 0
no-process-exit: 0
class-methods-use-this: 0
no-this-before-super: 0
no-constructor-return: 0
no-console:
- warn
- allow:
- warn
- error
- trace
complexity:
- error
- max: 20
prettier/prettier:
- error
- singleQuote: true
printWidth: 100
tabWidth: 2
useTabs: false
semi: true
quoteProps: as-needed
trailingComma: es5
bracketSpacing: true
arrowParens: always
proseWrap: preserve
htmlWhitespaceSensitivity: css
endOfLine: lf
no-unused-vars:
- error
- args: none
ignoreRestSiblings: true
vars: local
caughtErrors: none
no-use-before-define:
- error
- functions: false
no-unused-expressions:
- error
- allowTernary: true
allowShortCircuit: true
id-length:
- error
- properties: never
exceptions:
- R
- h
- t
- i
- k
- q
- c
- r
- v
- x
no-shadow:
- error
- builtinGlobals: true
allow:
- find
- name
- external
- status
- event
- open
consistent-return:
- error
- treatUndefinedAsUnspecified: true
no-param-reassign:
- error
- props: false
max-params:
- error
- 4
func-style:
- error
- declaration
- allowArrowFunctions: true
import/group-exports: 0
import/exports-last: 0
import/max-dependencies: 0
import/no-unused-modules: 0
import/prefer-default-export: 0
import/no-namespace: 0
import/no-extraneous-dependencies:
- error
- devDependencies: true
import/extensions: 0
import/unambiguous: 0
import/no-anonymous-default-export:
- error
- allowArray: true
allowArrowFunction: true
allowObject: true
node/no-unpublished-import: 0
node/no-process-exit: 0
node/no-process-env: 0
node/no-sync: 0
promise/avoid-new: 0
promise/always-return: 0
unicorn/catch-error-name: 0
unicorn/no-null: 0
unicorn/prevent-abbreviations: 0
sonarjs/cognitive-complexity:
- error
- 40

overrides:
- files:
- 'test/unit/*.test.js'
extends:
- plugin:jest/recommended
12 changes: 12 additions & 0 deletions .prettierrc.yaml
@@ -0,0 +1,12 @@
printWidth: 100
tabWidth: 2
useTabs: false
semi: true
singleQuote: true
quoteProps: as-needed
trailingComma: es5
bracketSpacing: true
arrowParens: always
proseWrap: preserve
htmlWhitespaceSensitivity: css
endOfLine: lf
8 changes: 8 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,8 @@
{
"[javascript]": {},
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
"editor.formatOnSave": true,
"editor.formatOnPaste": false,
}
1 change: 1 addition & 0 deletions .vscode/snipsnap.code-snippets

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions babel.config.js
Expand Up @@ -9,6 +9,7 @@ module.exports = {
},
],
],

env: {
test: {
presets: [['@babel/preset-env']],
Expand Down
6 changes: 3 additions & 3 deletions build/build-css.js
Expand Up @@ -30,14 +30,14 @@ sass.render(
autoprefixer(),
postcssReport({ clearMessages: true }),
]);
prefixer.process(result.css, { from: undefined }).then(res => {
res.warnings().forEach(warn => {
prefixer.process(result.css, { from: undefined }).then((res) => {
res.warnings().forEach((warn) => {
console.warn(warn.toString());
});

writeFileSync('./dist/ol-geocoder.css', banner + res.css);

cssnano.process(res.css).then(min => {
cssnano.process(res.css).then((min) => {
writeFileSync('./dist/ol-geocoder.min.css', banner + min.css);

const cssSize = bytes(Buffer.byteLength(res.css));
Expand Down
33 changes: 6 additions & 27 deletions build/config.js
@@ -1,13 +1,9 @@
import { readFileSync } from 'fs';
import { minify } from 'uglify-es';
import nodeResolve from 'rollup-plugin-node-resolve';
import json from 'rollup-plugin-json';
import buble from 'rollup-plugin-buble';
import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import { eslint } from 'rollup-plugin-eslint';
import includePaths from 'rollup-plugin-includepaths';
import bundleSize from 'rollup-plugin-filesize';
import { uglify } from 'rollup-plugin-uglify';
import json from '@rollup/plugin-json';
import buble from '@rollup/plugin-buble';
import { terser } from 'rollup-plugin-terser';

const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
const external = Object.keys(pkg.dependencies);
Expand All @@ -24,22 +20,11 @@ const ol = [
['ol/Feature', 'ol.Feature'],
];

ol.forEach(each => {
ol.forEach((each) => {
external.push(each[0]);
globals[each[0]] = each[1];
});

const lintOpts = {
// extensions: ['js'],
exclude: ['**/*.json'],
cache: true,
throwOnError: true,
};

const includePathOptions = {
paths: ['', './src'],
};

const banner = readFileSync('./build/banner.js', 'utf-8')
.replace('${name}', pkg.name)
.replace('${description}', pkg.description)
Expand All @@ -59,14 +44,11 @@ export default [
name: 'Geocoder',
},
plugins: [
includePaths(includePathOptions),
eslint(lintOpts),
bundleSize(),
nodeResolve(),
commonjs(),
json({ exclude: 'node_modules/**' }),
buble({ target: { ie: 11 } }),
uglify({ output: { comments: /^!/ } }, minify),
terser({ output: { comments: /^!/ } }),
],
},
{
Expand All @@ -80,9 +62,6 @@ export default [
name: 'Geocoder',
},
plugins: [
includePaths(includePathOptions),
eslint(lintOpts),
bundleSize(),
nodeResolve(),
commonjs(),
json({ exclude: 'node_modules/**' }),
Expand Down
43 changes: 22 additions & 21 deletions examples/control-glass.js
@@ -1,22 +1,23 @@
(function(win, doc) {
var olview = new ol.View({
center: [0, 0],
zoom: 3,
minZoom: 2,
maxZoom: 20,
}),
baseLayer = new ol.layer.Tile({
source: new ol.source.OSM(),
}),
map = new ol.Map({
target: doc.getElementById('map'),
view: olview,
layers: [baseLayer],
}),
popup = new ol.Overlay.Popup();
((win, doc) => {
const olview = new ol.View({
center: [0, 0],
zoom: 3,
minZoom: 2,
maxZoom: 20,
});

const baseLayer = new ol.layer.Tile({
source: new ol.source.OSM(),
});
const map = new ol.Map({
target: doc.querySelector('#map'),
view: olview,
layers: [baseLayer],
});
const popup = new ol.Overlay.Popup();

//Instantiate with some options and add the Control
var geocoder = new Geocoder('nominatim', {
// Instantiate with some options and add the Control
const geocoder = new Geocoder('nominatim', {
provider: 'photon',
targetType: 'glass-button',
lang: 'en',
Expand All @@ -28,9 +29,9 @@
map.addControl(geocoder);
map.addOverlay(popup);

//Listen when an address is chosen
geocoder.on('addresschosen', function(evt) {
window.setTimeout(function() {
// Listen when an address is chosen
geocoder.on('addresschosen', (evt) => {
window.setTimeout(() => {
popup.show(evt.coordinate, evt.address.formatted);
}, 3000);
});
Expand Down
43 changes: 22 additions & 21 deletions examples/control-nominatim.js
@@ -1,22 +1,23 @@
(function(win, doc) {
var olview = new ol.View({
center: [0, 0],
zoom: 3,
minZoom: 2,
maxZoom: 20,
}),
baseLayer = new ol.layer.Tile({
source: new ol.source.OSM(),
}),
map = new ol.Map({
target: doc.getElementById('map'),
view: olview,
layers: [baseLayer],
}),
popup = new ol.Overlay.Popup();
((win, doc) => {
const olview = new ol.View({
center: [0, 0],
zoom: 3,
minZoom: 2,
maxZoom: 20,
});

const baseLayer = new ol.layer.Tile({
source: new ol.source.OSM(),
});
const map = new ol.Map({
target: doc.querySelector('#map'),
view: olview,
layers: [baseLayer],
});
const popup = new ol.Overlay.Popup();

//Instantiate with some options and add the Control
var geocoder = new Geocoder('nominatim', {
// Instantiate with some options and add the Control
const geocoder = new Geocoder('nominatim', {
provider: 'osm',
targetType: 'text-input',
lang: 'en',
Expand All @@ -28,9 +29,9 @@
map.addControl(geocoder);
map.addOverlay(popup);

//Listen when an address is chosen
geocoder.on('addresschosen', function(evt) {
window.setTimeout(function() {
// Listen when an address is chosen
geocoder.on('addresschosen', (evt) => {
window.setTimeout(() => {
popup.show(evt.coordinate, evt.address.formatted);
}, 3000);
});
Expand Down

0 comments on commit 17aba16

Please sign in to comment.