Ver Fonte

ESLint: Improve config. (#32520)

Michael Herzog há 1 mês atrás
pai
commit
ece4db1b75

+ 1 - 1
editor/index.html

@@ -245,7 +245,7 @@
 
 					navigator.serviceWorker.register( 'sw.js' );
 
-				} catch ( error ) { // eslint-disable-line no-unused-vars
+				} catch ( error ) {
 
 				}
 

+ 1 - 1
editor/js/Script.js

@@ -212,7 +212,7 @@ function Script( editor ) {
 
 						jsonlint.parse( string );
 
-					} catch ( error ) { // eslint-disable-line no-unused-vars
+					} catch ( error ) {
 
 						// ignore failed error recovery
 

+ 2 - 2
editor/js/Sidebar.Material.js

@@ -409,7 +409,7 @@ function SidebarMaterial( editor ) {
 			materialUserData.dom.classList.add( 'success' );
 			materialUserData.dom.classList.remove( 'fail' );
 
-		} catch ( error ) { // eslint-disable-line no-unused-vars
+		} catch ( error ) {
 
 			materialUserData.dom.classList.remove( 'success' );
 			materialUserData.dom.classList.add( 'fail' );
@@ -439,7 +439,7 @@ function SidebarMaterial( editor ) {
 			output = JSON.stringify( output, null, '\t' );
 			output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
 
-		} catch ( error ) { // eslint-disable-line no-unused-vars
+		} catch ( error ) {
 
 			output = JSON.stringify( output );
 

+ 2 - 2
editor/js/Sidebar.Object.js

@@ -386,7 +386,7 @@ function SidebarObject( editor ) {
 			objectUserData.dom.classList.add( 'success' );
 			objectUserData.dom.classList.remove( 'fail' );
 
-		} catch ( error ) { // eslint-disable-line no-unused-vars
+		} catch ( error ) {
 
 			objectUserData.dom.classList.remove( 'success' );
 			objectUserData.dom.classList.add( 'fail' );
@@ -415,7 +415,7 @@ function SidebarObject( editor ) {
 			output = JSON.stringify( output, null, '\t' );
 			output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
 
-		} catch ( error ) { // eslint-disable-line no-unused-vars
+		} catch ( error ) {
 
 			output = JSON.stringify( output );
 

+ 2 - 2
editor/sw.js

@@ -239,7 +239,7 @@ self.addEventListener( 'install', async function () {
 
 			await cache.add( asset );
 
-		} catch ( error ) { // eslint-disable-line no-unused-vars
+		} catch ( error ) {
 
 			console.warn( '[SW] Couldn\'t cache:', asset );
 
@@ -284,7 +284,7 @@ async function networkFirst( request ) {
 
 		return response;
 
-	} catch ( error ) { // eslint-disable-line no-unused-vars
+	} catch ( error ) {
 
 		const cachedResponse = await caches.match( request );
 

+ 4 - 2
eslint.config.js

@@ -111,8 +111,10 @@ export default [
 			'no-fallthrough': 'off',
 			'no-prototype-builtins': 'off',
 			'no-loss-of-precision': 'off',
-
-			// 'jsdoc/check-types': 'error',
+			'no-unused-vars': [ 'error', {
+				caughtErrors: 'none',
+			} ],
+			'jsdoc/check-types': 'error',
 			'jsdoc/require-returns': 'off',
 			'jsdoc/require-returns-type': 'error',
 			'jsdoc/require-param-description': 'off',

+ 2 - 2
examples/jsm/capabilities/WebGL.js

@@ -18,7 +18,7 @@ class WebGL {
 			const canvas = document.createElement( 'canvas' );
 			return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );
 
-		} catch ( e ) { // eslint-disable-line no-unused-vars
+		} catch ( e ) {
 
 			return false;
 
@@ -42,7 +42,7 @@ class WebGL {
 			ctx.drawingBufferColorSpace = colorSpace;
 			return ctx.drawingBufferColorSpace === colorSpace; // deepscan-disable-line SAME_OPERAND_VALUE
 
-		} catch ( e ) { // eslint-disable-line no-unused-vars
+		} catch ( e ) {
 
 			return false;
 

+ 1 - 1
examples/jsm/helpers/ViewHelper.js

@@ -378,7 +378,7 @@ class ViewHelper extends Object3D {
 
 				result = typeof OffscreenCanvas !== 'undefined' && ( new OffscreenCanvas( 1, 1 ).getContext( '2d' ) ) !== null;
 
-			} catch ( err ) { // eslint-disable-line no-unused-vars
+			} catch ( err ) {
 
 				// Ignore any errors
 

+ 1 - 1
examples/jsm/loaders/LDrawLoader.js

@@ -636,7 +636,7 @@ class LDrawParsedCache {
 				const text = await fileLoader.loadAsync( subobjectURL );
 				return text;
 
-			} catch ( _ ) { // eslint-disable-line no-unused-vars
+			} catch ( _ ) {
 
 				continue;
 

+ 1 - 1
examples/jsm/loaders/TDSLoader.js

@@ -778,7 +778,7 @@ class Chunk {
 			this.position += next.size;
 			return next;
 
-		}	catch ( e ) { // eslint-disable-line no-unused-vars
+		}	catch ( e ) {
 
 			this.debugMessage( 'Unable to read chunk at ' + this.position );
 			return null;

+ 2 - 2
examples/jsm/loaders/VRMLLoader.js

@@ -3167,8 +3167,8 @@ class VRMLLoader extends Loader {
 		 *
 		 * @param {BufferGeometry} geometry
 		 * @param {number} radius
-		 * @param {array} angles
-		 * @param {array} colors
+		 * @param {Array} angles
+		 * @param {Array} colors
 		 * @param {boolean} topDown - Whether to work top down or bottom up.
 		 */
 		function paintFaces( geometry, radius, angles, colors, topDown ) {

+ 1 - 1
examples/jsm/objects/MarchingCubes.js

@@ -560,7 +560,7 @@ class MarchingCubes extends Mesh {
 							  )
 								: new Color( colors );
 
-				} catch ( err ) { // eslint-disable-line no-unused-vars
+				} catch ( err ) {
 
 					ballColor = new Color( ballx, bally, ballz );
 

+ 1 - 1
manual/examples/3dlut-base-cube-maker.html

@@ -72,7 +72,7 @@ function handleSizeChange( event ) {
 
 		}
 
-	} catch ( e ) { // eslint-disable-line no-unused-vars
+	} catch ( e ) {
 
 		elem.style.background = 'red';
 

+ 3 - 3
manual/examples/resources/lessons-helper.js

@@ -76,13 +76,13 @@
 
 				document.getElementsByTagName( 'html' )[ 0 ].className = 'iframe';
 
-			} catch ( e ) { } // eslint-disable-line no-unused-vars
+			} catch ( e ) { }
 
 			try {
 
 				document.body.className = 'iframe';
 
-			} catch ( e ) { } // eslint-disable-line no-unused-vars
+			} catch ( e ) { }
 
 		}
 
@@ -368,7 +368,7 @@
 					// });
 					return matcher( lines[ lineNdx ] );
 
-				} catch ( e ) {} // eslint-disable-line no-unused-vars
+				} catch ( e ) {}
 
 			}
 

+ 0 - 1
manual/resources/tools/geo-picking/make-geo-picking-texture.js

@@ -3,7 +3,6 @@
 /* global shapefile */
 
 /* eslint no-console: off */
-/* eslint no-unused-vars: off */
 
 async function main() {
 

+ 1 - 1
src/animation/KeyframeTrack.js

@@ -565,7 +565,7 @@ class KeyframeTrack {
 /**
  * The value type name.
  *
- * @type {String}
+ * @type {string}
  * @default ''
  */
 KeyframeTrack.prototype.ValueTypeName = '';

+ 1 - 1
src/animation/tracks/BooleanKeyframeTrack.js

@@ -29,7 +29,7 @@ class BooleanKeyframeTrack extends KeyframeTrack {
 /**
  * The value type name.
  *
- * @type {String}
+ * @type {string}
  * @default 'bool'
  */
 BooleanKeyframeTrack.prototype.ValueTypeName = 'bool';

+ 1 - 1
src/animation/tracks/ColorKeyframeTrack.js

@@ -26,7 +26,7 @@ class ColorKeyframeTrack extends KeyframeTrack {
 /**
  * The value type name.
  *
- * @type {String}
+ * @type {string}
  * @default 'color'
  */
 ColorKeyframeTrack.prototype.ValueTypeName = 'color';

+ 1 - 1
src/animation/tracks/NumberKeyframeTrack.js

@@ -26,7 +26,7 @@ class NumberKeyframeTrack extends KeyframeTrack {
 /**
  * The value type name.
  *
- * @type {String}
+ * @type {string}
  * @default 'number'
  */
 NumberKeyframeTrack.prototype.ValueTypeName = 'number';

+ 1 - 1
src/animation/tracks/QuaternionKeyframeTrack.js

@@ -40,7 +40,7 @@ class QuaternionKeyframeTrack extends KeyframeTrack {
 /**
  * The value type name.
  *
- * @type {String}
+ * @type {string}
  * @default 'quaternion'
  */
 QuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion';

+ 1 - 1
src/animation/tracks/StringKeyframeTrack.js

@@ -29,7 +29,7 @@ class StringKeyframeTrack extends KeyframeTrack {
 /**
  * The value type name.
  *
- * @type {String}
+ * @type {string}
  * @default 'string'
  */
 StringKeyframeTrack.prototype.ValueTypeName = 'string';

+ 1 - 1
src/animation/tracks/VectorKeyframeTrack.js

@@ -26,7 +26,7 @@ class VectorKeyframeTrack extends KeyframeTrack {
 /**
  * The value type name.
  *
- * @type {String}
+ * @type {string}
  * @default 'vector'
  */
 VectorKeyframeTrack.prototype.ValueTypeName = 'vector';

+ 1 - 1
src/nodes/gpgpu/SubgroupFunctionNode.js

@@ -35,7 +35,7 @@ class SubgroupFunctionNode extends TempNode {
 		/**
 		 * The subgroup/wave intrinsic method to construct.
 		 *
-		 * @type {String}
+		 * @type {string}
 		 */
 		this.method = method;
 

+ 1 - 1
src/objects/Line.js

@@ -81,7 +81,7 @@ class Line extends Object3D {
 		 * morph targets name, the value its attribute index. This member is `undefined`
 		 * by default and only set when morph targets are detected in the geometry.
 		 *
-		 * @type {Object<String,number>|undefined}
+		 * @type {Object<string,number>|undefined}
 		 * @default undefined
 		 */
 		this.morphTargetDictionary = undefined;

+ 1 - 1
src/objects/Mesh.js

@@ -79,7 +79,7 @@ class Mesh extends Object3D {
 		 * morph targets name, the value its attribute index. This member is `undefined`
 		 * by default and only set when morph targets are detected in the geometry.
 		 *
-		 * @type {Object<String,number>|undefined}
+		 * @type {Object<string,number>|undefined}
 		 * @default undefined
 		 */
 		this.morphTargetDictionary = undefined;

+ 1 - 1
src/objects/Points.js

@@ -59,7 +59,7 @@ class Points extends Object3D {
 		 * morph targets name, the value its attribute index. This member is `undefined`
 		 * by default and only set when morph targets are detected in the geometry.
 		 *
-		 * @type {Object<String,number>|undefined}
+		 * @type {Object<string,number>|undefined}
 		 * @default undefined
 		 */
 		this.morphTargetDictionary = undefined;

+ 1 - 1
src/renderers/webgl/WebGLTextures.js

@@ -27,7 +27,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 			&& ( new OffscreenCanvas( 1, 1 ).getContext( '2d' ) ) !== null;
 
 
-	} catch ( err ) { // eslint-disable-line no-unused-vars
+	} catch ( err ) {
 
 		// Ignore any errors
 

+ 1 - 1
src/renderers/webgpu/utils/WebGPUPipelineUtils.js

@@ -271,7 +271,7 @@ class WebGPUPipelineUtils {
 
 					pipelineData.pipeline = await device.createRenderPipelineAsync( pipelineDescriptor );
 
-				} catch ( err ) { } // eslint-disable-line no-unused-vars
+				} catch ( err ) { }
 
 				const errorScope = await device.popErrorScope();
 

+ 1 - 1
src/renderers/webgpu/utils/WebGPUTextureUtils.js

@@ -791,7 +791,7 @@ class WebGPUTextureUtils {
 
 			// try/catch has been added to fix bad video frame data on certain devices, see #32391
 
-		} catch ( _ ) {} // eslint-disable-line no-unused-vars
+		} catch ( _ ) {}
 
 	}
 

+ 7 - 7
test/e2e/puppeteer.js

@@ -131,7 +131,7 @@ process.on( 'SIGINT', async () => {
 
 			await browser.close();
 
-		} catch ( e ) {} // eslint-disable-line no-unused-vars
+		} catch ( e ) {}
 
 	}
 
@@ -148,13 +148,13 @@ async function main() {
 
 		await fs.rm( 'test/e2e/output-screenshots', { recursive: true, force: true } );
 
-	} catch ( e ) {} // eslint-disable-line no-unused-vars
+	} catch ( e ) {}
 
 	try {
 
 		await fs.mkdir( 'test/e2e/output-screenshots' );
 
-	} catch ( e ) {} // eslint-disable-line no-unused-vars
+	} catch ( e ) {}
 
 	/* Find files */
 
@@ -320,7 +320,7 @@ async function preparePage( page, injection, builds, errorMessages ) {
 
 				return await arg.executionContext().evaluate( arg => arg instanceof Error ? arg.message : arg, arg );
 
-			} catch ( e ) { // eslint-disable-line no-unused-vars
+			} catch ( e ) {
 
 				// Execution context might have been already destroyed
 
@@ -377,7 +377,7 @@ async function preparePage( page, injection, builds, errorMessages ) {
 
 			}
 
-		} catch ( e ) {} // eslint-disable-line no-unused-vars
+		} catch ( e ) {}
 
 	} );
 
@@ -511,7 +511,7 @@ async function makeAttempt( page, failedScreenshots, cleanPage, isMakeScreenshot
 
 				expected = ( await Jimp.read( `examples/screenshots/${ file }.jpg`, { quality: jpgQuality } ) );
 
-			} catch ( e ) { // eslint-disable-line no-unused-vars
+			} catch ( e ) {
 
 				await screenshot.write( `test/e2e/output-screenshots/${ file }-actual.jpg` );
 				throw new Error( `Screenshot does not exist: ${ file }` );
@@ -530,7 +530,7 @@ async function makeAttempt( page, failedScreenshots, cleanPage, isMakeScreenshot
 					alpha: 0.2
 				} );
 
-			} catch ( e ) { // eslint-disable-line no-unused-vars
+			} catch ( e ) {
 
 				await screenshot.write( `test/e2e/output-screenshots/${ file }-actual.jpg` );
 				await expected.write( `test/e2e/output-screenshots/${ file }-expected.jpg` );

粤ICP备19079148号