Skip to content

Commit

Permalink
fix: refactor OptionsApiService for better handling of source options…
Browse files Browse the repository at this point in the history
… and enhance ESLint rules
  • Loading branch information
alecarn committed Feb 26, 2025
1 parent 8ecc749 commit fc0209d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
8 changes: 7 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ export default tseslint.config(
],
'@typescript-eslint/no-unused-vars': [
'error',
{ args: 'after-used', destructuredArrayIgnorePattern: '^_' }
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_'
}
],
'arrow-spacing': 'error',
eqeqeq: ['error', 'smart'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';

import {
AnyDataSourceOptions,
ArcGISRestDataSourceOptions,
ArcGISRestImageDataSourceOptions,
TileArcGISRestDataSourceOptions,
Expand Down Expand Up @@ -57,16 +58,8 @@ export class OptionsApiService extends OptionsService {
map(
(res: {
sourceOptions: WMSDataSourceOptions;
layerOptions: Record<string, string>;
}) => {
if (!res || !res.sourceOptions) {
return {} as WMSDataSourceOptions;
}
if (res.layerOptions) {
res.sourceOptions._layerOptionsFromSource = res.layerOptions;
}
return res.sourceOptions;
}
layerOptions: { [keys: string]: string };
}) => this.handleSourceOptions(res)
)
);
}
Expand Down Expand Up @@ -108,20 +101,25 @@ export class OptionsApiService extends OptionsService {
| ArcGISRestDataSourceOptions
| ArcGISRestImageDataSourceOptions
| TileArcGISRestDataSourceOptions;
layerOptions: Record<string, string>;
}) => {
if (!res || !res.sourceOptions) {
return {} as
| ArcGISRestDataSourceOptions
| ArcGISRestImageDataSourceOptions
| TileArcGISRestDataSourceOptions;
}
if (res.layerOptions) {
res.sourceOptions._layerOptionsFromSource = res.layerOptions;
}
return res.sourceOptions;
}
layerOptions: { [keys: string]: string };
}) => this.handleSourceOptions(res)
)
);
}

private handleSourceOptions<T extends AnyDataSourceOptions>(res: {
sourceOptions: T;
layerOptions: { [keys: string]: string };
}) {
if (!res || !res.sourceOptions) {
return {} as WMSDataSourceOptions;
}
if (res.layerOptions) {
res.sourceOptions._layerOptionsFromSource = res.layerOptions;
} else {
const { sourceOptions: _1, layerOptions: _2, ...restOptions } = res;
res.sourceOptions._layerOptionsFromSource = restOptions;
}
return res.sourceOptions;
}
}

0 comments on commit fc0209d

Please sign in to comment.