Repository: pixijs/pixijs
File: packages/spritesheet/src/spritesheetAsset.ts (TypeScript)

Code before:
    /**
     * Loader plugin that parses sprite sheets!
     * once the JSON has been loaded this checks to see if the JSON is spritesheet data.
     * If it is, we load the spritesheets image and parse the data into PIXI.Spritesheet
     * All textures in the sprite sheet are then added to the cache
     * @ignore
     */
    loader: {
        name: 'spritesheetLoader',

        extension: {
            type: ExtensionType.LoadParser,
            priority: LoaderParserPriority.Normal,
        },

        async testParse(asset: SpriteSheetJson, options: ResolvedAsset): Promise<boolean>
        {
            return (utils.path.extname(options.src).toLowerCase() === '.json' && !!asset.frames);
        },

        async parse(asset: SpriteSheetJson, options: ResolvedAsset, loader: Loader): Promise<Spritesheet>
        {
            const {
                texture: imageTexture, // if user need to use preloaded texture
                imageFilename // if user need to use custom filename (not from jsonFile.meta.image)
            } = options?.data || { texture: undefined, imageFilename: undefined };

            let basePath = utils.path.dirname(options.src);

            if (basePath && basePath.lastIndexOf('/') !== (basePath.length - 1))
            {
                basePath += '/';
            }

            let texture: Texture;

            if (imageTexture && imageTexture.baseTexture)
            {
                texture = imageTexture;
            }
            else
            {
                let imagePath = '';

                if (imageFilename)
                {
                    imagePath = basePath + imageFilename;
                }
                else
                {
                    imagePath = basePath + asset.meta.image;

Review comment (refactor):
Simplify this a little, we don't need the undefineds to do the destructuring. 
```suggestion
            } = options?.data ?? {};
```


Code after:
    /**
     * Loader plugin that parses sprite sheets!
     * once the JSON has been loaded this checks to see if the JSON is spritesheet data.
     * If it is, we load the spritesheets image and parse the data into PIXI.Spritesheet
     * All textures in the sprite sheet are then added to the cache
     * @ignore
     */
    loader: {
        name: 'spritesheetLoader',

        extension: {
            type: ExtensionType.LoadParser,
            priority: LoaderParserPriority.Normal,
        },

        async testParse(asset: SpriteSheetJson, options: ResolvedAsset): Promise<boolean>
        {
            return (utils.path.extname(options.src).toLowerCase() === '.json' && !!asset.frames);
        },

        async parse(asset: SpriteSheetJson, options: ResolvedAsset, loader: Loader): Promise<Spritesheet>
        {
            const {
                texture: imageTexture, // if user need to use preloaded texture
                imageFilename // if user need to use custom filename (not from jsonFile.meta.image)
            } = options?.data ?? {};

            let basePath = utils.path.dirname(options.src);

            if (basePath && basePath.lastIndexOf('/') !== (basePath.length - 1))
            {
                basePath += '/';
            }

            let texture: Texture;

            if (imageTexture && imageTexture.baseTexture)
            {
                texture = imageTexture;
            }
            else
            {
                const imagePath = copySearchParams(basePath + (imageFilename ?? asset.meta.image), options.src);

                const assets = await loader.load<Texture>([imagePath]);

                texture = assets[imagePath];
            }

            const spritesheet = new Spritesheet(
                texture.baseTexture,