nuxt-modules / svg-sprite

Optimize SVG files and combine them into sprite
https://codesandbox.io/s/github/nuxt-community/svg-sprite-module/
MIT License
301 stars 42 forks source link

style(plugin): better formatting #246

Closed mrazauskas closed 3 years ago

mrazauskas commented 3 years ago

Improved formatting for plugin template. Improves readily of the rendered plugin file (see bellow). Follows ESLint rules of the repository.

Before:

const SPRITES = {
"dreams": () => import('../../assets/sprite/gen/dreams.svg'),"empty-defs": () => import('../../assets/sprite/gen/empty-defs.svg'),"love": () => import('../../assets/sprite/gen/love.svg'),"icons": () => import('../../assets/sprite/gen/icons.svg')
}

export default function(context, inject) {
    inject('svgSprite', svgSprite({
        importSprite: key => SPRITES[key] ? SPRITES[key]() : Promise.resolve(""),
        defaultSprite: 'icons',
        spriteClassPrefix: 'sprite-',
        spriteClass: 'icon',
    }))
}

After:

const SPRITES = {
  'dreams': () => import('../../assets/sprite/gen/dreams.svg'),
  'empty-defs': () => import('../../assets/sprite/gen/empty-defs.svg'),
  'love': () => import('../../assets/sprite/gen/love.svg'),
  'icons': () => import('../../assets/sprite/gen/icons.svg')
}

export default function (_, inject) {
  inject('svgSprite', svgSprite({
    importSprite: key => SPRITES[key] ? SPRITES[key]() : Promise.resolve(''),
    defaultSprite: 'icons',
    spriteClassPrefix: 'sprite-',
    spriteClass: 'icon'
  }))
}