简体   繁体   中英

Code Sniffer error into js code

I have been searching since yesterday for the resolution of two code sniffer errors :

62 | ERROR | [x] Expected 1 space after closing parenthesis; found
   |       |     " options.keys = $.extend(\n

Here is my code :

  if (newOptions.keys) options.keys = $.extend(
     {
     shift: 1,
     ctrl: 'resize' },
     newOptions.keys
  );

I would like to have the eye of an outside person to solve this, thanks for your attention :)

I'd have to see the rest of the file to be able to generate and fix that Expected 1 space after closing parenthesis error, but if you want to format that IF statement in a way that PSR2 is happy with, you'd do this:

if (newOptions.keys) {
    options.keys = $.extend(
        {
            shift: 1,
            ctrl: 'resize'
        },
        newOptions.keys
    );
}

If you are using a standard that allows inline control structures, you can ignore the PSR2 error for that and use this code instead:

if (newOptions.keys) options.keys = $.extend(
    {
        shift: 1,
        ctrl: 'resize'
    },
    newOptions.keys
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM