WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#25957 closed defect (bug) (fixed)

jshint shouldn't throw errors: wp-includes/js/utils.js

Reported by: adamsilverstein Owned by: nacin
Milestone: 3.8 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-patch
Focuses: Cc:

Description

fixing these:

Linting src/wp-includes/js/utils.js ...ERROR
[L67:C56] W109: Strings must use singlequote.
    var cookie = document.cookie, e, p = name + "=", b;
Linting src/wp-includes/js/utils.js ...ERROR
[L72:C32] W109: Strings must use singlequote.
    b = cookie.indexOf("; " + p);
Linting src/wp-includes/js/utils.js ...ERROR
[L77:C20] W041: Use '!==' to compare with '0'.
      if ( b != 0 )
Linting src/wp-includes/js/utils.js ...ERROR
[L84:C31] W109: Strings must use singlequote.
    e = cookie.indexOf(";", b);
Linting src/wp-includes/js/utils.js ...ERROR
[L110:C37] W109: Strings must use singlequote.
    document.cookie = name + "=" + encodeURIComponent(value) +
Linting src/wp-includes/js/utils.js ...ERROR
[L111:C38] W109: Strings must use singlequote.
      ((expires) ? "; expires=" + expires : "") +
Linting src/wp-includes/js/utils.js ...ERROR
[L111:C53] W109: Strings must use singlequote.
      ((expires) ? "; expires=" + expires : "") +
Linting src/wp-includes/js/utils.js ...ERROR
[L112:C32] W109: Strings must use singlequote.
      ((path) ? "; path=" + path : "") +
Linting src/wp-includes/js/utils.js ...ERROR
[L112:C44] W109: Strings must use singlequote.
      ((path) ? "; path=" + path : "") +
Linting src/wp-includes/js/utils.js ...ERROR
[L113:C36] W109: Strings must use singlequote.
      ((domain) ? "; domain=" + domain : "") +
Linting src/wp-includes/js/utils.js ...ERROR
[L113:C50] W109: Strings must use singlequote.
      ((domain) ? "; domain=" + domain : "") +
Linting src/wp-includes/js/utils.js ...ERROR
[L114:C35] W109: Strings must use singlequote.
      ((secure) ? "; secure" : "");
Linting src/wp-includes/js/utils.js ...ERROR
[L114:C40] W109: Strings must use singlequote.
      ((secure) ? "; secure" : "");
Linting src/wp-includes/js/utils.js ...ERROR
[L146:C35] W117: 'userSettings' is not defined.
  var cookie = 'wp-settings-' + userSettings.uid, all = wpCookies.getHash(cookie) || {}, path = userSettings.url,
Linting src/wp-includes/js/utils.js ...ERROR
[L146:C99] W117: 'userSettings' is not defined.
  var cookie = 'wp-settings-' + userSettings.uid, all = wpCookies.getHash(cookie) || {}, path = userSettings.url,
Linting src/wp-includes/js/utils.js ...ERROR
[L156:C39] W117: 'userSettings' is not defined.
  wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, 31536000, path);
Linting src/wp-includes/js/utils.js ...ERROR
[L156:C57] W117: 'userSettings' is not defined.
  wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, 31536000, path);
Linting src/wp-includes/js/utils.js ...ERROR
[L170:C47] W117: 'userSettings' is not defined.
  return wpCookies.getHash('wp-settings-' + userSettings.uid) || {};
Linting src/wp-includes/js/utils.js ...ERROR
[L128:C24] W098: 'getUserSetting' is defined but never used.
function getUserSetting( name, def ) {
Linting src/wp-includes/js/utils.js ...ERROR
[L161:C27] W098: 'deleteUserSetting' is defined but never used.
function deleteUserSetting( name ) {

Attachments (1)

25957.diff (1.3 KB) - added by adamsilverstein 5 months ago.
clear jshint errors

Download all attachments as: .zip

Change History (6)

adamsilverstein5 months ago

clear jshint errors

comment:1 adamsilverstein5 months ago

25957.diff​ changes:

  • swap double for single quotes
  • add globals
  • add jshint config don't check undefined: functions used elsewhere in core
  • change != 0 to !== 0 @L80

comment:2 follow-up: nacin5 months ago

  • Milestone changed from Awaiting Review to 3.8

Looks good. We can used exported instead of unused.

comment:3 nacin5 months ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 26203:

Fix JSHint errors in utils.js.

props adamsilverstein.
fixes #25957.

comment:4 in reply to: ↑ 2 adamsilverstein5 months ago

Replying to nacin:

Looks good. We can used exported instead of unused.

noted, thanks.

comment:5 nacin5 months ago

In 26207:

Fix JSHint errors in two files. see #25957, #25864. (Similar names but separate files.)

Note: See TracTickets for help on using tickets.