Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

420
Vistas
Fix - expected an assignment or function call and instead saw an expression

I am trying to fix this Eslint error:

Expected an assignment or function call an instead saw an expression

Any idea on how I can accommodate the code so that it doesn't give me that error in following sample code?

window.matchMedia || (window.matchMedia = function() {
 
  if (!styleMedia) {
    const style = document.createElement('style');

    const script = document.getElementsByTagName('script')[0];

    let info = null;

    style.type  = 'text/css';
    style.id    = 'matchmediajs-test';

    script.parentNode.insertBefore(style, script);

    info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle;

    styleMedia = {
      matchMedium: function(media) {
        const text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }';

     
        if (style.styleSheet) {
          style.styleSheet.cssText = text;
        } else {
          style.textContent = text;
        }

        return info.width === '1px';
      },
    };
  }

  return function(media) {
    return {
      matches: styleMedia.matchMedium(media || 'all'),
      media: media || 'all',
    };
  };
}());

Any idea why I am getting this lint error?

Thank you

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your first line (which encloses the whole script, actually)

window.matchMedia || (window.matchMedia = function() {

is an expression, not an assignment or function call. You instead need something like:

if (!window.matchMedia) {
  window.matchMedia = function() {
    // ..
}

instead of assigning inside the conditional.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda