Skip to content

Commit b1249c4

Browse files
committed
style: fix some lint
1 parent 664f79c commit b1249c4

File tree

12 files changed

+32
-35
lines changed

12 files changed

+32
-35
lines changed

src/Asset.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class Asset {
2525
* @param {string} assetId - The ID of this asset.
2626
* @param {DataFormat} [dataFormat] - The format of the data (WAV, PNG, etc.); required iff `data` is present.
2727
* @param {Buffer} [data] - The in-memory data for this asset; optional.
28-
* @param {bool} [generateId] - Whether to create id from an md5 hash of data
28+
* @param {boolean} [generateId] - Whether to create id from an md5 hash of data
2929
*/
3030
constructor (
3131
assetType: AssetType,
@@ -79,7 +79,7 @@ export default class Asset {
7979
* Same as `setData` but encodes text first.
8080
* @param {string} data - the text data to encode and store.
8181
* @param {DataFormat} dataFormat - the format of the data (DataFormat.SVG for example).
82-
* @param {bool} generateId - after setting data, set the id to an md5 of the data?
82+
* @param {boolean} generateId - after setting data, set the id to an md5 of the data?
8383
*/
8484
encodeTextData (data: string, dataFormat: DataFormat, generateId: boolean): void {
8585
const encoder = new _TextEncoder();

src/AssetType.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export interface AssetType {
99

1010
/**
1111
* Enumeration of the supported asset types.
12-
* @type {Object.<String,AssetType>}
13-
* @typedef {Object} AssetType - Information about a supported asset type.
12+
* @type {{[assetTypeName: string]: AssetType}}
13+
* @typedef {object} AssetType - Information about a supported asset type.
1414
* @property {string} contentType - the MIME type associated with this kind of data. Useful for data URIs, etc.
1515
* @property {string} name - The human-readable name of this asset type.
1616
* @property {DataFormat} runtimeFormat - The default format used for runtime, in-memory storage of this asset. For

src/BuiltinHelper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ export default class BuiltinHelper extends Helper {
6767

6868
/**
6969
* In-memory storage for all built-in assets.
70-
* @type {Object.<AssetType, AssetIdMap>} Maps asset type to a map of asset ID to actual assets.
71-
* @typedef {Object.<string, BuiltinAssetRecord>} AssetIdMap - Maps asset ID to asset.
70+
* @type {{[assetType: string]: AssetIdMap}} Maps asset type to a map of asset ID to actual assets.
71+
* @typedef {{[id: string]: BuiltinAssetRecord}} AssetIdMap - Maps asset ID to asset.
7272
*/
7373
this.assets = {};
7474

@@ -97,7 +97,7 @@ export default class BuiltinHelper extends Helper {
9797
get (assetId: AssetId): Asset | null {
9898
let asset: Asset | null = null;
9999
if (Object.prototype.hasOwnProperty.call(this.assets, assetId)) {
100-
/** @type{BuiltinAssetRecord} */
100+
/** @type {BuiltinAssetRecord} */
101101
const assetRecord = this.assets[assetId];
102102
asset = new Asset(assetRecord.type, assetRecord.id!, assetRecord.format, assetRecord.data);
103103
}
@@ -163,7 +163,7 @@ export default class BuiltinHelper extends Helper {
163163
* Fetch an asset but don't process dependencies.
164164
* @param {AssetType} assetType - The type of asset to fetch.
165165
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
166-
* @return {?Promise.<Asset>} A promise for the contents of the asset.
166+
* @returns {?Promise.<Asset>} A promise for the contents of the asset.
167167
*/
168168
load (assetType: AssetType, assetId: AssetId): Promise<Asset | null> | null {
169169
if (!this.get(assetId)) {

src/FetchWorkerTool.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class PrivateFetchWorkerTool implements Tool {
4848
// Yes, this is a browser API and we've specified `browser: false` in the eslint env,
4949
// but `isGetSupported` checks for the presence of Worker and uses it only if present.
5050
// Also see https://webpack.js.org/guides/web-workers/
51-
// eslint-disable-next-line no-undef
5251
const worker = new Worker(
5352
/* webpackChunkName: "fetch-worker" */ new URL('./FetchWorkerTool.worker', import.meta.url)
5453
);

src/FetchWorkerTool.worker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const registerStep = function () {
4141

4242
/**
4343
* Receive a job from the parent and fetch the requested data.
44-
* @param {object} options.job A job id, url, and options descriptor to perform.
44+
* @param {object} message The message from the parent.
45+
* @param {object} message.data A job id, url, and options descriptor to perform.
4546
*/
4647
const onMessage = ({data: job}) => {
4748
if (jobsActive === 0 && !intervalId) {

src/Helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class Helper {
1919
* @param {AssetType} assetType - The type of asset to fetch.
2020
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
2121
* @param {DataFormat} dataFormat - The file format / file extension of the asset to fetch: PNG, JPG, etc.
22-
* @return {Promise.<Asset>} A promise for the contents of the asset.
22+
* @returns {Promise.<Asset>} A promise for the contents of the asset.
2323
*/
2424
load (assetType: AssetType, assetId: AssetId, dataFormat: DataFormat): Promise<Asset | null> | null {
2525
return Promise.reject(new Error(`No asset of type ${assetType} for ID ${assetId} with format ${dataFormat}`));

src/ScratchStorage.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,50 +41,50 @@ export class ScratchStorage {
4141
}
4242

4343
/**
44-
* @return {Asset} - the `Asset` class constructor.
45-
* @constructor
44+
* @returns {Asset} - the `Asset` class constructor.
45+
* @class
4646
*/
4747
get Asset () {
4848
return _Asset;
4949
}
5050

5151
/**
52-
* @return {AssetType} - the list of supported asset types.
53-
* @constructor
52+
* @returns {AssetType} - the list of supported asset types.
53+
* @class
5454
*/
5555
get AssetType () {
5656
return _AssetType;
5757
}
5858

5959
/**
60-
* @return {DataFormat} - the list of supported data formats.
61-
* @constructor
60+
* @returns {DataFormat} - the list of supported data formats.
61+
* @class
6262
*/
6363
get DataFormat () {
6464
return _DataFormat;
6565
}
6666

6767
/**
6868
* Access the `scratchFetch` module within this library.
69-
* @return {module} the scratchFetch module, with properties for `scratchFetch`, `setMetadata`, etc.
69+
* @returns {module} the scratchFetch module, with properties for `scratchFetch`, `setMetadata`, etc.
7070
*/
7171
get scratchFetch () {
7272
return _scratchFetch;
7373
}
7474

7575
/**
7676
* @deprecated Please use the `Asset` member of a storage instance instead.
77-
* @return {Asset} - the `Asset` class constructor.
78-
* @constructor
77+
* @returns {Asset} - the `Asset` class constructor.
78+
* @class
7979
*/
8080
static get Asset () {
8181
return _Asset;
8282
}
8383

8484
/**
8585
* @deprecated Please use the `AssetType` member of a storage instance instead.
86-
* @return {AssetType} - the list of supported asset types.
87-
* @constructor
86+
* @returns {AssetType} - the list of supported asset types.
87+
* @class
8888
*/
8989
static get AssetType () {
9090
return _AssetType;
@@ -174,7 +174,7 @@ export class ScratchStorage {
174174
/**
175175
* TODO: Should this be removed in favor of requesting an asset with `null` as the ID?
176176
* @param {AssetType} type - Get the default ID for assets of this type.
177-
* @return {?string} The ID of the default asset of the given type, if any.
177+
* @returns {?string} The ID of the default asset of the given type, if any.
178178
*/
179179
getDefaultAssetId (type: AssetType): AssetId | undefined {
180180
if (Object.prototype.hasOwnProperty.call(this.defaultAssetId, type.name)) {
@@ -199,7 +199,7 @@ export class ScratchStorage {
199199
* @param {AssetType} assetType - The type of asset to fetch. This also determines which asset store to use.
200200
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
201201
* @param {DataFormat} [dataFormat] - Optional: load this format instead of the AssetType's default.
202-
* @return {Promise.<Asset>} A promise for the requested Asset.
202+
* @returns {Promise.<Asset>} A promise for the requested Asset.
203203
* If the promise is resolved with non-null, the value is the requested asset.
204204
* If the promise is resolved with null, the desired asset could not be found with the current asset sources.
205205
* If the promise is rejected, there was an error on at least one asset source. HTTP 404 does not count as an
@@ -247,7 +247,7 @@ export class ScratchStorage {
247247
* @param {?DataFormat} [dataFormat] - Optional: load this format instead of the AssetType's default.
248248
* @param {Buffer} data - Data to store for the asset
249249
* @param {?string} [assetId] - The ID of the asset to fetch: a project ID, MD5, etc.
250-
* @return {Promise.<object>} A promise for asset metadata
250+
* @returns {Promise.<object>} A promise for asset metadata
251251
*/
252252
store (assetType: AssetType, dataFormat: DataFormat | null | undefined, data: AssetData, assetId?: AssetId) {
253253
dataFormat = dataFormat || assetType.runtimeFormat;

src/WebHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class WebHelper extends Helper {
103103
* @param {AssetType} assetType - The type of asset to fetch.
104104
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
105105
* @param {DataFormat} dataFormat - The file format / file extension of the asset to fetch: PNG, JPG, etc.
106-
* @return {Promise.<Asset>} A promise for the contents of the asset.
106+
* @returns {Promise.<Asset>} A promise for the contents of the asset.
107107
*/
108108
load (assetType: AssetType, assetId: AssetId, dataFormat: DataFormat): Promise<Asset | null> {
109109

@@ -162,7 +162,7 @@ export default class WebHelper extends Helper {
162162
* @param {?DataFormat} dataFormat - DataFormat of the data for the stored asset.
163163
* @param {Buffer} data - The data for the cached asset.
164164
* @param {?string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
165-
* @return {Promise.<object>} A promise for the response from the create or update request
165+
* @returns {Promise.<object>} A promise for the response from the create or update request
166166
*/
167167
store (
168168
assetType: AssetType,

src/memoizedToString.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ let _TextDecoder: typeof TextDecoder;
1515
let _TextEncoder: typeof TextEncoder;
1616
if (typeof TextDecoder === 'undefined' || typeof TextEncoder === 'undefined') {
1717
// Wait to require the text encoding polyfill until we know it's needed.
18-
// eslint-disable-next-line global-require
1918
const encoding = require('fastestsmallesttextencoderdecoder');
2019
_TextDecoder = encoding.TextDecoder;
2120
_TextEncoder = encoding.TextEncoder;
@@ -31,13 +30,13 @@ const memoizedToString = (function () {
3130
* 32766 is a multiple of 3 so btoa does not need to use padding characters
3231
* except for the final chunk where that is fine. 32766 is also close to
3332
* 32768 so it is close to a size an memory allocator would prefer.
34-
* @const {number}
33+
* @constant {number}
3534
*/
3635
const BTOA_CHUNK_MAX_LENGTH = 32766;
3736

3837
/**
3938
* An array cache of bytes to characters.
40-
* @const {?Array.<string>}
39+
* @constant {?Array.<string>}
4140
*/
4241
let fromCharCode: string[] | null = null;
4342

@@ -46,7 +45,6 @@ const memoizedToString = (function () {
4645
if (!Object.prototype.hasOwnProperty.call(strings, assetId)) {
4746
if (typeof btoa === 'undefined') {
4847
// Use a library that does not need btoa to run.
49-
/* eslint-disable-next-line global-require */
5048
const base64js = require('base64-js');
5149
strings[assetId] = base64js.fromByteArray(data);
5250
} else {

test/__mocks__/cross-fetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const successText = 'successful response';
2020
/**
2121
* @typedef MockFetchTestData
2222
* @property {Headers} [headers] A Headers object initialized with the header info received by mockFetch.
23-
* @property {Number} [headersCount] The number of headers in the 'headers' property.
23+
* @property {number} [headersCount] The number of headers in the 'headers' property.
2424
*/
2525

2626
/**

0 commit comments

Comments
 (0)