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

Enable eslint-jsdoc #12019

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
  •  
  •  
  •  
14 changes: 6 additions & 8 deletions Apps/Sandcastle/gallery/Custom DataSource.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@
* This class is an example of a custom DataSource. It loads JSON data as
* defined by Google's WebGL Globe, https://github.com/dataarts/webgl-globe.
* @alias WebGLGlobeDataSource
* @constructor
*
* @class
* @param {string} [name] The name of this data source. If undefined, a name
* will be derived from the url.
*
* @example
* const dataSource = new Cesium.WebGLGlobeDataSource();
* dataSource.loadUrl('sample.json');
Expand All @@ -70,7 +68,7 @@
/**
* Gets a human-readable name for this instance.
* @memberof WebGLGlobeDataSource.prototype
* @type {String}
* @type {string}
*/
name: {
get: function () {
Expand Down Expand Up @@ -99,7 +97,7 @@
/**
* Gets a value indicating if the data source is currently loading data.
* @memberof WebGLGlobeDataSource.prototype
* @type {Boolean}
* @type {boolean}
*/
isLoading: {
get: function () {
Expand Down Expand Up @@ -156,7 +154,7 @@
* so that only one series is viewed at a time. Valid values are defined
* in the seriesNames property.
* @memberof WebGLGlobeDataSource.prototype
* @type {String}
* @type {string}
*/
seriesToDisplay: {
get: function () {
Expand All @@ -180,7 +178,7 @@
/**
* Gets or sets the scale factor applied to the height of each line.
* @memberof WebGLGlobeDataSource.prototype
* @type {Number}
* @type {number}
*/
heightScale: {
get: function () {
Expand All @@ -196,7 +194,7 @@
/**
* Gets whether or not this data source should be displayed.
* @memberof WebGLGlobeDataSource.prototype
* @type {Boolean}
* @type {boolean}
*/
show: {
get: function () {
Expand Down
3 changes: 1 addition & 2 deletions Apps/Sandcastle/gallery/Custom Geocoder.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@
/**
* This class is an example of a custom geocoder. It provides geocoding through the OpenStreetMap Nominatim service.
* @alias OpenStreetMapNominatimGeocoder
* @constructor
* @class
*/
function OpenStreetMapNominatimGeocoder() {}

/**
* The function called to geocode using this geocoder service.
*
* @param {string} input The query to be sent to the geocoder service
* @returns {Promise<GeocoderService.Result[]>}
*/
Expand Down
5 changes: 5 additions & 0 deletions Apps/Sandcastle/gallery/development/Custom Primitive.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* Simple example of writing a Primitive from scratch. This
* primitive displays a procedurally-generated surface at a given
* position on the globe.
* @param cartographicPosition
*/
function CustomPrimitive(cartographicPosition) {
this.show = true;
Expand Down Expand Up @@ -84,6 +85,8 @@
/**
* generate a quad that's subdivided into faceResolution x faceResolution quads.
* The vertices will be adjusted in the vertex shader.
* @param faceResolution
* @param halfWidthMeters
Comment on lines +88 to +89
Copy link
Contributor

@jjspace jjspace Jun 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without forcing the types i'm not sure these add much value . if we're leaving require-param-type off for now then I almost think we should be turning require-param off entirely? I don't want to bikeshed this one much so if you wanna leave it on that's fine.

Edit: That said, it doesn't actually look like there were too many of these added so it might just make sense to turn on the require-param-type and take a bit of time to fill them out? 🤔

*/
function generateVertices(faceResolution, halfWidthMeters) {
const vertexResolution = faceResolution + 1;
Expand All @@ -109,6 +112,7 @@

/**
* Tessellate a big square region into faceResolution x faceResolution quads
* @param faceResolution
*/
function generateIndices(faceResolution) {
const indicesPerQuad = 6;
Expand Down Expand Up @@ -141,6 +145,7 @@
const scratchColor = new Cesium.Color();
/**
* Generate a 1D texture for the color palette
* @param context
*/
function generateTexture(context) {
const width = 256;
Expand Down
10 changes: 5 additions & 5 deletions Documentation/Contributors/DocumentationGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ CesiumMath.EPSILON1 = 0.1;
* interface and is not intended to be instantiated directly.
*
* @alias TerrainProvider
* @constructor
* @class
*
* @see EllipsoidTerrainProvider
* @see CesiumTerrainProvider
Expand All @@ -264,14 +264,14 @@ function TerrainProvider() {

## Classes

Define a class with `@alias` and `@constructor` tags on the constructor function, e.g.,
Define a class with `@alias` and `@class` tags on the constructor function, e.g.,

```javascript
/**
* A 3D Cartesian point.
*
* @alias Cartesian3
* @constructor
* @class
*
* ...
*/
Expand Down Expand Up @@ -423,7 +423,7 @@ If a member or function doesn't start with `_`, but is intended to be private, u
* one using {@link Scene#tweens} and {@link TweenCollection#add} and related add functions.
*
* @alias Tween
* @constructor
* @class
*
* @private
*/
Expand Down Expand Up @@ -459,7 +459,7 @@ There's a general flow to each documentation block that makes it easy to read. T
DESCRIPTION.

@alias NAME
@constructor
@class

@param {TYPE} NAME DESCRIPTION.
@param {TYPE|OTHER_TYPE} NAME DESCRIPTION WITH LONG
Expand Down
5 changes: 1 addition & 4 deletions Specs/ImplicitTilingTester.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ function ImplicitTilingTester() {}
* @property {Uint8Array} [subtreeJson] The JSON portion of the subtree file. Mutually exclusive with subtreeBuffer.
* @property {Uint8Array} [subtreeBuffer] A typed array storing the contents of the subtree file (including the internal buffer). Mutually exclusive with subtreeJson.
* @property {Uint8Array} externalBuffer A typed array representing an external .bin file. This is always returned, but it may be an empty typed array.

*/

/**
* Generate a subtree buffer
* @param {SubtreeDescription} subtreeDescription A JSON description of the subtree's structure and values
* @param {boolean} constantOnly true if all the bitstreams are constant, i.e. no buffers/bufferViews are needed.
* @return {GeneratedSubtree} The procedurally generated subtree and an external buffer.
*
* @returns {GeneratedSubtree} The procedurally generated subtree and an external buffer.
* @example
* const subtreeDescription = {
* tileAvailability: {
Expand All @@ -80,7 +78,6 @@ function ImplicitTilingTester() {}
* const results = ImplicitTilingTester.generateSubtreeBuffers(
* subtreeDescription
* );
*
* @private
*/
ImplicitTilingTester.generateSubtreeBuffers = function (
Expand Down
2 changes: 1 addition & 1 deletion Specs/getArguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* constructor, so it never compares Jasmine-equal to an array. This function lets
* us create an arguments array.
* @alias getArguments
* @return {Array} The arguments passed to the function.
* @returns {Array} The arguments passed to the function.
*/
function getArguments() {
return arguments;
Expand Down
31 changes: 30 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import globals from "globals";
import html from "eslint-plugin-html";
import configCesium from "eslint-config-cesium";
import jsdoc from "eslint-plugin-jsdoc";

export default [
{
Expand Down Expand Up @@ -42,13 +43,41 @@ export default [
{
files: ["packages/**/*.js", "Apps/**/*.js", "Specs/**/*.js", "**/*.html"],
...configCesium.configs.browser,
plugins: { html },
plugins: { html, jsdoc },
settings: {
jsdoc: {
tagNamePreference: {
demo: "demo",
experimental: "experimental",
internalConstructor: "internalConstructor",
performance: "performance",
privateparam: "privateparam",
privateParam: "privateParam",
},
},
},
rules: {
...configCesium.configs.browser.rules,
...jsdoc.configs["flat/recommended-error"].rules,
"no-unused-vars": [
"error",
{ vars: "all", args: "none", caughtErrors: "none" },
],
"jsdoc/require-jsdoc": "off", // Only lint existing jsdoc
"jsdoc/no-undefined-types": "off", // Ignore types for now
"jsdoc/valid-types": "off", // Our link tags are structured differently
"jsdoc/no-defaults": "off", // We use default parameters instead of enforcing with ES6 for now
"jsdoc/require-returns": "off",
"jsdoc/require-returns-description": "off",
"jsdoc/require-returns-type": "off",
"jsdoc/require-returns-check": "off",
"jsdoc/require-param-type": "off",
"jsdoc/require-param-description": "off",
"jsdoc/require-property-description": "off",
"jsdoc/require-description": "off",
"jsdoc/check-param-names": "off",
"jsdoc/check-property-names": "off",
"jsdoc/check-types": "off",
},
},
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"eslint": "^9.1.1",
"eslint-config-cesium": "^11.0.1",
"eslint-plugin-html": "^8.1.1",
"eslint-plugin-jsdoc": "^48.2.7",
"express": "^4.17.1",
"globals": "^15.1.0",
"globby": "^14.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/engine/Source/Core/ApproximateTerrainHeights.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ApproximateTerrainHeights = {};

/**
* Initializes the minimum and maximum terrain heights
* @return {Promise<void>}
* @returns {Promise<void>}
*/
ApproximateTerrainHeights.initialize = function () {
let initPromise = ApproximateTerrainHeights._initPromise;
Expand All @@ -57,7 +57,7 @@ ApproximateTerrainHeights.initialize = function () {
* Computes the minimum and maximum terrain heights for a given rectangle
* @param {Rectangle} rectangle The bounding rectangle
* @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid
* @return {{minimumTerrainHeight: number, maximumTerrainHeight: number}}
* @returns {{minimumTerrainHeight: number, maximumTerrainHeight: number}}
*/
ApproximateTerrainHeights.getMinimumMaximumHeights = function (
rectangle,
Expand Down Expand Up @@ -131,7 +131,7 @@ ApproximateTerrainHeights.getMinimumMaximumHeights = function (
* Computes the bounding sphere based on the tile heights in the rectangle
* @param {Rectangle} rectangle The bounding rectangle
* @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid
* @return {BoundingSphere} The result bounding sphere
* @returns {BoundingSphere} The result bounding sphere
*/
ApproximateTerrainHeights.getBoundingSphere = function (rectangle, ellipsoid) {
//>>includeStart('debug', pragmas.debug);
Expand Down
24 changes: 4 additions & 20 deletions packages/engine/Source/Core/ArcGISTiledElevationTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const ALL_CHILDREN = 15;
* @typedef {Object} ArcGISTiledElevationTerrainProvider.ConstructorOptions
*
* Initialization options for the ArcGISTiledElevationTerrainProvider constructor
*
* @property {string} [token] The authorization token to use to connect to the service.
* @property {Ellipsoid} [ellipsoid] The ellipsoid. If the tilingScheme is specified,
* this parameter is ignored and the tiling scheme's ellipsoid is used instead.
Expand All @@ -34,10 +33,8 @@ const ALL_CHILDREN = 15;

/**
* Used to track creation details while fetching initial metadata
*
* @constructor
* @class
* @private
*
* @param {ArcGISTiledElevationTerrainProvider.ConstructorOptions} [options] An object describing initialization options.
*/
function TerrainProviderBuilder(options) {
Expand All @@ -58,9 +55,7 @@ function TerrainProviderBuilder(options) {

/**
* Complete ArcGISTiledElevationTerrainProvider creation based on builder values.
*
* @private
*
* @param {ArcGISTiledElevationTerrainProvider} provider
*/
TerrainProviderBuilder.prototype.build = function (provider) {
Expand Down Expand Up @@ -217,18 +212,14 @@ async function requestMetadata(
*
* A {@link TerrainProvider} that produces terrain geometry by tessellating height maps
* retrieved from Elevation Tiles of an an ArcGIS ImageService.
*
* @alias ArcGISTiledElevationTerrainProvider
* @constructor
*
* @class
* @param {CesiumTerrainProvider.ConstructorOptions} [options] A url or an object describing initialization options
*
* @example
* const terrainProvider = await Cesium.ArcGISTiledElevationTerrainProvider.fromUrl("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer", {
* token: "KED1aF_I4UzXOHy3BnhwyBHU4l5oY6rO6walkmHoYqGp4XyIWUd5YZUC1ZrLAzvV40pR6gBXQayh0eFA8m6vPg.."
* });
* viewer.terrainProvider = terrainProvider;
*
* @see TerrainProvider
*/
function ArcGISTiledElevationTerrainProvider(options) {
Expand Down Expand Up @@ -336,19 +327,16 @@ Object.defineProperties(ArcGISTiledElevationTerrainProvider.prototype, {
/**
* Creates a {@link TerrainProvider} that produces terrain geometry by tessellating height maps
* retrieved from Elevation Tiles of an an ArcGIS ImageService.
*
* @param {Resource|String|Promise<Resource>|Promise<String>} url The URL of the ArcGIS ImageServer service.
* @param {ArcGISTiledElevationTerrainProvider.ConstructorOptions} [options] A url or an object describing initialization options.
* @returns {Promise<ArcGISTiledElevationTerrainProvider>}
*
* @example
* const terrainProvider = await Cesium.ArcGISTiledElevationTerrainProvider.fromUrl("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer", {
* token: "KED1aF_I4UzXOHy3BnhwyBHU4l5oY6rO6walkmHoYqGp4XyIWUd5YZUC1ZrLAzvV40pR6gBXQayh0eFA8m6vPg.."
* });
* viewer.terrainProvider = terrainProvider;
*
* @exception {RuntimeError} metadata specifies invalid spatial reference
* @exception {RuntimeError} metadata does not specify tileInfo
* @throws {RuntimeError} metadata specifies invalid spatial reference
* @throws {RuntimeError} metadata does not specify tileInfo
*/
ArcGISTiledElevationTerrainProvider.fromUrl = async function (url, options) {
//>>includeStart('debug', pragmas.debug);
Expand Down Expand Up @@ -387,7 +375,6 @@ ArcGISTiledElevationTerrainProvider.fromUrl = async function (url, options) {
/**
* Requests the geometry for a given tile. The result includes terrain
* data and indicates that all child tiles are available.
*
* @param {number} x The X coordinate of the tile for which to request geometry.
* @param {number} y The Y coordinate of the tile for which to request geometry.
* @param {number} level The level of the tile for which to request geometry.
Expand Down Expand Up @@ -491,7 +478,6 @@ function isTileAvailable(that, level, x, y) {

/**
* Gets the maximum geometric error allowed in a tile at a given level.
*
* @param {number} level The tile level for which to get the maximum geometric error.
* @returns {number} The maximum geometric error.
*/
Expand All @@ -503,7 +489,6 @@ ArcGISTiledElevationTerrainProvider.prototype.getLevelMaximumGeometricError = fu

/**
* Determines whether data for a tile is available to be loaded.
*
* @param {number} x The X coordinate of the tile for which to request geometry.
* @param {number} y The Y coordinate of the tile for which to request geometry.
* @param {number} level The level of the tile for which to request geometry.
Expand All @@ -530,7 +515,6 @@ ArcGISTiledElevationTerrainProvider.prototype.getTileDataAvailable = function (

/**
* Makes sure we load availability data for a tile
*
* @param {number} x The X coordinate of the tile for which to request geometry.
* @param {number} y The Y coordinate of the tile for which to request geometry.
* @param {number} level The level of the tile for which to request geometry.
Expand Down
Loading