Skip to content

Commit

Permalink
require-example linting (#10862)
Browse files Browse the repository at this point in the history
* Last public facing examples

* Exclude private files from geo/ and promote require-example from warning to error
  • Loading branch information
karimnaaji authored Jul 15, 2021
1 parent 6211841 commit a609ca7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@
"src/ui/events.js",
"src/ui/control/**",
"src/ui/handler/**",
"src/geo/**",
"src/geo/lng_lat.js",
"src/geo/lng_lat_bounds.js",
"src/geo/mercator_coordinate.js",
"src/source/**",
],
"rules": {
Expand All @@ -173,7 +175,7 @@
"jsdoc/newline-after-description": "warn",
"jsdoc/no-bad-blocks": "warn",
"jsdoc/require-description": "warn",
"jsdoc/require-example": "warn",
"jsdoc/require-example": "error",
"jsdoc/require-param-type": "warn",
"jsdoc/require-property-description": "warn",
"jsdoc/require-property-name": "warn",
Expand Down
8 changes: 8 additions & 0 deletions src/ui/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ class Camera extends Evented {
* @memberof Map#
* @returns The map's current bearing.
* @see [Navigate the map with game-like controls](https://www.mapbox.com/mapbox-gl-js/example/game-controls/)
* @example
* const bearing = map.getBearing();
*/
getBearing(): number { return this.transform.bearing; }

Expand Down Expand Up @@ -374,6 +376,8 @@ class Camera extends Evented {
*
* @memberof Map#
* @returns The current padding around the map viewport.
* @example
* const padding = map.getPadding();
*/
getPadding(): PaddingOptions { return this.transform.padding; }

Expand Down Expand Up @@ -486,6 +490,8 @@ class Camera extends Evented {
*
* @memberof Map#
* @returns The map's current pitch, measured in degrees away from the plane of the screen.
* @example
* const pitch = map.getPitch();
*/
getPitch(): number { return this.transform.pitch; }

Expand Down Expand Up @@ -1481,6 +1487,8 @@ class Camera extends Evented {
*
* @memberof Map#
* @returns {Map} `this`
* @example
* map.stop();
*/
stop(): this {
return this._stop();
Expand Down
13 changes: 13 additions & 0 deletions src/ui/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ export class MapMouseEvent extends Event {
* * On `mousedown` events, the behavior of {@link BoxZoomHandler}
* * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler}
*
* @example
* map.on('click', (e) => {
* e.preventDefault();
* });
*/
preventDefault() {
this._defaultPrevented = true;
Expand Down Expand Up @@ -244,6 +248,10 @@ export class MapTouchEvent extends Event {
* * On `touchstart` events, the behavior of {@link DragPanHandler}
* * On `touchstart` events, the behavior of {@link TouchZoomRotateHandler}
*
* @example
* map.on('touchstart', (e) => {
* e.preventDefault();
* });
*/
preventDefault() {
this._defaultPrevented = true;
Expand Down Expand Up @@ -308,6 +316,11 @@ export class MapWheelEvent extends Event {
* Prevents subsequent default processing of the event by the map.
*
* Calling this method will prevent the the behavior of {@link ScrollZoomHandler}.
* @example
* map.on('wheel', (e) => {
* // Prevent the default map scroll zoom behavior.
* e.preventDefault();
* });
*/
preventDefault() {
this._defaultPrevented = true;
Expand Down

0 comments on commit a609ca7

Please sign in to comment.