Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#10005 update babel configuration #10006

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@
]
},
"devDependencies": {
"@babel/core": "7.8.7",
"@babel/plugin-proposal-class-properties": "7.8.3",
"@babel/core": "7.23.9",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/preset-env": "7.8.7",
"@babel/preset-react": "7.8.3",
"@babel/runtime": "7.11.2",
"@babel/plugin-transform-regenerator": "7.23.3",
"@babel/preset-env": "7.23.9",
"@babel/preset-react": "7.23.3",
"@babel/runtime": "7.23.9",
"@geosolutions/acorn-jsx": "4.0.2",
"@geosolutions/jsdoc": "3.4.4",
"@geosolutions/mocha": "6.2.1-3",
"@mapstore/eslint-config-mapstore": "1.0.5",
"@mapstore/eslint-config-mapstore": "1.0.6",
"@testing-library/react": "12.1.5",
"axios-mock-adapter": "1.16.0",
"babel-loader": "8.0.5",
Expand All @@ -66,10 +67,10 @@
"download-cli": "1.0.1",
"dynamic-public-path-webpack-plugin": "1.0.4",
"escope": "3.2.0",
"eslint": "7.8.1",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-no-only-tests": "2.3.1",
"eslint-plugin-react": "3.3.2",
"eslint": "7.32.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-only-tests": "2.6.0",
"eslint-plugin-react": "3.16.1",
"expect": "1.20.1",
"file-loader": "2.0.0",
"glob": "7.1.1",
Expand Down
58 changes: 12 additions & 46 deletions utility/eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ module.exports = {
"react/jsx-no-duplicate-props": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
"react/display-name": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
"react/jsx-boolean-value": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
"react/jsx-quotes": [2, "double"], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-quotes.md
"jsx-quotes": [2, "prefer-double"], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-quotes.md
"react/jsx-no-undef": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
"react/jsx-sort-props": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
"react/jsx-sort-prop-types": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-prop-types.md
Expand All @@ -199,54 +199,20 @@ module.exports = {
"react/no-did-update-set-state": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
"react/no-multi-comp": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
"react/no-unknown-property": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
"react/prop-types": [2, { "ignore": ["children"] }], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
"react/prop-types": [0, { "ignore": ["children"] }], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
"react/react-in-jsx-scope": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
"react/self-closing-comp": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
"react/wrap-multilines": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md
"react/sort-comp": [2, { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
"order": [
"displayName",
"propTypes",
"inheritedPropTypes",
"contextTypes",
"childContextTypes",
"mixins",
"statics",
"defaultProps",
"constructor",
"getDefaultProps",
"/^state$/",
"getInitialState",
"getChildContext",
"UNSAFE_componentWillMount",
"componentWillMount",
"componentDidMount",
"UNSAFE_componentWillReceiveProps",
"componentWillReceiveProps",
"shouldComponentUpdate",
"UNSAFE_componentWillUpdate",
"componentWillUpdate",
"componentDidUpdate",
"componentWillUnmount",
"/^on.+$/",
"/^get.+$/",
"/^render.+$/",
"render"
],
// CUSTOM
// prevent to `import _ from 'lodash';`. Allows `import {get} from 'lodash';` or `import get from 'lodash/get';`
// for bundle size
"no-restricted-imports": [2,
{
"name": "lodash",
"importNames": ["default"],
"message": "Please use the default import from 'lodash/functionName' instead."
}
],
// prevent to `const _ = require('lodash')`. Allows `const get = require('lodash/get');`
// for bundle size
"no-restricted-modules": [2, { "paths": ["lodash", "!lodash/*"] }]
}]
"no-restricted-imports": [2,
{
"name": "lodash",
"importNames": ["default"],
"message": "Please use the default import from 'lodash/functionName' instead."
}
],
// prevent to `const _ = require('lodash')`. Allows `const get = require('lodash/get');`
// for bundle size
"no-restricted-modules": [2, { "paths": ["lodash", "!lodash/*"] }]
}
};

2 changes: 1 addition & 1 deletion utility/eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mapstore/eslint-config-mapstore",
"version": "1.0.5",
"version": "1.0.6",
"private": false,
"description": "ESLint Configuration for MapStore project",
"author": "GeoSolutions S.a.s.",
Expand Down
1 change: 1 addition & 0 deletions web/client/api/WFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const getFeatureLayer = (layer, {version = "1.1.0", filters, proj, outpu
.concat(featureGridFilter ? featureGridFilter : []);
const reqBody = wfsGetFeature(query(
typeName,
// TODO: insert propertyName before filter to limit attributes to return
allFilters.length > 0
? filter(
and(
Expand Down
6 changes: 3 additions & 3 deletions web/client/components/TOC/fragments/settings/FeatureInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export default class extends React.Component {
const getSupportedFormat = supportedFormatRequests[this.props.element.type];
// we dont know supported infoFormats yet
if (getSupportedFormat && this.props.element.url && !this.props.element.infoFormats || this.props.element.infoFormats?.length === 0) {
this.setState({ loading: true });
this.setState({ loading: true }); // eslint-disable-line -- TODO: need to be fixed
getSupportedFormat(this.props.element.url, true)
.then(({ infoFormats }) => {
this.props.onChange("infoFormats", infoFormats);
this.setState({ loading: false });
this.setState({ loading: false }); // eslint-disable-line -- TODO: need to be fixed
})
.catch(() => {
this.setState({ loading: false });
this.setState({ loading: false }); // eslint-disable-line -- TODO: need to be fixed
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion web/client/components/catalog/RecordItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class RecordItem extends React.Component {
componentDidMount() {
const notAvailable = getMessageById(this.context.messages, "catalog.notAvailable");
const record = this.props.record;
this.setState({visibleExpand: !this.props.hideExpand &&
this.setState({visibleExpand: !this.props.hideExpand && // eslint-disable-line -- TODO: need to be fixed
(
this.displayExpand() ||
// show expand if the template is not empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class LayoutComponent extends Component {

componentDidUpdate(prevProps) {
if (prevProps.expanded && !this.props.expanded) {
this.setState({
this.setState({ // eslint-disable-line -- TODO: need to be fixed
showModal: false,
linkTarget: '',
linkTitle: '',
Expand Down
4 changes: 1 addition & 3 deletions web/client/components/import/style/StylePanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ class StylePanel extends React.Component {
overrideAnnotation: false,
initialLayers: []
};

componentDidMount() {
this.setState({initialLayers: [...this.props.layers]});
this.setState({initialLayers: [...this.props.layers]}); // eslint-disable-line -- TODO: need to be fixed
}

getGeometryType = (geometry) => {
if (geometry && geometry.type === 'GeometryCollection') {
return geometry.geometries.reduce((previous, g) => {
Expand Down
2 changes: 1 addition & 1 deletion web/client/components/map/cesium/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class CesiumMap extends React.Component {
if (this.props.errorPanel) {
// override the default error message overlay
map.cesiumWidget.showErrorPanel = (title, message, error) => {
this.setState({ renderError: { title, message, error } });
this.setState({ renderError: { title, message, error } }); // eslint-disable-line -- TODO: need to be fixed
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class DateTimePicker extends Component {
if (prevProps.value !== this.props.value || prevProps.operator !== this.props.operator) {
const { value, operator } = this.props;
this.setDateFromValueProp(value, operator);
if (this.props.operator === 'isNull') this.setState({ inputValue: '', date: null });
if (this.props.operator === 'isNull') this.setState({ inputValue: '', date: null }); // eslint-disable-line -- TODO: need to be fixed
}
}

Expand Down
2 changes: 1 addition & 1 deletion web/client/components/misc/datetimepicker/Hours.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Hours extends Component {
state = { focusedItemIndex: -1, times: [] };

componentDidMount() {
this.setState({ times: getDates() });
this.setState({ times: getDates() }); // eslint-disable-line -- TODO: need to be fixed
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion web/client/components/resources/modals/Save.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class SaveModal extends React.Component {
!isEqual(this.props.errors, prevProps.errors) &&
this.state?.loading
) {
this.setState({ loading: false });
this.setState({ loading: false }); // eslint-disable-line -- TODO: need to be fixed
}
}

Expand Down
2 changes: 1 addition & 1 deletion web/client/components/share/ShareEmbed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ShareEmbed extends React.Component {

componentDidMount() {
if (this.props.sizeOptions && !isEqual(this.state.sizeOptions)) {
this.setState({sizeOptions: this.props.sizeOptions, selectedOption: this.props.selectedOption || 'Small'});
this.setState({sizeOptions: this.props.sizeOptions, selectedOption: this.props.selectedOption || 'Small'}); // eslint-disable-line -- TODO: need to be fixed
}
}

Expand Down
2 changes: 1 addition & 1 deletion web/client/components/styleeditor/WMSJsonLegendIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const icon = {
Text: ({ symbolizer }) => {
return (
<svg viewBox="0 0 16 16">
<text x="8" y="8" text-anchor="middle" alignment-baseline="middle" style={{
<text x="8" y="8" textAnchor="middle" alignment-baseline="middle" style={{ // eslint-disable-line -- TODO: need to be fixed
fontSize: symbolizer.size < 14 ? symbolizer.size : 14,
fill: symbolizer.color,
fontFamily: symbolizer?.font?.join(', '),
Expand Down
2 changes: 1 addition & 1 deletion web/client/libs/numeric-input/NumericInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class NumericInput extends Component {
this.refsInput.getValueAsNumber = () => this.state.value || 0;

this.refsInput.setValue = (value) => {
this.setState({
this.setState({ // eslint-disable-line -- TODO: need to be fixed
value: this._parse(value),
stringValue: value
});
Expand Down
4 changes: 2 additions & 2 deletions web/client/plugins/SidebarMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ class SidebarMenu extends React.Component {

if (visibleElements === 0 && !hidden) {
onDetach();
this.setState((state) => ({ ...state, hidden: true}));
this.setState((state) => ({ ...state, hidden: true})); // eslint-disable-line -- need to be fixed
} else if (visibleElements > 0 && hidden) {
onInit();
this.setState((state) => ({ ...state, hidden: false}));
this.setState((state) => ({ ...state, hidden: false})); // eslint-disable-line -- need to be fixed
}
}

Expand Down
2 changes: 1 addition & 1 deletion web/client/plugins/TOC/components/WMSLegend.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class WMSLegend extends React.Component {

componentDidMount() {
const containerWidth = this.containerRef.current && this.containerRef.current.clientWidth;
this.setState({ containerWidth, ...this.state });
this.setState({ containerWidth, ...this.state }); // eslint-disable-line -- TODO: need to be fixed
}

render() {
Expand Down
14 changes: 7 additions & 7 deletions web/client/utils/ogc/Filter/FilterBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
const {logical, spatial, comparison, literal, propertyName, valueReference, distance, lower, upper, func} = require('./operators');
const {filter, fidFilter} = require('./filter');
const {processOGCGeometry} = require("../GML");
const {castArray} = require('lodash');
import {logical, spatial, comparison, literal, propertyName, valueReference, distance, lower, upper, func} from './operators';
import {filter, fidFilter} from './filter';
import {processOGCGeometry} from "../GML";
import {castArray} from 'lodash';
// const isValidXML = (value, {filterNS, gmlNS}) => value.indexOf(`<${filterNS}:` === 0) || value.indexOf(`<${gmlNS}:`) === 0;
/**
* Returns OGC Filter Builder. The FilterBuilder returns the method to compose the filter.
Expand All @@ -17,7 +17,7 @@ const {castArray} = require('lodash');
* The property object have the methods listed as properies below.
* The builder provides all the methods to compose the filter (filter, and, or, not, property) to compose the filter.
* ```
* const filterBuilder = require('.../FilterBuilder');
* import filterBuilder from '.../FilterBuilder';
* const {filter, property, and, or, not} = filterBuilder({gmlVersion: "3.1.1"});
* filter(
* and(
Expand Down Expand Up @@ -105,7 +105,7 @@ const {castArray} = require('lodash');
* @prop {function} property.dwithin `property("P1").dwithin(geoJSONGeometry, 10, "m")` 2nd and 3rd params are optional
* @prop {function} property.contains `property("P1").contains(geoJSONGeometry)`
*/
module.exports = function({filterNS = "ogc", gmlVersion, wfsVersion = "1.1.0"} = {}) {
export default function({filterNS = "ogc", gmlVersion, wfsVersion = "1.1.0"} = {}) {
let gmlV = gmlVersion || "3.1.1";

const getGeom = (geom) => processOGCGeometry(gmlV, geom);
Expand Down Expand Up @@ -164,4 +164,4 @@ module.exports = function({filterNS = "ogc", gmlVersion, wfsVersion = "1.1.0"} =
}
};

};
}
6 changes: 3 additions & 3 deletions web/client/utils/ogc/Filter/__tests__/FilterBuilder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* LICENSE file in the root directory of this source tree.
*/
// Disable ESLint because some of the names to include are not in camel case
const expect = require('expect');
const FilterBuilder = require('../FilterBuilder');
const {processOGCGeometry} = require("../../GML");
import expect from 'expect';
import FilterBuilder from '../FilterBuilder';
import {processOGCGeometry} from "../../GML";
describe('FilterBuilder', () => {
it('comparison', () => {
const b = new FilterBuilder();
Expand Down
12 changes: 6 additions & 6 deletions web/client/utils/ogc/WFS/RequestBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
const filterBuilder = require('../Filter/FilterBuilder');
const castArray = require('lodash/castArray');
const {wfsToGmlVersion} = require("./base");
import filterBuilder from '../Filter/FilterBuilder';
import castArray from 'lodash/castArray';
import {wfsToGmlVersion} from "./base";
const getStaticAttributesWFS1 = (ver) => 'service="WFS" version="' + ver + '" ' +
(ver === "1.0.0" ? 'outputFormat="GML2" ' : "") +
'xmlns:gml="http://www.opengis.net/gml" ' +
Expand Down Expand Up @@ -42,7 +42,7 @@ const getStaticAttributesWFS2 = (ver) => 'service="WFS" version="' + ver + '" '
* @return {Object} A request builder. it contains all the `FilterBuilder` methods, plus the getFeature, query... methods
* The request builder provides all the methods to compose the request (query, filter...).
* @example
* const requestBuilder = require('.../RequestBuilder');
* import requestBuilder from '.../RequestBuilder';
* const {getFeature, query, filter, property} = requestBuilder({wfsVersion: "1.0.0"});
* const reqBody = getFeature(query(
* "workspace:layer",
Expand All @@ -65,7 +65,7 @@ const getStaticAttributesWFS2 = (ver) => 'service="WFS" version="' + ver + '" '
* query("layerName", filter..., {options})
* ```
*/
module.exports = function({wfsVersion = "1.1.0", gmlVersion, filterNS, wfsNS = "wfs"} = {}) {
export default function({wfsVersion = "1.1.0", gmlVersion, filterNS, wfsNS = "wfs"} = {}) {
let gmlV = gmlVersion;
if (!gmlV && wfsVersion) {
gmlV = wfsToGmlVersion(wfsVersion);
Expand Down Expand Up @@ -110,4 +110,4 @@ module.exports = function({wfsVersion = "1.1.0", gmlVersion, filterNS, wfsNS = "
+ `</${wfsNS}:Query>`
};

};
}
4 changes: 2 additions & 2 deletions web/client/utils/ogc/WFS/__tests__/RequestBuilder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/

const expect = require('expect');
const requestBuilder = require('../RequestBuilder');
import expect from 'expect';
import requestBuilder from '../RequestBuilder';

const TEST_REQUEST_V2 = '<wfs:GetFeature service="WFS" version="2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd"><wfs:Query typeNames="ft_name_test" srsName="EPSG:4326"><fes:Filter><fes:And><fes:Or><fes:PropertyIsEqualTo><fes:ValueReference>highway_system</fes:ValueReference><fes:Literal>state</fes:Literal></fes:PropertyIsEqualTo></fes:Or></fes:And></fes:Filter></wfs:Query></wfs:GetFeature>';

Expand Down
18 changes: 9 additions & 9 deletions web/client/utils/ogc/WFST/RequestBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* LICENSE file in the root directory of this source tree.
*/

const get = require('lodash/get');
const {insert, feature, attribute} = require('./insert');
const {transaction} = require('./transaction');
const {deleteFeaturesByFilter, deleteFeature} = require('./delete');
const {update, propertyChange} = require('./update');
const {getPropertyDescriptor, getValue, findGeometryProperty, featureTypeSchema} = require("../WFS/base");
const wfsRequestBuilder = require('../WFS/RequestBuilder');
import get from 'lodash/get';
import {insert, feature, attribute} from './insert';
import {transaction} from './transaction';
import {deleteFeaturesByFilter, deleteFeature} from './delete';
import {update, propertyChange} from './update';
import {getPropertyDescriptor, getValue, findGeometryProperty, featureTypeSchema} from "../WFS/base";
import wfsRequestBuilder from '../WFS/RequestBuilder';

const mergeArray = (e, arr2) => arr2 && arr2.length > 0 ? [e, ...arr2] : e;
const WFSVersionNotSupportedException = function(wfsVersion) {
Expand Down Expand Up @@ -56,7 +56,7 @@ const getPropertyName = (name, describe) => name === "geometry" || name === getG
* propertyChange("p", 2) // <Property><Name>p</Name><Value>2</Value></Property>
* ```
*/
module.exports = function(describe, {wfsVersion = "1.1.0", wfsNS = "wfs", ...other} = {}) {
export default function(describe, {wfsVersion = "1.1.0", wfsNS = "wfs", ...other} = {}) {
if (wfsVersion !== "1.1.0") {
throw new WFSVersionNotSupportedException(wfsVersion);
}
Expand All @@ -83,4 +83,4 @@ module.exports = function(describe, {wfsVersion = "1.1.0", wfsNS = "wfs", ...oth
propertyChange: (name, value) => propertyChange(wfsNS, name, getValue(value, name, describe)),
transaction: (content, ...rest) => transaction(mergeArray(content, rest), featureTypeSchema(describe), wfsVersion, wfsNS)
};
};
}
Loading
Loading