Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Make node 8 a package.json requirement #3642

Closed
ianb opened this issue Oct 16, 2017 · 3 comments
Closed

Make node 8 a package.json requirement #3642

ianb opened this issue Oct 16, 2017 · 3 comments
Assignees
Labels
code quality Not a bug, targeted for fixing in 2018 code Code quality issue, that does not have any outward effect on the product good first issue
Milestone

Comments

@ianb
Copy link
Contributor

ianb commented Oct 16, 2017

I recently encountered a problem running under Node v6. So... somewhere along the way v8 became a hard requirement. I think there's something like an "engine" requirement we can put in package.json?

@ghost ghost added this to the Stretch milestone Oct 17, 2017
@pdehaan
Copy link
Collaborator

pdehaan commented Oct 18, 2017

Interesting, it looks like our Dockerfile is set to use Node 7.x:

FROM node:7

And the circle.yml file wants Node 8.2:

node:
version: 8.2.0

I can try digging in and seeing what APIs we're using that cause a requirement on Node 7+.

@ianb
Copy link
Contributor Author

ianb commented Oct 18, 2017

Another good thing to update! (I guess we must be compatible with 7 but not 6, but maybe we should switch to 8 everywhere for consistency)

@pdehaan
Copy link
Collaborator

pdehaan commented Oct 19, 2017

+1 to moving straight to Node 8.x. Here's a bit of play-by-play comparing Node 6 👉 7 👉 8:

Node 6:

$ npm run lint:js

> firefox-screenshots@22.0.0 lint:js /Users/pdehaan/dev/github/mozilla-services/pageshot
> eslint .

/Users/pdehaan/dev/github/mozilla-services/pageshot/addon/webextension/background/analytics.js
  45:36  error  'Object.entries' is not supported yet on Node 6.0.0  node/no-unsupported-features

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/b64.js
  3:16  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api
  8:16  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/proxy-url.js
   7:40  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api
  16:42  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/server.js
  867:42  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/servershot.js
  373:17  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api
  706:19  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

/Users/pdehaan/dev/github/mozilla-services/pageshot/test/addon/browser_screenshots_ui_check.js
  11:10  error  Async functions are not supported yet on Node 6.0.0  node/no-unsupported-features
  12:3   error  Async functions are not supported yet on Node 6.0.0  node/no-unsupported-features
  14:27  error  Async functions are not supported yet on Node 6.0.0  node/no-unsupported-features
  15:5   error  Async functions are not supported yet on Node 6.0.0  node/no-unsupported-features
  19:3   error  Async functions are not supported yet on Node 6.0.0  node/no-unsupported-features

✖ 13 problems (13 errors, 0 warnings)

Node 7

If I bump the engine to Node 7, I still get 12 problems:

$ npm run lint:js

> firefox-screenshots@22.0.0 lint:js /Users/pdehaan/dev/github/mozilla-services/pageshot
> eslint .

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/b64.js
  3:16  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api
  8:16  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/proxy-url.js
   7:40  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api
  16:42  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/server.js
  867:42  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/servershot.js
  373:17  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api
  706:19  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

/Users/pdehaan/dev/github/mozilla-services/pageshot/test/addon/browser_screenshots_ui_check.js
  11:10  error  Async functions are not supported yet on Node 7.0.0  node/no-unsupported-features
  12:3   error  Async functions are not supported yet on Node 7.0.0  node/no-unsupported-features
  14:27  error  Async functions are not supported yet on Node 7.0.0  node/no-unsupported-features
  15:5   error  Async functions are not supported yet on Node 7.0.0  node/no-unsupported-features
  19:3   error  Async functions are not supported yet on Node 7.0.0  node/no-unsupported-features

✖ 12 problems (12 errors, 0 warnings)

Node 8:

Going straight to Node 8 still gives the node/no-deprecated-api errors, but none of the node/no-unsupported-features errors:

$ npm run lint:js

> firefox-screenshots@22.0.0 lint:js /Users/pdehaan/dev/github/mozilla-services/pageshot
> eslint .

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/b64.js
  3:16  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api
  8:16  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/proxy-url.js
   7:40  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api
  16:42  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/server.js
  867:42  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

/Users/pdehaan/dev/github/mozilla-services/pageshot/server/src/servershot.js
  373:17  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api
  706:19  error  'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead  node/no-deprecated-api

✖ 7 problems (7 errors, 0 warnings)

Configs ahoy!

diff --git a/package.json b/package.json
index a0fe0c67..92892a6e 100644
--- a/package.json
+++ b/package.json
@@ -59,6 +59,7 @@
     "eslint": "4.8.0",
     "eslint-plugin-mozilla": "0.4.4",
     "eslint-plugin-no-unsanitized": "2.0.1",
+    "eslint-plugin-node": "5.2.0",
     "eslint-plugin-promise": "3.5.0",
     "eslint-plugin-react": "^7.3.0",
     "fx-runner": "1.0.8",
@@ -76,6 +77,9 @@
     "uglifyify": "4.0.4",
     "web-ext": "2.1.0"
   },
+  "engines": {
+    "node": ">=6.0.0"
+  },
   "homepage": "https://screenshots.firefox.com",
   "license": "MPL-2.0",
   "repository": {
diff --git a/.eslintrc.yml b/.eslintrc.yml
index e5341ba5..82258857 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -6,6 +6,7 @@ env:
 extends:
   - eslint:recommended
   - plugin:mozilla/recommended
+  - plugin:node/recommended
   - plugin:react/recommended

 parserOptions:
@@ -15,12 +16,27 @@ parserOptions:

 plugins:
   - mozilla
+  - node
   - react
   - promise

 root: true

 rules:
+  node/no-extraneous-require: off
+  node/no-missing-require: off
+  node/no-unpublished-require: off
+  node/shebang: off
+
   react/jsx-uses-react: warn
   react/jsx-uses-vars: warn
   react/no-deprecated: warn # TODO: change to "error"
@@ -31,15 +47,7 @@ rules:
   consistent-return: off # TODO: remove, and default to mozilla/recommended of "error"
   eqeqeq: off # TODO: change to "error"
   no-console: [error, {allow: [debug, error, info, trace, warn]}]
+  no-process-exit: off
   no-var: off # TODO: change to "error"
   prefer-const: off # TODO: change to "error"
   quotes: [off, double] # TODO: change to "error"

@ianb ianb added code Code quality issue, that does not have any outward effect on the product code quality Not a bug, targeted for fixing in 2018 labels Jan 10, 2018
@jaredhirsch jaredhirsch self-assigned this Feb 13, 2018
@chenba chenba closed this as completed in 2423408 Feb 14, 2018
chenba added a commit that referenced this issue Feb 14, 2018
Fix #3642, Require node 8 for docker and in package.json
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
code quality Not a bug, targeted for fixing in 2018 code Code quality issue, that does not have any outward effect on the product good first issue
Projects
None yet
Development

No branches or pull requests

4 participants