build: migrate to nimbus (#8)

* build: migrate to nimbus

* fix: eslint-disable statements

* fix: conflict

* fix: lint

* fix: lints

* fix: bump packages
This commit is contained in:
Krist Wongsuphasawat 2020-02-07 14:18:22 -08:00 committed by Yongjie Zhao
parent b50ab75983
commit b7ec4bf266
38 changed files with 246 additions and 244 deletions

View File

@ -1,30 +1,56 @@
.babelrc
.cache
.cache-loader
.DS_Store .DS_Store
*.DS_Store
# Logs
logs/
*.log
# Cache
.bundle/
.happo/
.idea/
.next/
.cache
.eslintcache .eslintcache
.eslintignore
.eslintrc.js
.idea .idea
.npm .npm
.prettierignore
.vscode .vscode
.yarnclean .yarnclean
*.log # Directories
*.map
*.min.js
babel.config.js
build/ build/
coverage/ coverage/
dist/
esm/ esm/
jest.config.js
lib/ lib/
logs/ public/
node_modules/ node_modules/
package-lock.json tmp/
# Custom
*.map
*.min.js
test-changelog.md
# Configs (provided by Nimbus)
.babelrc
.eslintignore
.eslintrc.js
.flowconfig
.prettierignore
babel.config.js
jest.config.js
prettier.config.js prettier.config.js
tsconfig.eslint.json
tsconfig.json tsconfig.json
tsconfig.options.json
*.tsbuildinfo
webpack.config.js
# Lock files, libs should not have lock files
npm-shrinkwrap.json
package-lock.json
yarn.lock yarn.lock
old-yarn.lock
.*.swp
_gh-pages _gh-pages

View File

@ -1,8 +1,7 @@
# @superset-ui/plugins-deckgl 🔌💡 # @superset-ui/plugins-deckgl 🔌💡
[![Codecov branch](https://img.shields.io/codecov/c/github/apache-superset/superset-ui-plugins-deckgl/master.svg?style=flat-square)](https://codecov.io/gh/apache-superset/superset-ui-plugins-deckgl/branch/master) [![Codecov branch](https://img.shields.io/codecov/c/github/apache-superset/superset-ui-plugins-deckgl/master.svg?style=flat-square)](https://codecov.io/gh/apache-superset/superset-ui-plugins-deckgl/branch/master)
[![Build Status](https://img.shields.io/travis/com/apache-superset/superset-ui-plugins-deckgl/master.svg?style=flat-square [![Build Status](https://img.shields.io/travis/com/apache-superset/superset-ui-plugins-deckgl/master.svg?style=flat-square)](https://travis-ci.com/apache-superset/superset-ui-plugins-deckgl)
)](https://travis-ci.com/apache-superset/superset-ui-plugins-deckgl)
[![David](https://img.shields.io/david/dev/apache-superset/superset-ui-plugins-deckgl.svg?style=flat-square)](https://david-dm.org/apache-superset/superset-ui-plugins-deckgl?type=dev) [![David](https://img.shields.io/david/dev/apache-superset/superset-ui-plugins-deckgl.svg?style=flat-square)](https://david-dm.org/apache-superset/superset-ui-plugins-deckgl?type=dev)
[![Netlify Status](https://api.netlify.com/api/v1/badges/4d054ead-0e76-4e03-b684-797ca5924161/deploy-status)](https://app.netlify.com/sites/superset-ui-plugins-deckgl/deploys) [![Netlify Status](https://api.netlify.com/api/v1/badges/4d054ead-0e76-4e03-b684-797ca5924161/deploy-status)](https://app.netlify.com/sites/superset-ui-plugins-deckgl/deploys)
@ -14,14 +13,16 @@ Current master: https://superset-ui-plugins-deckgl.netlify.com
## Packages ## Packages
| Package | Version | | Package | Version |
|--|--| | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [@superset-ui/legacy-preset-chart-deckgl](https://github.com/apache-superset/superset-ui-plugins-deckgl/tree/master/packages/superset-ui-legacy-preset-chart-deckgl) | [![Version](https://img.shields.io/npm/v/@superset-ui/legacy-preset-chart-deckgl.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/legacy-preset-chart-deckgl.svg?style=flat-square) | | [@superset-ui/legacy-preset-chart-deckgl](https://github.com/apache-superset/superset-ui-plugins-deckgl/tree/master/packages/superset-ui-legacy-preset-chart-deckgl) | [![Version](https://img.shields.io/npm/v/@superset-ui/legacy-preset-chart-deckgl.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/legacy-preset-chart-deckgl.svg?style=flat-square) |
## Contribution and development guide ## Contribution and development guide
Please read the [contributing guidelines](https://github.com/apache-superset/superset-ui/blob/master/CONTRIBUTING.md) which include development environment setup Please read the
and other things you should know about coding in this repo. [contributing guidelines](https://github.com/apache-superset/superset-ui/blob/master/CONTRIBUTING.md)
which include development environment setup and other things you should know about coding in this
repo.
### License ### License

View File

@ -4,25 +4,28 @@
"description": "Superset UI Plugins - deck.gl", "description": "Superset UI Plugins - deck.gl",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "yarn build:cjs && yarn build:esm && yarn run type:dts && yarn build:assets", "build": "yarn babel && yarn type && yarn build:assets",
"build:cjs": "NODE_ENV=production beemo babel --extensions=\".js,.jsx,.ts,.tsx\" ./src --out-dir lib/ --delete-dir-on-start --minify --workspaces=\"@superset-ui/!(plugins-demo)\"", "babel": "yarn babel:cjs && yarn babel:esm",
"build:esm": "NODE_ENV=production beemo babel --extensions=\".js,.jsx,.ts,.tsx\" ./src --out-dir esm/ --delete-dir-on-start --esm --minify --workspaces=\"@superset-ui/!(plugins-demo)\"", "babel:cjs": "nimbus babel --clean --workspaces=\"@superset-ui/!(plugins-demo)\"",
"build:assets": "node ./buildAssets.js", "babel:esm": "nimbus babel --clean --workspaces=\"@superset-ui/!(plugins-demo)\" --esm",
"build:assets": "node ./scripts/buildAssets.js",
"clean": "rm -rf ./packages/**/{lib,esm}",
"commit": "superset-commit", "commit": "superset-commit",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"type": "NODE_ENV=production beemo typescript --workspaces=\"@superset-ui/((preset|plugin)-*)\" --noEmit", "format": "yarn prettier --write",
"type:dts": "NODE_ENV=production beemo typescript --workspaces=\"@superset-ui/((preset|plugin)-*)\" --emitDeclarationOnly", "jest": "NODE_ENV=test nimbus jest --coverage --verbose",
"lint": "beemo create-config prettier && beemo eslint \"./packages/*/{src,test,storybook}/**/*.{js,jsx,ts,tsx}\"", "lint": "nimbus eslint && nimbus prettier --check",
"lint:fix": "beemo create-config prettier && beemo eslint --fix \"./packages/*/{src,test,storybook}/**/*.{js,jsx,ts,tsx}\"", "lint:fix": "nimbus eslint --fix",
"jest": "beemo jest --color --coverage --react", "prettier": "nimbus prettier",
"test": "yarn type",
"test:watch": "yarn lint:fix && yarn jest --watch",
"type": "nimbus typescript --build --reference-workspaces",
"prepare-release": "git checkout master && git pull --rebase origin master && lerna bootstrap && yarn install && yarn test",
"prerelease": "yarn build",
"pretest": "yarn lint",
"release": "yarn prepare-release && lerna publish --exact && yarn postrelease",
"postrelease": "lerna run deploy-demo", "postrelease": "lerna run deploy-demo",
"prepare-release": "git checkout master && git pull --rebase origin master && lerna bootstrap && yarn run test", "storybook": "cd packages/superset-ui-plugins-demo && yarn storybook"
"prerelease": "yarn run build",
"pretest": "yarn run lint",
"prettier": "beemo prettier \"./packages/*/{src,test,storybook}/**/*.{js,jsx,ts,tsx,json,md}\"",
"release": "yarn run prepare-release && lerna publish && yarn run postrelease",
"test": "yarn run type && yarn run jest",
"test:watch": "yarn run lint:fix && beemo create-config jest --react && jest --watch"
}, },
"repository": "https://github.com/apache-superset/superset-ui-plugins-deckgl.git", "repository": "https://github.com/apache-superset/superset-ui-plugins-deckgl.git",
"keywords": [ "keywords": [
@ -33,65 +36,99 @@
"analysis", "analysis",
"visualization", "visualization",
"react", "react",
"d3", "d3"
"data-ui",
"vx"
], ],
"license": "Apache-2.0", "license": "Apache-2.0",
"devDependencies": { "devDependencies": {
"@superset-ui/build-config": "^0.1.0", "@airbnb/config-babel": "^2.1.3",
"@superset-ui/chart": "^0.12.1", "@airbnb/config-eslint": "^2.1.3",
"@superset-ui/chart-composition": "^0.12.1", "@airbnb/config-jest": "^2.1.3",
"@superset-ui/color": "^0.12.1", "@airbnb/config-prettier": "^2.0.4",
"@airbnb/config-typescript": "^2.1.2",
"@airbnb/nimbus": "^2.1.3",
"@babel/plugin-transform-runtime": "^7.8.3",
"@superset-ui/commit-config": "^0.0.9", "@superset-ui/commit-config": "^0.0.9",
"@superset-ui/connection": "^0.12.0", "@superset-ui/superset-ui": "^0.12.5",
"@superset-ui/core": "^0.12.0", "@types/enzyme": "^3.10.3",
"@superset-ui/dimension": "^0.12.0", "@types/jest": "^25.1.1",
"@superset-ui/number-format": "^0.12.1", "@types/jsdom": "^12.2.4",
"@superset-ui/query": "^0.12.2", "@types/react": "^16.9.0",
"@superset-ui/time-format": "^0.12.1", "@types/react-test-renderer": "^16.9.0",
"@superset-ui/translation": "^0.12.0",
"@types/react": "^16.8.8",
"core-js": "^3.0.1",
"csstype": "^2.6.3", "csstype": "^2.6.3",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.15.1",
"enzyme-to-json": "^3.4.3",
"fast-glob": "^3.0.1", "fast-glob": "^3.0.1",
"fs-extra": "^8.0.1", "fs-extra": "^8.0.1",
"husky": "^3.0.3", "husky": "^4.2.1",
"lerna": "^3.2.1", "jest-mock-console": "^1.0.0",
"lint-staged": "^9.2.1", "lerna": "^3.15.0",
"luma.gl": "^7.3.0", "lint-staged": "^10.0.7",
"react": "^16.6.0", "luma.gl": "^7.3.2",
"react-dom": "^16.6.0", "react-test-renderer": "^16.9.0",
"yarn": "^1.9.4" "react-dom": "^16.9.0",
"react": "^16.9.0"
}, },
"engines": { "engines": {
"node": ">=8.10.0" "node": ">=10.10.0",
}, "npm": ">=6.8.0",
"beemo": { "yarn": ">=1.13.0"
"module": "@superset-ui/build-config",
"drivers": [
"babel",
"eslint",
{
"driver": "jest",
"env": {
"NODE_ENV": "test"
}
},
"prettier",
"typescript"
],
"typescript": {
"compilerOptions": {
"typeRoots": [
"../../node_modules/vega-lite/typings"
]
}
}
}, },
"workspaces": [ "workspaces": [
"./packages/*" "./packages/*"
], ],
"nimbus": {
"drivers": [
"babel",
"eslint",
"jest",
"prettier",
"typescript"
],
"settings": {
"library": true,
"react": true,
"next": true,
"env": {
"corejs": 3,
"useBuiltIns": "usage"
}
},
"babel": {
"plugins": [["@babel/plugin-transform-runtime", { "corejs": 3 }]]
},
"jest": {
"timers": "real",
"setupFilesAfterEnv": [
"@airbnb/config-jest/enzyme"
],
"coverageThreshold": {
"global": {
"branches": 0,
"functions": 0,
"lines": 0,
"statements": 0
}
}
},
"eslint": {
"overrides": [
{
"files": "*.{js,jsx,ts,tsx}",
"rules": {
"react/jsx-no-literals": "off",
"prefer-exponentiation-operator": "off",
"@typescript-eslint/no-explicit-any": ["warn", { "fixToUnknown": false }]
}
}
]
},
"typescript": {
"compilerOptions": {
"emitDeclarationOnly": true
}
}
},
"husky": { "husky": {
"hooks": { "hooks": {
"pre-commit": "lint-staged", "pre-commit": "lint-staged",
@ -100,7 +137,7 @@
}, },
"lint-staged": { "lint-staged": {
"./packages/*/{src,test,storybook}/**/*.{js,jsx,ts,tsx,json,md}": [ "./packages/*/{src,test,storybook}/**/*.{js,jsx,ts,tsx,json,md}": [
"yarn run prettier --write", "yarn prettier --write",
"git add" "git add"
] ]
} }

View File

@ -1,7 +1,6 @@
/* eslint-disable react/jsx-handler-names */ /* eslint-disable react/jsx-sort-default-props */
/* eslint-disable react/destructuring-assignment */ /* eslint-disable react/sort-prop-types */
/* eslint-disable react/forbid-prop-types */ /* eslint-disable react/forbid-prop-types */
/* eslint-disable sort-keys */
/* eslint-disable react/require-default-props */ /* eslint-disable react/require-default-props */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,17 +1,9 @@
/* eslint-disable react/sort-prop-types */
/* eslint-disable react/require-default-props */ /* eslint-disable react/require-default-props */
/* eslint-disable react/no-unused-prop-types */ /* eslint-disable react/no-unused-prop-types */
/* eslint-disable react/forbid-prop-types */
/* eslint-disable react/no-access-state-in-setstate */ /* eslint-disable react/no-access-state-in-setstate */
/* eslint-disable compat/compat */
/* eslint-disable react/destructuring-assignment */
/* eslint-disable react/jsx-handler-names */
/* eslint-disable react/no-unsafe */
/* eslint-disable react/sort-comp */
/* eslint-disable camelcase */ /* eslint-disable camelcase */
/* eslint-disable no-prototype-builtins */ /* eslint-disable no-prototype-builtins */
/* eslint-disable sort-keys */
/* eslint-disable no-eq-null */
/* eslint-disable no-magic-numbers */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -107,6 +99,7 @@ export default class CategoricalDeckGLContainer extends React.PureComponent {
}); });
} }
// eslint-disable-next-line class-methods-use-this
getStateFromProps(props, state) { getStateFromProps(props, state) {
const features = props.payload.data.features || []; const features = props.payload.data.features || [];
const timestamps = features.map(f => f.__timestamp); const timestamps = features.map(f => f.__timestamp);
@ -178,6 +171,7 @@ export default class CategoricalDeckGLContainer extends React.PureComponent {
return [getLayer(fd, filteredPayload, onAddFilter, setTooltip)]; return [getLayer(fd, filteredPayload, onAddFilter, setTooltip)];
} }
// eslint-disable-next-line class-methods-use-this
addColor(data, fd) { addColor(data, fd) {
const c = fd.color_picker || { r: 0, g: 0, b: 0, a: 1 }; const c = fd.color_picker || { r: 0, g: 0, b: 0, a: 1 };
const colorFn = getScale(fd.color_scheme); const colorFn = getScale(fd.color_scheme);
@ -233,7 +227,6 @@ export default class CategoricalDeckGLContainer extends React.PureComponent {
end={this.state.end} end={this.state.end}
getStep={this.state.getStep} getStep={this.state.getStep}
values={this.state.values} values={this.state.values}
onValuesChange={this.onValuesChange}
disabled={this.state.disabled} disabled={this.state.disabled}
viewport={this.state.viewport} viewport={this.state.viewport}
mapboxApiAccessToken={this.props.mapboxApiKey} mapboxApiAccessToken={this.props.mapboxApiKey}

View File

@ -1,6 +1,6 @@
/* eslint-disable react/jsx-sort-default-props */
/* eslint-disable react/sort-prop-types */
/* eslint-disable react/jsx-handler-names */ /* eslint-disable react/jsx-handler-names */
/* eslint-disable react/destructuring-assignment */
/* eslint-disable sort-keys */
/* eslint-disable react/forbid-prop-types */ /* eslint-disable react/forbid-prop-types */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
@ -98,13 +98,13 @@ export default class DeckGLContainer extends React.Component {
return ( return (
<div style={{ position: 'relative', width, height: adjustedHeight }}> <div style={{ position: 'relative', width, height: adjustedHeight }}>
<DeckGL <DeckGL
initWebGLParameters
controller
width={width} width={width}
height={adjustedHeight} height={adjustedHeight}
layers={layers} layers={layers}
viewState={viewState} viewState={viewState}
onViewStateChange={this.onViewStateChange} onViewStateChange={this.onViewStateChange}
initWebGLParameters
controller
> >
<StaticMap <StaticMap
mapStyle={this.props.mapStyle} mapStyle={this.props.mapStyle}

View File

@ -1,13 +1,8 @@
/* eslint-disable compat/compat */ /* eslint-disable react/jsx-sort-default-props */
/* eslint-disable react/no-unsafe */ /* eslint-disable react/sort-prop-types */
/* eslint-disable promise/always-return */
/* eslint-disable react/jsx-handler-names */ /* eslint-disable react/jsx-handler-names */
/* eslint-disable react/no-access-state-in-setstate */ /* eslint-disable react/no-access-state-in-setstate */
/* eslint-disable react/sort-comp */
/* eslint-disable camelcase */ /* eslint-disable camelcase */
/* eslint-disable react/destructuring-assignment */
/* eslint-disable sort-keys */
/* eslint-disable react/forbid-prop-types */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -126,10 +121,10 @@ class DeckMulti extends React.PureComponent {
<DeckGLContainer <DeckGLContainer
mapboxApiAccessToken={payload.data.mapboxApiKey} mapboxApiAccessToken={payload.data.mapboxApiKey}
viewport={this.state.viewport || this.props.viewport} viewport={this.state.viewport || this.props.viewport}
onViewportChange={this.onViewportChange}
layers={layers} layers={layers}
mapStyle={formData.mapbox_style} mapStyle={formData.mapbox_style}
setControlValue={setControlValue} setControlValue={setControlValue}
onViewportChange={this.onViewportChange}
/> />
); );
} }

View File

@ -17,10 +17,9 @@
* under the License. * under the License.
*/ */
.BootstrapSliderWrapper .slider-selection { .BootstrapSliderWrapper .slider-selection {
background: #efefef; background: #efefef;
} }
.BootstrapSliderWrapper .slider-handle { .BootstrapSliderWrapper .slider-handle {
background: #b3b3b3; background: #b3b3b3;
} }

View File

@ -17,28 +17,28 @@
* under the License. * under the License.
*/ */
div.legend { div.legend {
font-size: 90%; font-size: 90%;
position: absolute; position: absolute;
background: #fff; background: #fff;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.15); box-shadow: 0 0 4px rgba(0, 0, 0, 0.15);
margin: 24px; margin: 24px;
padding: 12px 20px; padding: 12px 20px;
outline: none; outline: none;
overflow-y: scroll; overflow-y: scroll;
max-height: 200px; max-height: 200px;
} }
ul.categories { ul.categories {
list-style: none; list-style: none;
padding-left: 0; padding-left: 0;
margin: 0; margin: 0;
} }
ul.categories li a { ul.categories li a {
color: rgb(51, 51, 51); color: rgb(51, 51, 51);
text-decoration: none; text-decoration: none;
} }
ul.categories li a span { ul.categories li a span {
margin-right: 10px; margin-right: 10px;
} }

View File

@ -1,7 +1,6 @@
/* eslint-disable react/destructuring-assignment */ /* eslint-disable react/jsx-sort-default-props */
/* eslint-disable react/sort-prop-types */
/* eslint-disable jsx-a11y/anchor-is-valid */ /* eslint-disable jsx-a11y/anchor-is-valid */
/* eslint-disable sort-keys */
/* eslint-disable react/forbid-prop-types */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -17,30 +17,30 @@
* under the License. * under the License.
*/ */
.play-slider { .play-slider {
display: flex; display: flex;
height: 40px; height: 40px;
width: 100%; width: 100%;
margin: 0; margin: 0;
} }
.play-slider-controls { .play-slider-controls {
flex: 0 0 80px; flex: 0 0 80px;
text-align: middle; text-align: middle;
} }
.play-slider-scrobbler { .play-slider-scrobbler {
flex: 1; flex: 1;
} }
.slider.slider-horizontal { .slider.slider-horizontal {
width: 100% !important; width: 100% !important;
} }
.slider-button { .slider-button {
color: #b3b3b3; color: #b3b3b3;
margin-right: 5px; margin-right: 5px;
} }
div.slider > div.tooltip.tooltip-main.top.in { div.slider > div.tooltip.tooltip-main.top.in {
margin-left: 0 !important; margin-left: 0 !important;
} }

View File

@ -1,10 +1,9 @@
/* eslint-disable react/jsx-sort-default-props */
/* eslint-disable react/sort-prop-types */
/* eslint-disable react/jsx-handler-names */ /* eslint-disable react/jsx-handler-names */
/* eslint-disable jsx-a11y/click-events-have-key-events */ /* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable jsx-a11y/no-static-element-interactions */ /* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable no-negated-condition */ /* eslint-disable no-negated-condition */
/* eslint-disable react/destructuring-assignment */
/* eslint-disable no-eq-null */
/* eslint-disable sort-keys */
/* eslint-disable react/forbid-prop-types */ /* eslint-disable react/forbid-prop-types */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
.deckgl-tooltip > div { .deckgl-tooltip > div {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }

View File

@ -1,11 +1,7 @@
/* eslint-disable react/sort-prop-types */
/* eslint-disable react/jsx-handler-names */ /* eslint-disable react/jsx-handler-names */
/* eslint-disable react/destructuring-assignment */
/* eslint-disable react/sort-comp */
/* eslint-disable camelcase */ /* eslint-disable camelcase */
/* eslint-disable react/no-unsafe */
/* eslint-disable sort-keys */
/* eslint-disable react/no-unused-prop-types */ /* eslint-disable react/no-unused-prop-types */
/* eslint-disable react/forbid-prop-types */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -76,6 +72,7 @@ export function createDeckGLComponent(getLayer, getPoints) {
this.setState({ viewport }); this.setState({ viewport });
} }
// eslint-disable-next-line class-methods-use-this
computeLayer(props) { computeLayer(props) {
const { formData, payload, onAddFilter, setTooltip } = props; const { formData, payload, onAddFilter, setTooltip } = props;
@ -93,9 +90,9 @@ export function createDeckGLComponent(getLayer, getPoints) {
layers={[layer]} layers={[layer]}
mapStyle={formData.mapbox_style} mapStyle={formData.mapbox_style}
setControlValue={setControlValue} setControlValue={setControlValue}
onViewportChange={this.onViewportChange}
width={width} width={width}
height={height} height={height}
onViewportChange={this.onViewportChange}
/> />
); );
} }
@ -108,16 +105,7 @@ export function createDeckGLComponent(getLayer, getPoints) {
export function createCategoricalDeckGLComponent(getLayer, getPoints) { export function createCategoricalDeckGLComponent(getLayer, getPoints) {
function Component(props) { function Component(props) {
const { const { formData, payload, setControlValue, setTooltip, viewport, width, height } = props;
formData,
payload,
setControlValue,
onAddFilter,
setTooltip,
viewport,
width,
height,
} = props;
return ( return (
<CategoricalDeckGLContainer <CategoricalDeckGLContainer
@ -127,7 +115,6 @@ export function createCategoricalDeckGLComponent(getLayer, getPoints) {
viewport={viewport} viewport={viewport}
getLayer={getLayer} getLayer={getLayer}
payload={payload} payload={payload}
onAddFilter={onAddFilter}
setTooltip={setTooltip} setTooltip={setTooltip}
getPoints={getPoints} getPoints={getPoints}
width={width} width={width}

View File

@ -1,5 +1,3 @@
/* eslint-disable no-magic-numbers */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -1,7 +1,5 @@
/* eslint-disable no-magic-numbers */ /* eslint-disable react/sort-prop-types */
/* eslint-disable react/forbid-prop-types */
/* eslint-disable react/no-array-index-key */ /* eslint-disable react/no-array-index-key */
/* eslint-disable sort-keys */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -1,5 +1,3 @@
/* eslint-disable no-magic-numbers */
/* eslint-disable sort-keys */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -1,5 +1,3 @@
/* eslint-disable no-magic-numbers */
/* eslint-disable sort-keys */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -1,6 +1,4 @@
/* eslint-disable react/no-array-index-key */ /* eslint-disable react/no-array-index-key */
/* eslint-disable no-magic-numbers */
/* eslint-disable sort-keys */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -1,9 +1,6 @@
/* eslint-disable react/sort-prop-types */
/* eslint-disable react/jsx-handler-names */ /* eslint-disable react/jsx-handler-names */
/* eslint-disable react/destructuring-assignment */
/* eslint-disable react/no-access-state-in-setstate */ /* eslint-disable react/no-access-state-in-setstate */
/* eslint-disable react/forbid-prop-types */
/* eslint-disable no-magic-numbers */
/* eslint-disable sort-keys */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -41,7 +38,7 @@ import sandboxedEval from '../../utils/sandbox';
const DOUBLE_CLICK_TRESHOLD = 250; // milliseconds const DOUBLE_CLICK_TRESHOLD = 250; // milliseconds
function getPoints(features) { function getPoints(features) {
return features.map(d => d.polygon).flat(); return features.flatMap(d => d.polygon);
} }
function getElevation(d, colorScaler) { function getElevation(d, colorScaler) {
@ -77,10 +74,9 @@ export function getLayer(formData, payload, onAddFilter, setTooltip, selected, o
const sc = fd.stroke_color_picker; const sc = fd.stroke_color_picker;
let data = [...payload.data.features]; let data = [...payload.data.features];
// eslint-disable-next-line no-eq-null
if (filters != null) { if (filters != null) {
filters.forEach(f => { filters.forEach(f => {
data = data.filter(f); data = data.filter(x => f(x));
}); });
} }
@ -101,14 +97,14 @@ export function getLayer(formData, payload, onAddFilter, setTooltip, selected, o
// when polygons are selected, reduce the opacity of non-selected polygons // when polygons are selected, reduce the opacity of non-selected polygons
const colorScaler = d => { const colorScaler = d => {
const baseColor = baseColorScaler(d); const baseColor = baseColorScaler(d);
if (selected.length > 0 && selected.indexOf(d[fd.line_column]) === -1) { if (selected.length > 0 && !selected.includes(d[fd.line_column])) {
baseColor[3] /= 2; baseColor[3] /= 2;
} }
return baseColor; return baseColor;
}; };
const tooltipContentGenerator = const tooltipContentGenerator =
fd.line_column && fd.metric && ['geohash', 'zipcode'].indexOf(fd.line_type) >= 0 fd.line_column && fd.metric && ['geohash', 'zipcode'].includes(fd.line_type)
? setTooltipContent(fd) ? setTooltipContent(fd)
: undefined; : undefined;
@ -265,12 +261,12 @@ class DeckGLPolygon extends React.Component {
return ( return (
<div style={{ position: 'relative' }}> <div style={{ position: 'relative' }}>
<AnimatableDeckGLContainer <AnimatableDeckGLContainer
aggregation
getLayers={this.getLayers} getLayers={this.getLayers}
start={start} start={start}
end={end} end={end}
getStep={getStep} getStep={getStep}
values={values} values={values}
onValuesChange={this.onValuesChange}
disabled={disabled} disabled={disabled}
viewport={viewport} viewport={viewport}
width={this.props.width} width={this.props.width}
@ -278,7 +274,8 @@ class DeckGLPolygon extends React.Component {
mapboxApiAccessToken={payload.data.mapboxApiKey} mapboxApiAccessToken={payload.data.mapboxApiKey}
mapStyle={formData.mapbox_style} mapStyle={formData.mapbox_style}
setControlValue={setControlValue} setControlValue={setControlValue}
aggregation onValuesChange={this.onValuesChange}
onViewportChange={this.onViewportChange}
> >
{formData.metric !== null && ( {formData.metric !== null && (
<Legend <Legend

View File

@ -1,5 +1,3 @@
/* eslint-disable no-magic-numbers */
/* eslint-disable sort-keys */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -1,8 +1,5 @@
/* eslint-disable react/sort-prop-types */
/* eslint-disable react/jsx-handler-names */ /* eslint-disable react/jsx-handler-names */
/* eslint-disable react/destructuring-assignment */
/* eslint-disable no-magic-numbers */
/* eslint-disable sort-keys */
/* eslint-disable react/forbid-prop-types */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -63,10 +60,9 @@ export function getLayer(formData, payload, onAddFilter, setTooltip, selected, o
data = jsFnMutator(data); data = jsFnMutator(data);
} }
// eslint-disable-next-line no-eq-null
if (filters != null) { if (filters != null) {
filters.forEach(f => { filters.forEach(f => {
data = data.filter(f); data = data.filter(x => f(x));
}); });
} }
@ -179,12 +175,12 @@ class DeckGLScreenGrid extends React.PureComponent {
return ( return (
<div> <div>
<AnimatableDeckGLContainer <AnimatableDeckGLContainer
aggregation
getLayers={this.getLayers} getLayers={this.getLayers}
start={this.state.start} start={this.state.start}
end={this.state.end} end={this.state.end}
getStep={this.state.getStep} getStep={this.state.getStep}
values={this.state.values} values={this.state.values}
onValuesChange={this.onValuesChange}
disabled={this.state.disabled} disabled={this.state.disabled}
viewport={this.state.viewport} viewport={this.state.viewport}
width={this.props.width} width={this.props.width}
@ -192,7 +188,8 @@ class DeckGLScreenGrid extends React.PureComponent {
mapboxApiAccessToken={payload.data.mapboxApiKey} mapboxApiAccessToken={payload.data.mapboxApiKey}
mapStyle={formData.mapbox_style} mapStyle={formData.mapbox_style}
setControlValue={setControlValue} setControlValue={setControlValue}
aggregation onValuesChange={this.onValuesChange}
onViewportChange={this.onViewportChange}
/> />
</div> </div>
); );

View File

@ -1,4 +1,3 @@
/* eslint-disable no-magic-numbers */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -61,7 +60,10 @@ export function getBounds(points) {
const latBounds = latExt[0] === latExt[1] ? getLatBoundsForSingleCoordinate(latExt) : latExt; const latBounds = latExt[0] === latExt[1] ? getLatBoundsForSingleCoordinate(latExt) : latExt;
const lngBounds = lngExt[0] === lngExt[1] ? getLngBoundsForSingleCoordinate(lngExt) : lngExt; const lngBounds = lngExt[0] === lngExt[1] ? getLngBoundsForSingleCoordinate(lngExt) : lngExt;
return [[lngBounds[0], latBounds[0]], [lngBounds[1], latBounds[1]]]; return [
[lngBounds[0], latBounds[0]],
[lngBounds[1], latBounds[1]],
];
} }
export function fitViewport(viewport, points, padding = 10) { export function fitViewport(viewport, points, padding = 10) {
@ -77,9 +79,9 @@ export function fitViewport(viewport, points, padding = 10) {
width: viewport.width, width: viewport.width,
}), }),
}; };
} catch (e) { } catch (error) {
/* eslint no-console: 0 */ /* eslint no-console: 0 */
console.error('Could not auto zoom', e); console.error('Could not auto zoom', error);
return viewport; return viewport;
} }
@ -153,5 +155,5 @@ export function getAggFunc(type = 'sum', accessor = null) {
return arr => d3func(arr); return arr => d3func(arr);
} }
return arr => d3func(arr.map(accessor)); return arr => d3func(arr.map(x => accessor(x)));
} }

View File

@ -1,4 +1,3 @@
/* eslint-disable sort-keys */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -1,4 +1,3 @@
/* eslint-disable no-magic-numbers */
/* eslint-disable no-negated-condition */ /* eslint-disable no-negated-condition */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
@ -44,7 +43,7 @@ export function getBreakPoints(
const precision = delta === 0 ? 0 : Math.max(0, Math.ceil(Math.log10(1 / delta))); const precision = delta === 0 ? 0 : Math.max(0, Math.ceil(Math.log10(1 / delta)));
const extraBucket = maxValue > maxValue.toFixed(precision) ? 1 : 0; const extraBucket = maxValue > maxValue.toFixed(precision) ? 1 : 0;
return Array(numBuckets + 1 + extraBucket) return new Array(numBuckets + 1 + extraBucket)
.fill() .fill()
.map((_, i) => (minValue + i * delta).toFixed(precision)); .map((_, i) => (minValue + i * delta).toFixed(precision));
} }
@ -111,7 +110,7 @@ export function getBreakPointColorScaler(
if (maskPoint(v)) { if (maskPoint(v)) {
c[3] = 0; c[3] = 0;
} else { } else {
c[3] = (opacity / 100.0) * 255; c[3] = (opacity / 100) * 255;
} }
return c; return c;

View File

@ -1,4 +1,3 @@
/* eslint-disable no-magic-numbers */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -6,7 +6,7 @@ const MAX_URL_LENGTH = 8000;
export function getURIDirectory(formData, endpointType = 'base') { export function getURIDirectory(formData, endpointType = 'base') {
// Building the directory part of the URI // Building the directory part of the URI
let directory = '/superset/explore/'; let directory = '/superset/explore/';
if (['json', 'csv', 'query', 'results', 'samples'].indexOf(endpointType) >= 0) { if (['json', 'csv', 'query', 'results', 'samples'].includes(endpointType)) {
directory = '/superset/explore_json/'; directory = '/superset/explore_json/';
} }

View File

@ -1,5 +1,3 @@
/* eslint-disable no-restricted-properties */
/* eslint-disable no-magic-numbers */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -33,15 +31,20 @@ const METER_TO_MILE = 1609.34;
export function unitToRadius(unit, num) { export function unitToRadius(unit, num) {
if (unit === 'square_m') { if (unit === 'square_m') {
return Math.sqrt(num / Math.PI); return Math.sqrt(num / Math.PI);
} else if (unit === 'radius_m') { }
if (unit === 'radius_m') {
return num; return num;
} else if (unit === 'radius_km') { }
if (unit === 'radius_km') {
return num * 1000; return num * 1000;
} else if (unit === 'radius_miles') { }
if (unit === 'radius_miles') {
return num * METER_TO_MILE; return num * METER_TO_MILE;
} else if (unit === 'square_km') { }
if (unit === 'square_km') {
return Math.sqrt(num / Math.PI) * 1000; return Math.sqrt(num / Math.PI) * 1000;
} else if (unit === 'square_miles') { }
if (unit === 'square_miles') {
return Math.sqrt(num / Math.PI) * METER_TO_MILE; return Math.sqrt(num / Math.PI) * METER_TO_MILE;
} }
@ -55,7 +58,7 @@ export function kmToPixels(kilometers, latitude, zoomLevel) {
// Algorithm from: https://wiki.openstreetmap.org/wiki/Zoom_levels // Algorithm from: https://wiki.openstreetmap.org/wiki/Zoom_levels
const latitudeRad = latitude * (Math.PI / 180); const latitudeRad = latitude * (Math.PI / 180);
// Seems like the zoomLevel is off by one // Seems like the zoomLevel is off by one
const kmPerPixel = (EARTH_CIRCUMFERENCE_KM * Math.cos(latitudeRad)) / Math.pow(2, zoomLevel + 9); const kmPerPixel = (EARTH_CIRCUMFERENCE_KM * Math.cos(latitudeRad)) / 2 ** (zoomLevel + 9);
return roundDecimal(kilometers / kmPerPixel, 2); return roundDecimal(kilometers / kmPerPixel, 2);
} }

View File

@ -36,7 +36,7 @@ export function safeStringify(object) {
try { try {
// Quick deep copy to duplicate if this is a repeat rather than a circle. // Quick deep copy to duplicate if this is a repeat rather than a circle.
return JSON.parse(JSON.stringify(value)); return JSON.parse(JSON.stringify(value));
} catch (err) { } catch (error) {
// Discard key if value cannot be duplicated. // Discard key if value cannot be duplicated.
return; return;
} }

View File

@ -1,5 +1,3 @@
/* eslint-disable sort-keys */
/* eslint-disable no-magic-numbers */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -1,8 +1,4 @@
/* eslint-disable sort-keys */
/* eslint-disable babel/no-invalid-this */
/* eslint-disable no-eq-null */
/* eslint-disable no-negated-condition */ /* eslint-disable no-negated-condition */
/* eslint-disable func-names */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -52,7 +48,8 @@ export function truncate(timestamp, step) {
const difference = part - explodedLowerBound[i]; const difference = part - explodedLowerBound[i];
return part - ((part - truncatePartTo[i]) % difference); return part - ((part - truncatePartTo[i]) % difference);
} else if (i < firstDiffIndex || firstDiffIndex === -1) { }
if (i < firstDiffIndex || firstDiffIndex === -1) {
return part; return part;
} }
@ -85,7 +82,7 @@ export function getPlaySliderParams(timestamps, timeGrain) {
let step; let step;
let reference; let reference;
if (timeGrain.indexOf('/') !== -1) { if (timeGrain.includes('/')) {
// Here, time grain is a time interval instead of a simple duration, either // Here, time grain is a time interval instead of a simple duration, either
// `reference/duration` or `duration/reference`. We need to parse the // `reference/duration` or `duration/reference`. We need to parse the
// duration and make sure that start and end are in the right places. For // duration and make sure that start and end are in the right places. For

View File

@ -1,5 +1,3 @@
/* eslint-disable no-magic-numbers */
/* eslint-disable no-restricted-properties */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -25,7 +23,7 @@ export function roundDecimal(number, precision) {
let roundedNumber; let roundedNumber;
if (precision) { if (precision) {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
roundedNumber = Math.round(number * (precision = Math.pow(10, precision))) / precision; roundedNumber = Math.round(number * (precision = 10 ** precision)) / precision;
} else { } else {
roundedNumber = Math.round(number); roundedNumber = Math.round(number);
} }

View File

@ -31,6 +31,7 @@
"mapbox-gl": "^0.53.0", "mapbox-gl": "^0.53.0",
"prop-types": "^15.6.0", "prop-types": "^15.6.0",
"react-palm": "^3.1.2", "react-palm": "^3.1.2",
"redux": "^4.0.5",
"shortid": "^2.2.15", "shortid": "^2.2.15",
"styled-components": "^4.4.0", "styled-components": "^4.4.0",
"viewport-mercator-project": "^6.1.1" "viewport-mercator-project": "^6.1.1"

View File

@ -1,12 +1,12 @@
/* eslint-disable react/sort-prop-types */
/* eslint-disable max-classes-per-file */
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable prefer-destructuring */ /* eslint-disable prefer-destructuring */
/* eslint-disable react/destructuring-assignment */
/* eslint-disable react/jsx-handler-names */ /* eslint-disable react/jsx-handler-names */
/* eslint-disable react/no-deprecated */ /* eslint-disable react/no-deprecated */
/* eslint-disable no-negated-condition */ /* eslint-disable no-negated-condition */
/* eslint-disable react/prop-types */ /* eslint-disable react/prop-types */
/* eslint-disable react/require-default-props */ /* eslint-disable react/require-default-props */
/* eslint-disable sort-keys */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -69,7 +69,7 @@ class Kepler extends React.PureComponent {
const { keplerGl } = this.props; const { keplerGl } = this.props;
return KeplerGlSchema.getConfigToSave(keplerGl[this.state.keplerId]); return KeplerGlSchema.getConfigToSave(keplerGl[this.state.keplerId]);
} catch (e) { } catch (error) {
return null; return null;
} }
} }
@ -114,8 +114,8 @@ class Kepler extends React.PureComponent {
<div> <div>
<KeplerGl <KeplerGl
id={this.state.keplerId} id={this.state.keplerId}
onSaveMap={this.setMapConfig}
theme="light" theme="light"
onSaveMap={this.setMapConfig}
{...this.props} {...this.props}
/> />
</div> </div>
@ -128,12 +128,8 @@ Kepler.propTypes = propTypes;
const mapStateToProps = state => ({ keplerGl: state.keplerGl }); const mapStateToProps = state => ({ keplerGl: state.keplerGl });
const dispatchToProps = dispatch => ({ dispatch }); const dispatchToProps = dispatch => ({ dispatch });
const KeplerConnected = connect( const KeplerConnected = connect(mapStateToProps, dispatchToProps)(Kepler);
mapStateToProps,
dispatchToProps,
)(Kepler);
// eslint-disable-next-line react/no-multi-comp
export default class SubApp extends React.Component { export default class SubApp extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);

View File

@ -1,4 +1,3 @@
/* eslint-disable sort-keys */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -1,9 +1,3 @@
/* eslint-disable babel/new-cap */
/* eslint-disable babel/no-invalid-this */
/* eslint-disable compat/compat */
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable no-magic-numbers */
/* eslint-disable sort-keys */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -68,6 +62,7 @@ const rateLimitedUpdateConfigControl = RateLimit(updateConfigControl, 1000);
export default function getKeplerStore(setControlValue) { export default function getKeplerStore(setControlValue) {
// Using react-palm middleware to intercept changes and // Using react-palm middleware to intercept changes and
// save the state into the config control as text // save the state into the config control as text
// eslint-disable-next-line unicorn/consistent-function-scoping
const stateChangeMiddleware = store => next => action => { const stateChangeMiddleware = store => next => action => {
const returnValue = next(action); const returnValue = next(action);
rateLimitedUpdateConfigControl(store, setControlValue); rateLimitedUpdateConfigControl(store, setControlValue);

View File

@ -1,4 +1,3 @@
/* eslint-disable sort-keys */
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file