Skip to content

Commit

Permalink
changes eslint from standard to prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
songololo committed Nov 7, 2019
1 parent c4bdc0e commit 3b3f0f1
Show file tree
Hide file tree
Showing 9 changed files with 661 additions and 869 deletions.
1 change: 0 additions & 1 deletion .browserslistrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
> 1%
last 2 versions
not ie <= 8
5 changes: 0 additions & 5 deletions .editorconfig

This file was deleted.

14 changes: 7 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module.exports = {
env: {
node: true
},
'extends': [
'plugin:vue/recommended',
'@vue/standard'
extends: [
"plugin:vue/recommended",
"@vue/prettier"
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off"
},
parserOptions: {
parser: 'babel-eslint'
parser: "babel-eslint"
}
}
};
27 changes: 19 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# Editor and OS directories and files
.idea
**/.DS_Store
.DS_Store
node_modules
/dist
dist/

# local env files
.env.local
.env.*.local

# Log files
node_modules/
**/yarn-debug.log
**/yarn-error.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# build directories
dist/
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,22 @@
"mapbox-gl": "1.5.0"
},
"devDependencies": {
"@vue/cli-plugin-eslint": "^3.11.0",
"@vue/cli-service": "^3.11.0",
"@vue/eslint-config-standard": "4.0.0",
"@vue/cli-plugin-eslint": "^4.0.5",
"@vue/cli-service": "^4.0.5",
"@vue/eslint-config-prettier": "^5.0.0",
"babel-eslint": "10.0.3",
"eslint": "6.5.1",
"eslint-plugin-vue": "5.2.3",
"rollup": "1.23.1",
"eslint": "6.6.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-vue": "6.0.0",
"rollup": "1.26.3",
"rollup-plugin-buble": "0.19.8",
"rollup-plugin-commonjs": "10.1.0",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-terser": "5.1.2",
"rollup-plugin-vue": "5.0.1",
"rollup-plugin-vue": "5.1.2",
"vue": "2.6.10",
"vue-template-compiler": "2.6.10",
"vuepress": "1.1.0"
"vuepress": "1.2.0"
},
"bugs": "https://github.com/cityseer/vue-mapbox-map/issues",
"homepage": "https://cityseer.github.io/vue-mapbox-map/",
Expand Down
42 changes: 21 additions & 21 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import vue from 'rollup-plugin-vue'
import buble from 'rollup-plugin-buble'
import { terser } from 'rollup-plugin-terser'
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import vue from "rollup-plugin-vue";
import buble from "rollup-plugin-buble";
import { terser } from "rollup-plugin-terser";

// see https://github.com/rollup/rollup-starter-lib/blob/buble/rollup.config.js
export default {
input: 'src/main.js',
external: [ 'mapbox-gl', '@mapbox/mapbox-gl-geocoder' ], // suppresses warnings about external modules
input: "src/main.js",
external: ["mapbox-gl", "@mapbox/mapbox-gl-geocoder"], // suppresses warnings about external modules
output: [
{
name: 'VueMapboxMap',
file: 'dist/VueMapboxMap.umd.js',
format: 'umd', // browser friendly UMD build
name: "VueMapboxMap",
file: "dist/VueMapboxMap.umd.js",
format: "umd", // browser friendly UMD build
globals: {
'mapbox-gl': 'mapboxgl'
"mapbox-gl": "mapboxgl"
}
},
{
name: 'VueMapboxMap',
file: 'dist/VueMapboxMap.common.js',
format: 'cjs', // CommonJS (for Node)
name: "VueMapboxMap",
file: "dist/VueMapboxMap.common.js",
format: "cjs", // CommonJS (for Node)
globals: {
'mapbox-gl': 'mapboxgl'
"mapbox-gl": "mapboxgl"
}
},
{
name: 'VueMapboxMap',
file: 'dist/VueMapboxMap.esm.js',
format: 'esm', // ES module (for bundlers)
name: "VueMapboxMap",
file: "dist/VueMapboxMap.esm.js",
format: "esm", // ES module (for bundlers)
globals: {
'mapbox-gl': 'mapboxgl'
"mapbox-gl": "mapboxgl"
}
}
],
Expand All @@ -41,8 +41,8 @@ export default {
css: true
}),
buble({
exclude: ['node_modules/**']
exclude: ["node_modules/**"]
}),
terser()
]
}
};
99 changes: 55 additions & 44 deletions src/components/VueMapboxMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
<script>
// imports are dynamic, see below
export default {
name: 'VueMapboxMap',
name: "VueMapboxMap",
props: {
// mapbox requires an access token
// access as "access-token"
accessToken: {
type: String,
required: false,
default: ''
default: ""
},
// target map style, you can also load a local map style configuration
// access as "map-style"
mapStyle: {
type: [String, Object],
default: 'mapbox://styles/mapbox/light-v9'
default: "mapbox://styles/mapbox/light-v9"
},
// whether to display the attribution control
// this is required by mapbox unless you fulfill this requirement elsehow
Expand All @@ -36,9 +36,9 @@ export default {
transitionMode: {
type: String,
required: false,
default: 'jump',
validator: function (value) {
return ['jump', 'ease', 'fly'].indexOf(value) !== -1
default: "jump",
validator: function(value) {
return ["jump", "ease", "fly"].indexOf(value) !== -1;
}
},
// longitude (dynamic)
Expand Down Expand Up @@ -67,97 +67,108 @@ export default {
default: 0
}
},
data () {
data() {
return {
map: null
}
};
},
computed: {
mapScene () {
mapScene() {
return {
center: [this.lng, this.lat],
zoom: this.zoom,
bearing: this.bearing,
pitch: this.pitch
}
};
}
},
watch: {
mapStyle: {
deep: true,
handler (val) {
handler(val) {
if (val && this.map) {
// TODO: currently custom data layers are lost, but probably option to save them in future per
// https://github.com/mapbox/mapbox-gl-js/issues/4006
// currently this means that updating the style will undo any custom feature collections...
this.map.setStyle(val)
this.map.setStyle(val);
} else {
console.error(`NOTE -> Unable to update map style to ${val}.`)
console.error(`NOTE -> Unable to update map style to ${val}.`);
}
}
},
mapScene (val) {
mapScene(val) {
if (val) {
if (!this.map) {
console.error('NOTE -> Map object not set')
return
console.error("NOTE -> Map object not set");
return;
}
if (val.pitch < 0 || val.pitch > 60) {
console.error(`NOTE -> Unable to update pitch to ${val.pitch}. Exceeds permitted range.`)
return
console.error(
`NOTE -> Unable to update pitch to ${
val.pitch
}. Exceeds permitted range.`
);
return;
}
if (val.bearing < 0 || val.bearing > 360) {
console.error(`NOTE -> Unable to update bearing to ${val.bearing}. Exceeds permitted range.`)
return
console.error(
`NOTE -> Unable to update bearing to ${
val.bearing
}. Exceeds permitted range.`
);
return;
}
if (this.transitionMode === 'jump') {
this.map.jumpTo(val)
} else if (this.transitionMode === 'ease') {
this.map.easeTo(val)
} else if (this.transitionMode === 'fly') {
this.map.flyTo(val)
if (this.transitionMode === "jump") {
this.map.jumpTo(val);
} else if (this.transitionMode === "ease") {
this.map.easeTo(val);
} else if (this.transitionMode === "fly") {
this.map.flyTo(val);
}
}
}
},
mounted () {
mounted() {
// check if the mapbox available in the window
// e.g. using from web browser, in which case the scripts should be loaded in the head
// if using from a static SSR site such as vuepress then provide the relevant config.js head section
// this pattern prevents issues, e.g. with vuepress, where mapboxgl attempts to access the window scope before ready
if (typeof window.mapboxgl !== 'undefined') {
this.instanceMap()
if (typeof window.mapboxgl !== "undefined") {
this.instanceMap();
} else {
import('mapbox-gl').then(MapboxModule => {
window.mapboxgl = MapboxModule.default
this.instanceMap()
})
import("mapbox-gl").then(MapboxModule => {
window.mapboxgl = MapboxModule.default;
this.instanceMap();
});
}
},
methods: {
instanceMap () {
instanceMap() {
if (this.accessToken) {
window.mapboxgl.accessToken = this.accessToken
window.mapboxgl.accessToken = this.accessToken;
} else {
console.warn('NOTE -> No access token has been provided. If using Mapbox hosted tiles then this omission may break your map.')
console.warn(
"NOTE -> No access token has been provided. If using Mapbox hosted tiles then this omission may break your map."
);
}
this.map = new window.mapboxgl.Map({
container: this.$refs.mapboxMapDiv,
style: this.mapStyle,
interactive: this.interactive,
center: [
this.lng,
this.lat
],
center: [this.lng, this.lat],
zoom: this.zoom,
bearing: this.bearing,
pitch: this.pitch,
attributionControl: this.attributionControl
})
});
// return the map for reference from parent component
this.map.on('load', () => { this.$emit('mapbox-ready', this.map) })
this.map.on('remove', () => { this.$emit('mapbox-destroyed') })
this.map.on("load", () => {
this.$emit("mapbox-ready", this.map);
});
this.map.on("remove", () => {
this.$emit("mapbox-destroyed");
});
}
}
}
};
</script>
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// used for build
// auto registration of component via import Vue; Vue.component(...) increases build size fairly subtantially
import VueMapboxMap from './components/VueMapboxMap.vue'
import VueMapboxMap from "./components/VueMapboxMap.vue";

export default VueMapboxMap
export default VueMapboxMap;
Loading

0 comments on commit 3b3f0f1

Please sign in to comment.