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

Eslint: homogenize / sort imports using simple-sort-plugin #470

Merged
merged 5 commits into from
Sep 6, 2023
Merged
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
12 changes: 12 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": [
"@terrestris/eslint-config-typescript"
],
"plugins": ["simple-import-sort"],
"rules": {
"@typescript-eslint/member-ordering": "off",
"no-underscore-dangle": "off",
"simple-import-sort/exports": "warn",
"simple-import-sort/imports": "warn"
}
}
3 changes: 0 additions & 3 deletions .eslintrc.js

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ target/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# intellij
.idea
*.iml
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
],
"scripts": {
"build": "rimraf ./dist/* && tsc -p tsconfig.json",
"eslint": "eslint -c .eslintrc.js --ext .js,.ts,.tsx && tsc --noEmit --project tsconfig.json",
"lint:test:build": "npm run lint:test && npm run build",
"lint:test": "npm run lint && npm run test",
"lint": "npm run typecheck && npm run eslint ",
"lint": "eslint -c .eslintrc --ext .tsx,.ts src/",
"lint:fix": "eslint -c .eslintrc --ext .tsx,.ts src/ --fix",
"prepublishOnly": "npm run lint:test:build",
"release": "np --no-yarn && git push https://github.com/terrestris/react-util.git main",
"test-ci": "jest --ci --coverage",
Expand Down Expand Up @@ -50,6 +48,7 @@
"@babel/plugin-proposal-optional-chaining": "^7.13.12",
"@babel/preset-env": "^7.14.1",
"@babel/preset-react": "^7.13.13",
"eslint-plugin-simple-import-sort": "^10.0.0",
"@babel/preset-typescript": "^7.13.0",
"@cfaester/enzyme-adapter-react-18": "^0.7.1",
"@terrestris/eslint-config-typescript": "^3.0.0",
Expand Down
15 changes: 6 additions & 9 deletions src/BackgroundLayerChooser/BackgroundLayerChooser.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import React, {
useState,
useEffect,
useRef
} from 'react';

import OlOverviewMap from 'ol/control/OverviewMap';
import OlLayerBase from 'ol/layer/Base';
import OlLayerImage from 'ol/layer/Image';
import OlLayer from 'ol/layer/Layer';
import OlView from 'ol/View';
import OlLayerTile from 'ol/layer/Tile';
import OlLayerImage from 'ol/layer/Image';
import { ObjectEvent } from 'ol/Object';
import { getUid } from 'ol/util';
import OlView from 'ol/View';
import React, {
useEffect,
useRef,
useState} from 'react';

import BackgroundLayerPreview, {
BackgroundLayerLoadingMaskProps
} from '../BackgroundLayerPreview/BackgroundLayerPreview';

import useMap from '../hooks/useMap';

export type BackgroundLayerButtonProps = {
Expand Down
11 changes: 5 additions & 6 deletions src/BackgroundLayerPreview/BackgroundLayerPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { useState, useEffect } from 'react';

import { Coordinate } from 'ol/coordinate';
import OlLayerBase from 'ol/layer/Base';
import OlLayerImage from 'ol/layer/Image';
import OlLayer from 'ol/layer/Layer';
import OlMap from 'ol/Map';
import OlView from 'ol/View';
import OlLayerTile from 'ol/layer/Tile';
import OlLayerImage from 'ol/layer/Image';
import OlMap from 'ol/Map';
import { getUid } from 'ol/util';
import OlView from 'ol/View';
import React, { useEffect,useState } from 'react';

import { Coordinate } from 'ol/coordinate';
import useMap from '../hooks/useMap';
import MapComponent from '../Map/MapComponent/MapComponent';

Expand Down
7 changes: 4 additions & 3 deletions src/Context/MapContext/MapContext.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import { mount,shallow } from 'enzyme';
import OlMap from 'ol/Map';
import { shallow, mount } from 'enzyme';
import React from 'react';

import { useMap } from '../../hooks/useMap';
import MapContext from './MapContext';
import { TestUtil } from '../../Util/TestUtil';
import MapContext from './MapContext';

describe('MapContext', () => {
const olMap = TestUtil.createMap();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import FileUtil from '@terrestris/ol-util/dist/FileUtil/FileUtil';
import * as React from 'react';

import TestUtil from '../../Util/TestUtil';

import { onDropAware } from './DropTargetMap';

import FileUtil from '@terrestris/ol-util/dist/FileUtil/FileUtil';

describe('onDropAware', () => {
let EnhancedComponent;

Expand Down
2 changes: 1 addition & 1 deletion src/HigherOrderComponent/DropTargetMap/DropTargetMap.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FileUtil from '@terrestris/ol-util/dist/FileUtil/FileUtil';
import * as React from 'react';

import FileUtil from '@terrestris/ol-util/dist/FileUtil/FileUtil';
import { MapComponentProps } from '../../Map/MapComponent/MapComponent';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import * as React from 'react';
import moment from 'moment';

import OlTileLayer from 'ol/layer/Tile';
import OlTileWMS from 'ol/source/TileWMS';
import * as React from 'react';

import TestUtil from '../../Util/TestUtil';

import { timeLayerAware } from './TimeLayerAware';

describe('timeLayerAware', () => {
Expand Down
4 changes: 1 addition & 3 deletions src/HigherOrderComponent/TimeLayerAware/TimeLayerAware.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import * as React from 'react';

import _isArray from 'lodash/isArray';

import OlLayer from 'ol/layer/Layer';
import OlImageWMS from 'ol/source/ImageWMS';
import OlTileWMS from 'ol/source/TileWMS';
import * as React from 'react';

export type TimeLayerAwareConfig = {
isWmsTime?: boolean;
Expand Down
1 change: 0 additions & 1 deletion src/Map/FloatingMapLogo/FloatingMapLogo.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import testLogo from '../../../assets/user.png';
import TestUtil from '../../Util/TestUtil';

import FloatingMapLogo from './FloatingMapLogo';

describe('<FloatingMapLogo />', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/Map/FloatingMapLogo/FloatingMapLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';

import _cloneDeep from 'lodash/cloneDeep';
import * as React from 'react';

import { CSS_PREFIX } from '../../constants';

Expand Down
1 change: 0 additions & 1 deletion src/Map/MapComponent/MapComponent.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import TestUtil from '../../Util/TestUtil';

import MapComponent from './MapComponent';

describe('<MapComponent />', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/Map/MapComponent/MapComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import OlMap from 'ol/Map';
import React, {
useCallback
} from 'react';

import OlMap from 'ol/Map';

export interface MapComponentProps extends React.ComponentProps<'div'> {
map: OlMap;
mapDivId?: string;
Expand Down
22 changes: 11 additions & 11 deletions src/Util/DigitizeUtil.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import OlVectorLayer from 'ol/layer/Vector';
import OlStyleStyle, { StyleLike as OlStyleLike } from 'ol/style/Style';
import OlStyleCircle from 'ol/style/Circle';
import OlStyleFill from 'ol/style/Fill';
import OlStyleStroke from 'ol/style/Stroke';
import OlStyleText from 'ol/style/Text';
import OlStyle from 'ol/style/Style';
import OlLayerVector from 'ol/layer/Vector';
import OlSourceVector from 'ol/source/Vector';
import OlCollection from 'ol/Collection';
import OlMap from 'ol/Map';
import MapUtil from '@terrestris/ol-util/dist/MapUtil/MapUtil';
import OlCollection from 'ol/Collection';
import OlFeature from 'ol/Feature';
import OlGeometry from 'ol/geom/Geometry';
import Geometry from 'ol/geom/Geometry';
import OlVectorLayer from 'ol/layer/Vector';
import OlLayerVector from 'ol/layer/Vector';
import OlMap from 'ol/Map';
import RenderFeature from 'ol/render/Feature';
import OlSourceVector from 'ol/source/Vector';
import OlStyleCircle from 'ol/style/Circle';
import OlStyleFill from 'ol/style/Fill';
import OlStyleStroke from 'ol/style/Stroke';
import OlStyleStyle, { StyleLike as OlStyleLike } from 'ol/style/Style';
import OlStyle from 'ol/style/Style';
import OlStyleText from 'ol/style/Text';

export class DigitizeUtil {
/**
Expand Down
11 changes: 6 additions & 5 deletions src/Util/PrintUtil.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import OlMap from 'ol/Map';
import MapUtil from '@terrestris/ol-util/dist/MapUtil/MapUtil';
import {
downloadBlob,
getJobStatus,
queuePrint
} from '@camptocamp/inkmap';
import Logger from '@terrestris/base-util/dist/Logger';
import MapUtil from '@terrestris/ol-util/dist/MapUtil/MapUtil';
import { jsPDF } from 'jspdf';
import _isString from 'lodash/isString';
import OlMap from 'ol/Map';

import {
InkmapPrintSpec
} from './InkmapTypes';
import { jsPDF } from 'jspdf';
import _isString from 'lodash/isString';
import Logger from '@terrestris/base-util/dist/Logger';

export class PrintUtil {

Expand Down
12 changes: 6 additions & 6 deletions src/Util/TestUtil.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react';
import { mount, shallow, ShallowWrapper, ReactWrapper, MountRendererProps } from 'enzyme';
import OlView from 'ol/View';
import OlMap from 'ol/Map';
import OlSourceVector from 'ol/source/Vector';
import OlLayerVector from 'ol/layer/Vector';
import { mount, MountRendererProps,ReactWrapper, shallow, ShallowWrapper } from 'enzyme';
import OlFeature from 'ol/Feature';
import OlGeomPoint from 'ol/geom/Point';
import OlLayerVector from 'ol/layer/Vector';
import OlMap from 'ol/Map';
import OlMapBrowserEvent from 'ol/MapBrowserEvent';
import OlSourceVector from 'ol/source/Vector';
import OlView from 'ol/View';
import * as React from 'react';

type Wrapper = ShallowWrapper | ReactWrapper;

Expand Down
11 changes: 6 additions & 5 deletions src/Util/rtlTestUtils.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { act, fireEvent, render } from '@testing-library/react';
import OlMap from 'ol/Map';
import MapContext from '../Context/MapContext/MapContext';
import MapComponent from '../Map/MapComponent/MapComponent';
import * as React from 'react';
import { ReactElement } from 'react';
import OlFeature from 'ol/Feature';
import OlGeometry from 'ol/geom/Geometry';
import OlVectorLayer from 'ol/layer/Vector';
import OlMap from 'ol/Map';
import OlVectorSource from 'ol/source/Vector';
import * as React from 'react';
import { ReactElement } from 'react';

import MapContext from '../Context/MapContext/MapContext';
import MapComponent from '../Map/MapComponent/MapComponent';

export async function actSetTimeout(time: number): Promise<void> {
// @ts-ignore
Expand Down
16 changes: 7 additions & 9 deletions src/Util/typeUtils.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { isWmsLayer } from './typeUtils';

import OlBaseLayer from 'ol/layer/Base';
import OlLayer from 'ol/layer/Layer';
import OlImageWMS from 'ol/source/ImageWMS';
import OlTileWMS from 'ol/source/TileWMS';
import OlHeatmapLayer from 'ol/layer/Heatmap';
import OlImageLayer from 'ol/layer/Image';
import OlLayer from 'ol/layer/Layer';
import OlTileLayer from 'ol/layer/Tile';

import OlVectorLayer from 'ol/layer/Vector';
import OlHeatmapLayer from 'ol/layer/Heatmap';

import OlSourceCluster from 'ol/source/Cluster';
import OlImageWMS from 'ol/source/ImageWMS';
import OlTileWMS from 'ol/source/TileWMS';
import OlSourceVector from 'ol/source/Vector';
import OlSourceVectorTile from 'ol/source/VectorTile';
import OlSourceCluster from 'ol/source/Cluster';

import { isWmsLayer } from './typeUtils';

const getWmsLikeLayers = () => {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/Util/typeUtils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import OlBaseLayer from 'ol/layer/Base';
import OlImageLayer from 'ol/layer/Image';
import OlLayer from 'ol/layer/Layer';
import OlTileLayer from 'ol/layer/Tile';
import OlImageWMS from 'ol/source/ImageWMS';
import OlTileWMS from 'ol/source/TileWMS';
import OlImageLayer from 'ol/layer/Image';
import OlTileLayer from 'ol/layer/Tile';

export type WmsLayer = OlImageLayer<OlImageWMS> | OlTileLayer<OlTileWMS> | OlLayer<OlImageWMS | OlTileWMS>;

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useAsyncEffect/useAsyncEffect.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useAsyncEffect } from './useAsyncEffect';

// @ts-ignore
import fetch from 'jest-fetch-mock';

import { useAsyncEffect } from './useAsyncEffect';

jest.mock('react');

import { useEffect } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useDebouncedState/useDebouncedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ export const useDebouncedState = <T>({ initialValue, time = 100 }: UseDebouncedS
};

return [state, setDelayedState];
}
};
3 changes: 1 addition & 2 deletions src/hooks/useMap.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import OlMap from 'ol/Map';
import {
useContext
} from 'react';

import OlMap from 'ol/Map';

import MapContext from '../Context/MapContext/MapContext';

export const useMap = (): (OlMap | undefined) => {
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useObjectState/useObjectState.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useObjectState } from './useObjectState';
import { renderHook, act } from '@testing-library/react';

import { Logger } from '@terrestris/base-util';
import { act,renderHook } from '@testing-library/react';

import { useObjectState } from './useObjectState';

type User = {
name: string;
Expand Down
Loading
Loading