Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

416
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!