sheerun / prettier-standard

Formats with Prettier and lints with ESLint+Standard! (✿◠‿◠)
MIT License
868 stars 44 forks source link

Rx defaults are not exported #36

Closed Kikobeats closed 6 years ago

Kikobeats commented 6 years ago

Using node 8 LTS:

$ g ac "Remove logo from state"
husky > npm run -s precommit (node v9.2.0)

 ❯ Running tasks for *.js
   ✖ prettier-standard
     → at Module._compile (module.js:641:30)
     git add
✖ prettier-standard found some errors. Please fix them and try committing again.

          /Users/josefranciscoverdugambin/Projects/microlink/react-microlink/node_modules/prettier-standard/lib/format-files.js:132
var rxGlob = _Rx2.default.Observable.bindNodeCallback(_glob2.default);
                      ^

TypeError: Cannot read property 'Observable' of undefined
at Object.<anonymous> (/Users/josefranciscoverdugambin/Projects/microlink/react-microlink/node_modules/prettier-standard/lib/format-files.js:132:27)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
at Module.require (module.js:585:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/josefranciscoverdugambin/Projects/microlink/react-microlink/node_modules/prettier-standard/lib/index.js:41:20)
at Module._compile (module.js:641:30)

husky > pre-commit hook failed (add --no-verify to bypass)

I think code is not relevant; Rx polyfill is not exporting defaults 😢

fiuzagr commented 6 years ago

Install the rxjs@5.4.3 solved for me.

npm install rxjs@5.4.3 --save-dev
matthewdordal commented 6 years ago

I had this same issue and had to install rxjs@5.4.3 as a devDependency. My node version is 8.9.1

> redux-history-push-middleware@0.0.1 format /Users/matthewdordal/sites/redux-history-push-middleware
> npx prettier-standard 'src/**/*.js'

Cannot read property 'Observable' of undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! redux-history-push-middleware@0.0.1 format: `npx prettier-standard 'src/**/*.js'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the redux-history-push-middleware@0.0.1 format script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/matthewdordal/.npm/_logs/2017-12-05T04_18_46_383Z-debug.log
okuryu commented 6 years ago

This seems to be a regression of rxjs. I verified it resolved following fixes for prettier-standard, but rxjs's fixes might coming soon. See also https://github.com/ReactiveX/rxjs/issues/3155#issuecomment-349027028

diff --git a/package.json b/package.json
index 3cf2fd0..9310ca8 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
     "messageformat": "^1.0.2",
     "prettier": "1.7.x",
     "prettier-eslint": "^8.1.1",
-    "rxjs": "^5.4.0"
+    "rxjs": "^5.5.3"
   },
   "devDependencies": {
     "babel-cli": "^6.24.1",
diff --git a/src/format-files.js b/src/format-files.js
index eefc135..a576ee0 100644
--- a/src/format-files.js
+++ b/src/format-files.js
@@ -2,7 +2,7 @@
 import path from 'path'
 import fs from 'fs'
 import glob from 'glob'
-import Rx from 'rxjs/Rx'
+import * as Rx from 'rxjs/Rx'
 import format from 'prettier-eslint'
 import chalk from 'chalk'
 import getStdin from 'get-stdin'
dan-gamble commented 6 years ago

Weirdly enough, even when doing @fiuzagr's suggestion of npm install rxjs@5.4.3 --save-dev on yarn (yarn add -D rxjs@5.4.3) it doesn't work but when doing it on npm it does 👍

okuryu commented 6 years ago

rxjs@5.5.4 has been released. This issue looks resolved now.

sheerun commented 6 years ago

Sorry for the trouble, it's good that rxjs decided to revert backward incompatibility