Skip to content

Commit

Permalink
Update jsdoc fix (#120)
Browse files Browse the repository at this point in the history
* update deps

* add eslint config

* update codestyle + fix jsdoc + fix problems
  • Loading branch information
209 authored Mar 18, 2023
1 parent bef9030 commit ee68e8c
Show file tree
Hide file tree
Showing 264 changed files with 13,882 additions and 10,787 deletions.
90 changes: 90 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
module.exports = {
root: true,

parserOptions: {
parser: require.resolve('@typescript-eslint/parser'),
},

env: {
browser: true,
es2021: true,
node: true,
},

// Rules order is important, please avoid shuffling them
extends: [
'plugin:@typescript-eslint/recommended',
'airbnb-base',
],

plugins: [
'@typescript-eslint',
'jsdoc',
],

settings: {
jsdoc: {
mode: 'typescript',
},
},

// add your custom rules here
rules: {
'no-plusplus': 'off',
'max-len': 'off',
camelcase: 'off',
'no-use-before-define': 'off',

'no-param-reassign': 'off',
'no-void': 'off',
'no-nested-ternary': 'off',
'max-classes-per-file': 'off',

'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',

'import/first': 'off',
'import/named': 'error',
'import/namespace': 'error',
'import/default': 'error',
'import/export': 'error',
'import/extensions': 'off',
'import/no-unresolved': 'off',
'import/no-extraneous-dependencies': 'off',
'import/prefer-default-export': 'off',

'prefer-promise-reject-errors': 'off',

quotes: ['error', 'single', { avoidEscape: true }],

// this rule, if on, would require explicit return type on the `render` function
'@typescript-eslint/explicit-function-return-type': 'off',

// in plain CommonJS modules, you can't use `import foo = require('foo')` to pass this rule, so it has to be disabled
'@typescript-eslint/no-var-requires': 'off',

// The core 'no-unused-vars' rules (in the eslint:recommended ruleset)
// does not work with type definitions
'no-unused-vars': 'off',

// allow debugger during development only
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'@typescript-eslint/ban-ts-comment': 'off',

semi: ['error', 'never'],
'arrow-body-style': 'off',
'func-call-spacing': 'off',
'no-spaced-func': 'off',
'arrow-parens': ['error', 'as-needed'],
'no-console': 'off',
'no-alert': 'off',
'no-underscore-dangle': 'off',

'linebreak-style': ['error', (process.platform === 'win32' ? 'windows' : 'unix')],
'@typescript-eslint/consistent-type-imports': 'error',
'class-methods-use-this': 'off',
'no-undef': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-interface': 'off',
},
}
133 changes: 73 additions & 60 deletions @types/ol-ext/control/Bar.d.ts
Original file line number Diff line number Diff line change
@@ -1,72 +1,85 @@
import { Map as _ol_Map_ } from 'ol';
import Control from 'ol/control/Control';
import ol_control_Control, {Options as ControlOptions} from 'ol/control/Control';
import Event from 'ol/events/Event';
import { position } from './control';
import type { Map as _ol_Map_ } from 'ol'
import type { Options as ControlOptions } from 'ol/control/Control'
import ol_control_Control from 'ol/control/Control'
import type Event from 'ol/events/Event'
import type { position } from './control'

export interface Options extends ControlOptions {
className?: string;
group?: boolean;
toggleOne?: boolean;
autoDeactivate?: boolean;
controls?: ol_control_Control[];
className?: string;
group?: boolean;
toggleOne?: boolean;
autoDeactivate?: boolean;
controls?: ol_control_Control[];
}

/** Control bar for OL3
* The control bar is a container for other controls. It can be used to create toolbars.
* Control bars can be nested and combined with contrToggle to handle activate/deactivate.
*
* @constructor
* @extends {contrControl}
* @param {Object=} options Control options.
* @param {String} options.className class of the control
* @param {bool} options.group is a group, default false
* @param {bool} options.toggleOne only one toggle control is active at a time, default false
* @param {bool} options.autoDeactivate used with subbar to deactivate all control when top level control deactivate, default false
* @param {Array<Control>} options.controls a list of control to add to the bar
*/
export default class Bar extends ol_control_Control {
constructor(options?: Options);
/** Set the control visibility
* @param {boolean} b
*/
setVisible(b: boolean): void;
/** Get the control visibility
* @return {boolean} b
*/
getVisible(): boolean;
/**
* Set the map instance the control is associated with
* and add its controls associated to this map.
* @param {_ol_Map_} map The map instance.
*/
setMap(map: _ol_Map_): void;
/** Get controls in the panel
* @return {Array<ol_control_Control>}
*/
getControls(): ol_control_Control[];
/** Set tool bar position
* @param {top|left|bottom|right} pos
*/
setPosition(pos: position): void;
/** Add a control to the bar
* @param {_ol_control_} c control to add
*/
addControl(c: ol_control_Control): void;
/** Deativate all controls in a bar
* @param {_ol_control_} except a control
*/
deactivateControls(except: ol_control_Control): void;
/** Auto activate/deactivate controls in the bar
* @param {boolean} b activate/deactivate
*/
setActive(b: boolean): void;
/** Post-process an activated/deactivated control
* @param {Event} e :an object with a target {ol_control_Control} and active flag {boolean}
*/
onActivateControl_(e: Event): void;
/**
* @param {string} name of the control to search
* @return {ol_control_Control}
*/
getControlsByName(name: string): ol_control_Control;
/**
* @param {Object=} options Control options.
* @param {String} options.className class of the control
* @param {bool} options.group is a group, default false
* @param {bool} options.toggleOne only one toggle control is active at a time, default false
* @param {bool} options.autoDeactivate used with subbar to deactivate all control when top level control deactivate, default false
* @param {Array<Control>} options.controls a list of control to add to the bar
*/
constructor(options?: Options);

/** Set the control visibility
* @param {boolean} b
*/
setVisible(b: boolean): void;

/** Get the control visibility
* @return {boolean} b
*/
getVisible(): boolean;

/**
* Set the map instance the control is associated with
* and add its controls associated to this map.
* @param {_ol_Map_} map The map instance.
*/
setMap(map: _ol_Map_): void;

/** Get controls in the panel
* @return {Array<ol_control_Control>}
*/
getControls(): ol_control_Control[];

/** Set tool bar position
* @param {top|left|bottom|right} pos
*/
setPosition(pos: position): void;

/** Add a control to the bar
* @param {_ol_control_} c control to add
*/
addControl(c: ol_control_Control): void;

/** Deativate all controls in a bar
* @param {_ol_control_} except a control
*/
deactivateControls(except: ol_control_Control): void;

/** Auto activate/deactivate controls in the bar
* @param {boolean} b activate/deactivate
*/
setActive(b: boolean): void;

/** Post-process an activated/deactivated control
* @param {Event} e :an object with a target {ol_control_Control} and active flag {boolean}
*/
onActivateControl_(e: Event): void;

/**
* @param {string} name of the control to search
* @return {ol_control_Control}
*/
getControlsByName(name: string): ol_control_Control;
}
74 changes: 40 additions & 34 deletions @types/ol-ext/control/Button.d.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
import ol_control_Control, {Options as ControlOptions} from 'ol/control/Control';
import type { Options as ControlOptions } from 'ol/control/Control'
import ol_control_Control from 'ol/control/Control'

export interface Options extends ControlOptions {
className?: string;
title?: string;
name?: string;
html?: string | Element;
handleClick?: (e: Event) => void;
className?: string;
title?: string;
name?: string;
html?: string | Element;
handleClick?: (e: Event) => void;
}

/** A simple push button control
* @constructor
* @extends {contrControl}
* @param {Object=} options Control options.
* @param {String} options.className class of the control
* @param {String} options.title title of the control
* @param {String} options.name an optional name, default none
* @param {String} options.html html to insert in the control
* @param {function} options.handleClick callback when control is clicked (or use change:active event)
* @constructor
* @extends {contrControl}
*/
export default class Button extends ol_control_Control {
constructor(options?: Options);
/** Set the control visibility
* @param {boolean} b
*/
setVisible(b: boolean): void;
/**
* Set the button title
* @param {string} title
*/
setTitle(title: string): void;
/**
* Set the button html
* @param {string} html
*/
setHtml(html: string): void;
/**
* @param {Object=} options Control options.
* @param {String} options.className class of the control
* @param {String} options.title title of the control
* @param {String} options.name an optional name, default none
* @param {String} options.html html to insert in the control
* @param {function} options.handleClick callback when control is clicked (or use change:active event)
*/
constructor(options?: Options);

/**
* Get the button element
* @returns {Element}
*/
getButtonElement(): Element
/** Set the control visibility
* @param {boolean} b
*/
setVisible(b: boolean): void;

/**
* Set the button title
* @param {string} title
*/
setTitle(title: string): void;

/**
* Set the button html
* @param {string} html
*/
setHtml(html: string): void;

/**
* Get the button element
* @returns {Element}
*/
getButtonElement(): Element
}
62 changes: 34 additions & 28 deletions @types/ol-ext/control/CanvasAttribution.d.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
import { Map as _ol_Map_ } from 'ol';
import Attribution from 'ol/control/Attribution';
import { Style } from 'ol/style';
import {Options as AttributionOptions} from 'ol/control/Attribution'
import type { Map as _ol_Map_ } from 'ol'
import type { Options as AttributionOptions } from 'ol/control/Attribution'
import Attribution from 'ol/control/Attribution'
import type { Style } from 'ol/style'

export interface Options extends AttributionOptions {
style?: Style;
canvas?: boolean
style?: Style;
canvas?: boolean;
}

/**
* @classdesc
* OpenLayers 3 Attribution Control integrated in the canvas (for jpeg/png export purposes).
* @see http://www.kreidefossilien.de/webgis/dokumentation/beispiele/export-map-to-png-with-scale
*
* @constructor
* @extends ol_control_Attribution
* @param {Object=} options extend the ol_control_Attribution options.
* @param {ol_style_Style} options.style option is usesd to draw the text.
* @paream {boolean} [options.canvas=false] draw on canvas
*/
export default class CanvasAttribution extends Attribution {
constructor(options?: Options);
/**
* Draw attribution on canvas
* @param {boolean} b draw the attribution on canvas.
*/
setCanvas(b: boolean): void;
/**
* Change the control style
* @param {Style} style
*/
setStyle(style: Style): void;
/**
* Remove the control from its current map and attach it to the new map.
* Subclasses may set up event handlers to get notified about changes to
* the map here.
* @param {Map} map Map.
* @api stable
*/
setMap(map: _ol_Map_): void;
/**
* @param {Object=} options extend the ol_control_Attribution options.
* @param {ol_style_Style} options.style option is usesd to draw the text.
* @paream {boolean} [options.canvas=false] draw on canvas
*/
constructor(options?: Options);

/**
* Draw attribution on canvas
* @param {boolean} b draw the attribution on canvas.
*/
setCanvas(b: boolean): void;

/**
* Change the control style
* @param {Style} style
*/
setStyle(style: Style): void;

/**
* Remove the control from its current map and attach it to the new map.
* Subclasses may set up event handlers to get notified about changes to
* the map here.
* @param {Map} map Map.
* @api stable
*/
setMap(map: _ol_Map_): void;
}
Loading

0 comments on commit ee68e8c

Please sign in to comment.