WordPress / wp-autoupdates

Feature plugin building a UI for opting-in to plugin, theme, and core auto-updates.
https://wordpress.org/plugins/wp-autoupdates/
GNU General Public License v2.0
56 stars 18 forks source link

JS Coding Standards #111

Closed ntwb closed 4 years ago

ntwb commented 4 years ago

This PR seeks to update the js/wp-autoupdates.js file per WordPress Coding Standards

This is performed via the Add@wordpress/scripts` package

To test this PR check out the branch and run npm install

The JS file has already been formatted with Prettier run format:js via c75714a

To run the lint check using WP Coding Standards for CSS & JS run

For CSS Run npm run lint:css For JS Run npm run lint:js

To run both, run npm test (or npm t)

The following ESLint warnings are displayed from the lint:js task:

/Users/netweb/Code/WordPress/wp-autoupdates/js/wp-autoupdates.js
    1:1   error  'jQuery' is not defined                             no-undef
    2:11  error  Identifier 'add_error_notice' is not in camel case  camelcase
   15:4   error  Unexpected var, use let or const instead            no-var
   17:4   error  Unexpected var, use let or const instead            no-var
   17:15  error  'wpAjax' is not defined                             no-undef
   18:4   error  Unexpected var, use let or const instead            no-var
   21:4   error  Unexpected var, use let or const instead            no-var
   26:6   error  'wp_autoupdates' is not defined                     no-undef
   30:5   error  'ajaxurl' is not defined                            no-undef
   37:15  error  'response' is defined but never used                no-unused-vars
   49:22  error  'wp_autoupdates' is not defined                     no-undef
   51:7   error  Unexpected var, use let or const instead            no-var
   59:22  error  'response' is defined but never used                no-unused-vars
   60:6   error  Unexpected var, use let or const instead            no-var
   62:7   error  'wp_autoupdates' is not defined                     no-undef
   64:21  error  'wp_autoupdates' is not defined                     no-undef
   67:24  error  'response' is defined but never used                no-unused-vars
   76:4   error  Unexpected var, use let or const instead            no-var
   78:4   error  Unexpected var, use let or const instead            no-var
   78:15  error  'wpAjax' is not defined                             no-undef
   79:4   error  Unexpected var, use let or const instead            no-var
   82:4   error  Unexpected var, use let or const instead            no-var
   90:7   error  'wp_autoupdates' is not defined                     no-undef
   94:5   error  'ajaxurl' is not defined                            no-undef
  101:15  error  'response' is defined but never used                no-unused-vars
  113:22  error  'wp_autoupdates' is not defined                     no-undef
  115:7   error  Unexpected var, use let or const instead            no-var
  123:22  error  'response' is defined but never used                no-unused-vars
  124:6   error  Unexpected var, use let or const instead            no-var
  126:7   error  'wp_autoupdates' is not defined                     no-undef
  128:21  error  'wp_autoupdates' is not defined                     no-undef
  131:24  error  'response' is defined but never used                no-unused-vars
  140:4   error  Unexpected var, use let or const instead            no-var
  142:4   error  Unexpected var, use let or const instead            no-var
  142:15  error  'wpAjax' is not defined                             no-undef
  143:4   error  Unexpected var, use let or const instead            no-var
  146:4   error  Unexpected var, use let or const instead            no-var
  151:6   error  'wp_autoupdates' is not defined                     no-undef
  155:5   error  'ajaxurl' is not defined                            no-undef
  162:15  error  'response' is defined but never used                no-unused-vars
  174:22  error  'wp_autoupdates' is not defined                     no-undef
  176:7   error  Unexpected var, use let or const instead            no-var
  184:22  error  'response' is defined but never used                no-unused-vars
  185:6   error  Unexpected var, use let or const instead            no-var
  187:7   error  'wp_autoupdates' is not defined                     no-undef
  189:21  error  'wp_autoupdates' is not defined                     no-undef
  192:24  error  'response' is defined but never used                no-unused-vars
  201:4   error  Unexpected var, use let or const instead            no-var
  203:4   error  Unexpected var, use let or const instead            no-var
  203:15  error  'wpAjax' is not defined                             no-undef
  204:4   error  Unexpected var, use let or const instead            no-var
  207:4   error  Unexpected var, use let or const instead            no-var
  215:7   error  'wp_autoupdates' is not defined                     no-undef
  219:5   error  'ajaxurl' is not defined                            no-undef
  226:15  error  'response' is defined but never used                no-unused-vars
  238:22  error  'wp_autoupdates' is not defined                     no-undef
  240:7   error  Unexpected var, use let or const instead            no-var
  248:22  error  'response' is defined but never used                no-unused-vars
  249:6   error  Unexpected var, use let or const instead            no-var
  251:7   error  'wp_autoupdates' is not defined                     no-undef
  253:21  error  'wp_autoupdates' is not defined                     no-undef
  256:24  error  'response' is defined but never used                no-unused-vars
  264:3   error  Unexpected var, use let or const instead            no-var
  266:3   error  Unexpected var, use let or const instead            no-var
  266:14  error  'wpAjax' is not defined                             no-undef
  267:3   error  Unexpected var, use let or const instead            no-var
  270:3   error  Unexpected var, use let or const instead            no-var
  275:5   error  'wp_autoupdates' is not defined                     no-undef
  279:4   error  'ajaxurl' is not defined                            no-undef
  286:14  error  'response' is defined but never used                no-unused-vars
  292:21  error  'wp_autoupdates' is not defined                     no-undef
  294:6   error  Unexpected var, use let or const instead            no-var
  302:21  error  'response' is defined but never used                no-unused-vars
  303:5   error  Unexpected var, use let or const instead            no-var
  305:6   error  'wp_autoupdates' is not defined                     no-undef
  307:20  error  'wp_autoupdates' is not defined                     no-undef
  310:23  error  'response' is defined but never used                no-unused-vars
  317:3   error  Unexpected var, use let or const instead            no-var
  319:3   error  Unexpected var, use let or const instead            no-var
  319:14  error  'wpAjax' is not defined                             no-undef
  320:3   error  Unexpected var, use let or const instead            no-var
  323:3   error  Unexpected var, use let or const instead            no-var
  330:6   error  'wp_autoupdates' is not defined                     no-undef
  334:4   error  'ajaxurl' is not defined                            no-undef
  341:14  error  'response' is defined but never used                no-unused-vars
  347:21  error  'wp_autoupdates' is not defined                     no-undef
  349:6   error  Unexpected var, use let or const instead            no-var
  357:21  error  'response' is defined but never used                no-unused-vars
  358:5   error  Unexpected var, use let or const instead            no-var
  360:6   error  'wp_autoupdates' is not defined                     no-undef
  362:20  error  'wp_autoupdates' is not defined                     no-undef
  365:23  error  'response' is defined but never used                no-unused-vars

✖ 92 problems (92 errors, 0 warnings)
  36 errors and 0 warnings potentially fixable with the `--fix` option.

Some of these are easy fixes using ESLint --fix option, others not so much


The background of the reason for this PR is that any new code being merged to WordPress should meet the WordPress Coding Standards

With some luck I'm hoping to get ESLint added in WP 5.5 to test that any new JS code introduced will meet the coding standards before being committed to the SVN repo


I'll leave this a draft PR for the time being, I don't think it should be merged as it will add more code to the repo that isn't going to be used when merged to core, feel free to push commits to this branch and then the final JS changes can be cherry-picked back to the master branch would be my suggestion

pbiron commented 4 years ago

Hi @ntwb, thanx for the PR.

As you many have seen, I merged another PR yesterday that completely replaced all the JS that yours cleans up. Can you please refresh this PR against the current master?

It is still a good idea to have Prettier available to be run on the new JS, so thanx for that!!

ntwb commented 4 years ago

lol, I didn't even check, I wrote that patch on Saturday and forgot to push it up

I'll go comment on the #118 PR from @whyisjake now