Giter Site home page Giter Site logo

raven-for-redux's Introduction

Travis Codecov .

Deprecated

Sentry now recommends using their new SDK @sentry/browser rather than Raven. Check out redux-sentry-middleware for an API compatible fork of this library that supports the new SDK!

Raven Middleware for Redux

Note: Requires Raven >= 3.9.0. Raven 3.14.0 has a bug which this library triggers

Logs the type of each dispatched action to Raven as "breadcrumbs" and attaches your last action and current Redux state as additional context.

Inspired by redux-raven-middleware but with a slightly different approach.

Installation

npm install --save raven-for-redux

Usage

Browser

// store.js

import Raven from "raven-js"; // Or, you might already have this as `window.Raven`.
import { createStore, applyMiddleware } from "redux";
import createRavenMiddleware from "raven-for-redux";

import { reducer } from "./my_reducer";

Raven.config("<YOUR_DSN>").install();

export default createStore(
    reducer,
    applyMiddleware(
        // Middlewares, like `redux-thunk` that intercept or emit actions should
        // precede `raven-for-redux`.
        createRavenMiddleware(Raven, {
            // Optionally pass some options here.
        })
    )
);

For a working example, see the example directory.

TypeScript

raven-for-redux has TypeScript bindings available through DefinitelyTyped. Please note the import style below, as it differs from the JavaScript example and is required for these typings.

import * as Raven from "raven-js";
import * as createRavenMiddleware from "raven-for-redux";
import { applyMiddleware, createStore } from "redux";

//... (same as JavaScript example, but now with proper typings)

Improvements

This library makes, what I think are, a few improvements over redux-raven-middlware:

  1. Raven is injected rather than being setup inside the middleware. This allows for more advanced configuration of Raven, as well as cases where Raven has already been initialized. For example, if you include Raven as its own <script> tag.
  2. Adds your state and last action as context to all errors, not just reducer exceptions.
  3. Allows filtering action breadcrumbs before sending to Sentry
  4. Allows you to define a user context mapping from the state

API: createRavenMiddleware(Raven, [options])

Arguments

  • Raven (Raven Object): A configured and "installed" Raven object.
  • [options] (Object): See below for detailed documentation.

Options

While the default configuration should work for most use cases, Raven for Redux can be configured by providing an options object with any of the following optional keys.

breadcrumbMessageFromAction (Function)

Default: action => action.type

breadcrumbMessageFromAction allows you to specify a transform function which is passed the action object and returns a string that will be used as the message of the breadcrumb.

By default breadcrumbMessageFromAction returns action.type.

Finally, be careful not to mutate your action within this function.

See the Sentry Breadcrumb documentation.

breadcrumbDataFromAction (Function)

Default: action => undefined

Raven allows you to attach additional context information to each breadcrumb in the form of a data object. breadcrumbDataFromAction allows you to specify a transform function which is passed the action object and returns a data object. Which will be logged to Sentry along with the breadcrumb.

Ideally we could log the entire content of each action. If we could, we could perfectly replay the user's entire session to see what went wrong.

However, the default implementation of this function returns undefined, which means no data is attached. This is because there are a few gotchas:

  • The data object must be "flat". In other words, each value of the object must be a string. The values may not be arrays or other objects.
  • Sentry limits the total size of your error report. If you send too much data, the error will not be recorded. If you are going to attach data to your breadcrumbs, be sure you understand the way it will affect the total size of your report.

Finally, be careful not to mutate your action within this function.

See the Sentry Breadcrumb documentation.

actionTransformer (Function)

Default: action => action

In some cases your actions may be extremely large, or contain sensitive data. In those cases, you may want to transform your action before sending it to Sentry. This function allows you to do so. It is passed the last dispatched action object, and should return a serializable value.

Be careful not to mutate your action within this function.

If you have specified a dataCallback when you configured Raven, note that actionTransformer will be applied before your specified dataCallback.

stateTransformer (Function)

Default: state => state

In some cases your state may be extremely large, or contain sensitive data. In those cases, you may want to transform your state before sending it to Sentry. This function allows you to do so. It is passed the current state object, and should return a serializable value.

Be careful not to mutate your state within this function.

If you have specified a dataCallback when you configured Raven, note that stateTransformer will be applied before your specified dataCallback.

breadcrumbCategory (String)

Default: "redux-action"

Each breadcrumb is assigned a category. By default all action breadcrumbs are given the category "redux-action". If you would prefer a different category name, specify it here.

filterBreadcrumbActions (Function)

Default: action => true

If your app has certain actions that you do not want to send to Sentry, pass a filter function in this option. If the filter returns a truthy value, the action will be added as a breadcrumb, otherwise the action will be ignored. Note: even when the action has been filtered out, it may still be sent to Sentry as part of the extra data, if it was the last action before an error.

This option was introduced in version 1.1.1.

getUserContext (Optional Function)

Signature: state => userContext

Raven allows you to associcate a user context with each error report. getUserContext allows you to define a mapping from your Redux state to the user context. When getUserContext is specified, the result of getUserContext will be used to derive the user context before sending an error report. Be careful not to mutate your state within this function.

If you have specified a dataCallback when you configured Raven, note that getUserContext will be applied before your specified dataCallback. When a getUserContext function is given, it will override any previously set user context.

This option was introduced in version 1.2.0.

getTags (Optional Function)

Signature: state => tags

Raven allows you to associate tags with each report. getTags allows you to define a mapping from your Redux state to an object of tags (key β†’ value). Be careful not to mutate your state within this function.

This option was introduced in version 1.3.1.

Changelog

1.4.0

  • Add breadcrumbMessageFromAction method. (#98)

1.3.1

  • Add getTags option. (#69)

1.3.0

  • The Raven "extras" that we add are merged with existing extras rather than replacing them. (#59)

1.2.0

  • Add getUserContext option. (#49)

1.1.1

  • Add filterBreadcrumbActions option. (#39)

1.0.0

  • No changes. Just bringing the project out of beta.

0.7.1

  • Refactor: Use implicit binding to track the state/last action. (1def9a7)

0.7.0

  • Return the next middleware's (or the actual dispatch function's) return value. (#11)

0.6.0

  • actionTransformer and stateTransformer are only run when reporting an error, rather than on every action. (#8)

raven-for-redux's People

Contributors

atticoos avatar bjudson avatar captbaritone avatar chiubaka avatar greenkeeper[bot] avatar odinuge avatar zjr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

raven-for-redux's Issues

Jest Test Error

I installed the sentry package and integrated this package for redux which is working fine not until in started using the package on some component I have tested with jest and I keep getting a very weird error TypeError: Cannot use 'in' operator to search for 'fetch' in true which has to deal with raven.

Now if i remove it from the component the test seems to go, any idea

Overwriting of `extra` when capturing an exception

I've implemented this library in my Redux middleware and it's generally working quite well.

However, I've also set up some React Error Boundaries that report to my Sentry.io instance, as per https://blog.sentry.io/2017/09/28/react-16-error-boundaries.

When I manually trigger Raven.captureException in my Error Boundary component as per the blog post, an exception is logged on Sentry, but without the componentStack part being in the extra part of the data that is being sent to Sentry. The state is there as expected.

If I inspect the network request that's being made to Sentry, it's the same. The state is there, but the property that was added to extra in the captureException call has been discarded.

add action to breadcrumb

Add the whole action to breadcrumb. Normally people add payload to their action, this way, we can make a report more "reproducible". I believe right now we're only adding action.type in breadcrumb.

Support auto reporting of `error` FSA

How about the middleware to catch FSA with error === true automatically. Whenever it sees a FSA with the error key set to true it could report the error.

if (action.error === true) {
  Raven.captureException(action.payload, {
    extra: action.meta
  });
}

Getting large memory leaks

I'm getting some large memory leaks on my Express server with this library when doing server side rendering (SSR). Is anyone else getting the same thing?

Following this, I ran some tests with autocannon. https://www.npmjs.com/package/autocannon

  autocannon({
      url: 'http://localhost:3000',
      connections: 100,
      pipelining: 1,
      duration: 2 * 60
    })

The dotted blue line is when I took out raven-for-redux. As you can see, the memory leak seems to have disappeared after taking out raven-for-redux. The other tests are just attempted fixes, but that didn't have any effect.

screen shot 2018-01-03 at 3 28 29 pm

not working with redux-saga middleware

Hi

I am using this middleware along with redux-saga middleware, it seems like the action thrown from the reducer cannot be caught.

FYI: I use redux-actions to create my actions and reducers, etc.
error stacks:

uncaught at starConversationRequestedSaga Error: star error occur in state!!
    at eval (webpack-internal:///./src/reducers/conversation/star.js:73:9)
    at eval (webpack-internal:///./node_modules/redux-actions/es/handleAction.js:49:64)
    at eval (webpack-internal:///./node_modules/reduce-reducers/lib/index.js:13:14)
    at Array.reduce (<anonymous>)
    at eval (webpack-internal:///./node_modules/reduce-reducers/lib/index.js:12:21)
    at eval (webpack-internal:///./node_modules/redux-actions/es/handleActions.js:33:12)
    at eval (webpack-internal:///./src/reducers/reset.js:32:14)
    at combination (webpack-internal:///./node_modules/redux/es/combineReducers.js:124:29)
    at eval (webpack-internal:///./node_modules/redux-persist/es/persistReducer.js:110:33)
    at computeNextEntry (<anonymous>:2:27469)
    at recomputeStates (<anonymous>:2:27769)
    at <anonymous>:2:31382
    at Object.dispatch (webpack-internal:///./node_modules/redux/es/createStore.js:170:22)
    at dispatch (<anonymous>:2:31875)
    at eval (webpack-internal:///./node_modules/raven-for-redux/built/index.js:48:16)
    at eval (webpack-internal:///./node_modules/redux-saga/es/internal/middleware.js:70:22)
    at dispatch (webpack-internal:///./node_modules/redux/es/applyMiddleware.js:37:18)
    at eval (webpack-internal:///./node_modules/redux-saga/es/internal/utils.js:282:12)
    at eval (webpack-internal:///./node_modules/redux-saga/es/internal/proc.js:498:52)
    at exec (webpack-internal:///./node_modules/redux-saga/es/internal/scheduler.js:22:5)
    at flush (webpack-internal:///./node_modules/redux-saga/es/internal/scheduler.js:63:5)
    at asap (webpack-internal:///./node_modules/redux-saga/es/internal/scheduler.js:36:5)
    at Array.eval (webpack-internal:///./node_modules/redux-saga/es/internal/channel.js:196:71)
    at Object.emit (webpack-internal:///./node_modules/redux-saga/es/internal/channel.js:37:13)
    at Object.eval [as dispatch] (webpack-internal:///./node_modules/redux-saga/es/internal/middleware.js:71:21)
    at dispatch (<anonymous>:2:1620)
    at eval (webpack-internal:///./node_modules/redux/es/bindActionCreators.js:4:12)
    at starConversation (webpack-internal:///./src/components/Index/ConversationListLayout/ConversationTableView/ConversationCells/index.js:109:15)
    at onClick (webpack-internal:///./src/components/Index/ConversationListLayout/ConversationTableView/ConversationCells/ConversationCell/index.js:86:15)
    at HTMLUnknownElement.callCallback (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1299:14)
    at HTMLUnknownElement.wrapped (webpack-internal:///./node_modules/raven-js/src/raven.js:351:21)
    at Object.invokeGuardedCallbackDev (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1338:16)
    at Object.invokeGuardedCallback (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1195:27)
    at Object.invokeGuardedCallbackAndCatchFirstError (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1209:43)
    at executeDispatch (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1432:21)
    at Object.executeDispatchesInOrder (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1451:7)
    at executeDispatchesAndRelease (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1969:24)
    at executeDispatchesAndReleaseTopLevel (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1980:10)
    at Array.forEach (<anonymous>)
    at forEachAccumulated (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1946:9)
    at Object.processEventQueue (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:2139:7)
    at runEventQueueInBatch (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:2151:20)
    at Object.handleTopLevel [as _handleTopLevel] (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:2161:5)
    at handleTopLevelImpl (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1800:27)
    at batchedUpdates (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:13238:14)
    at performFiberBatchedUpdates (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1646:10)
    at stackBatchedUpdates (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1637:10)
    at batchedUpdates (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1651:10)
    at Object.batchedUpdatesWithControlledComponents [as batchedUpdates] (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1664:12)
    at dispatchEvent (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:1874:30)

Thanks

An in-range update of babel-jest is breaking the build 🚨

Version 20.0.1 of babel-jest just got published.

Branch Build failing 🚨
Dependency babel-jest
Current Version 20.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-jest is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Using dispatch in componentWillMount

In some components I am using dispatch function directly. If I do this in componentWillMount lifecycle methods I get uncaught error Cannot read property 'type' of undefined.

index.js:22 Uncaught TypeError: 
    at index.js:22
    at index.js:14
    at Object.dispatch (bindActionCreators.js:7)
    at CalendarView.componentWillMount (CalendarView.jsx:15)

My component using dispatch function:

componentWillMount() {
  this.props.dispatch({ type: 'start' });
}

const mapDispatchToProps = dispatch => bindActionCreators({
  dispatch,
}, dispatch);

I have changed dispatched action to action creator and it solved the problem, but I do not not understand why I can't use dispatch in componentWillMount() when using this library

An in-range update of webpack-dev-server is breaking the build 🚨

Version 2.10.0 of webpack-dev-server was just published.

Branch Build failing 🚨
Dependency webpack-dev-server
Current Version 2.9.7
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

webpack-dev-server is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v2.10.0

Version 2.10.0 adds the transpilation of the client scripts via babel to ES5 which restores backwards compatibility (that was removed in 2.8.0) to very old or out of date browsers.

Important webpack-dev-server has entered a maintenance-only mode. We won't be accepting any new features or major modifications. We'll still welcome pull requests for fixes however, and will continue to address any bugs that arise. Announcement with specifics pending.

Bugfixes

  • iOS Safari 10 bug where SockJS couldn't be found (#1238)
  • reportTime option (#1209)
  • don't mutate stats configuration (#1174)
  • enable progress from config (#1181)

Updates

  • transpile client bundles with babel (#1242)
  • dependency updates (ce30460)
  • Increase minimum marked version for ReDos vuln (#1255)
  • Update sockjs dependency to fix auditjs security vulnerability warning
Commits

The new version differs by 13 commits.

  • ca8b5aa 2.10.0 (#1258)
  • 17355f0 transpile client bundles with babel (#1242)
  • ce30460 rolling back webpack-dev-midddleware 2.0, as it's node6+
  • 00e8500 updating deps and patching as necessary
  • 082ddae maint only mode
  • c9c61f2 fix(package): Increase minimum marked version for ReDos vuln (#1255)
  • aab49de iOS Safari 10 bug where SockJS couldn't be found (#1238)
  • a168b81 feat: reportTime option (#1209)
  • 32c3ceb don't mutate stats configuration (#1174)
  • ef18fc8 Update sockjs dependency to fix auditjs security vulnerability warning (#1178)
  • 7e89442 enable progress from config (#1181)
  • e8964d1 add --progress cli test (#1182)
  • a9327e5 Fix typos (#1236)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Running on node-js causes a memory leak

Setting it up in a running server-side-rendering app causes the memory grows constantly:

screenshot_2018-06-26 node vms - eduk-beta-web-prd a4845384a7b3 - new relic

(it goes down when the server restarts the node process due memory restrictions)

The only difference is that I setup Raven globally:

global.Raven = require('raven');

I do this because I setup differently on client-side.

My store middlewares are:

import { createStore, applyMiddleware, compose } from 'redux';
import createRavenMiddleware from 'raven-for-redux';
import thunk from 'redux-thunk';
import rootReducer from '../reducers';

const composeEnhancers = (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose;

const configureStore = (preloadedState = {}) => createStore(
  rootReducer,
  preloadedState,
  composeEnhancers(
    applyMiddleware(thunk),
    applyMiddleware(createRavenMiddleware(Raven)),
  ),
);

In my packages.json, I have these versions:

    "raven-for-redux": "^1.3.1",
    "react-redux": "^5.0.3",
    "redux": "^3.6.0",
    "redux-thunk": "^2.2.0",

This behavior happens on nodejs 8.9.4 and 10.3.0.

An in-range update of eslint is breaking the build 🚨

Version 4.15.0 of eslint was just published.

Branch Build failing 🚨
Dependency eslint
Current Version 4.14.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v4.15.0
  • 6ab04b5 New: Add context.report({ messageId }) (fixes #6740) (#9165) (Jed Fox)
  • fc7f404 Docs: add url to each of the rules (refs #6582) (#9788) (Patrick McElhaney)
  • fc44da9 Docs: fix sort-imports rule block language (#9805) (ferhat elmas)
  • 65f0176 New: CLIEngine#getRules() (refs #6582) (#9782) (Patrick McElhaney)
  • c64195f Update: More detailed assert message for rule-tester (#9769) (Weijia Wang)
  • 9fcfabf Fix: no-extra-parens false positive (fixes: #9755) (#9795) (Erin)
  • 61e5fa0 Docs: Add table of contents to Node.js API docs (#9785) (Patrick McElhaney)
  • 4c87f42 Fix: incorrect error messages of no-unused-vars (fixes #9774) (#9791) (akouryy)
  • bbabf34 Update: add ignoreComments option to indent rule (fixes #9018) (#9752) (Kevin Partington)
  • db431cb Docs: HTTP -> HTTPS (fixes #9768) (#9768) (Ronald Eddy Jr)
  • cbf0fb9 Docs: describe how to feature-detect scopeManager/visitorKeys support (#9764) (Teddy Katz)
  • f7dcb70 Docs: Add note about "patch release pending" label to maintainer guide (#9763) (Teddy Katz)
Commits

The new version differs by 14 commits.

  • e14ceb0 4.15.0
  • 2dfc3bd Build: changelog update for 4.15.0
  • 6ab04b5 New: Add context.report({ messageId }) (fixes #6740) (#9165)
  • fc7f404 Docs: add url to each of the rules (refs #6582) (#9788)
  • fc44da9 Docs: fix sort-imports rule block language (#9805)
  • 65f0176 New: CLIEngine#getRules() (refs #6582) (#9782)
  • c64195f Update: More detailed assert message for rule-tester (#9769)
  • 9fcfabf Fix: no-extra-parens false positive (fixes: #9755) (#9795)
  • 61e5fa0 Docs: Add table of contents to Node.js API docs (#9785)
  • 4c87f42 Fix: incorrect error messages of no-unused-vars (fixes #9774) (#9791)
  • bbabf34 Update: add ignoreComments option to indent rule (fixes #9018) (#9752)
  • db431cb Docs: HTTP -> HTTPS (fixes #9768) (#9768)
  • cbf0fb9 Docs: describe how to feature-detect scopeManager/visitorKeys support (#9764)
  • f7dcb70 Docs: Add note about "patch release pending" label to maintainer guide (#9763)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Does this lib watch if the state will be too large?

I know I had an issue before with sending the entire Redux state when it's too large. Usually it causes the Sentry network call itself to fail because of the data size in the request being above the limit Sentry allows.

I'm wondering if this library checks for that before the request is sent? Or have you run into this issue personally and have some kind of workaround?

Great library, thank you.

An in-range update of webpack-dev-server is breaking the build 🚨

Version 2.9.1 of webpack-dev-server just got published.

Branch Build failing 🚨
Dependency webpack-dev-server
Current Version 2.9.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As webpack-dev-server is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 2 commits.

  • 97484a9 2.9.1
  • 8de5d0a fix errant always-on log message regarding 'setup'

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Using with Axios (Cannot read property 'hasOwnProperty' of undefined)

Hi,

Thanks for this package, I'm looking forward to getting it implemented.

I have a React / Redux universal application that's using Axios to get data from various endpoints. I'm using an Axios interceptor (https://github.com/mzabriskie/axios#interceptors) to catch any network errors like so:

axios.interceptors.response.use((response) => {
    return response;
  }, (error) => {
    Raven.captureException(error)
    return Promise.reject(error);
  });

If I run it like this with a default configuration, I get a number of Cannot read property 'hasOwnProperty' of undefined errors relating to Raven._trimBreadcrumbs.

screen shot 2017-04-10 at 18 45 53

On debugging I could see that in the _trimBreadcrumbs function in raven.js, crumb.data was 'undefined' and therefore it couldn't have the hasOwnProperty method. If I add this to the configuration line (it can in fact return any string and it still works okay)

const _ravenBreadcrumbData = (action) => {
  return action.type
}

and

createRavenMiddleware(Raven, {breadcrumbDataFromAction: _ravenBreadcrumbData})

then it all works okay. So I'm wondering if there's a better way of handling this?

Thanks!

Chris

An in-range update of webpack is breaking the build 🚨

Version 4.13.0 of webpack was just published.

Branch Build failing 🚨
Dependency webpack
Current Version 4.12.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v4.13.0

Features

  • the DefinePlugin now supports runtimeValues to pass computed values with dependencies that can change over time
  • added optimization.hashedModuleIds
  • crossOrigin for chunks is only set when really needed
  • added per chunk group indicies
  • updated enhanced-resolve
    • You can now use absolute paths as keys to resolve.alias

Bugfixes

  • when delegating CLI the bin fields are used
  • when assigning indicies sync dependencies are now walked before async dependencies
Commits

The new version differs by 52 commits.

  • e3678aa 4.13.0
  • 43563b3 hotfix merge issue in watchCases (not in CI)
  • 09beba0 Merge pull request #7621 from webpack/deps/enhanced-resolve
  • 7b7d323 upgrade enhanced-resolve
  • 34b0c7c Merge pull request #6906 from stepharr/patch-1
  • b181bc4 Merge pull request #6793 from ronkorving/define-functions
  • e08399a Merge pull request #7017 from rtsao/crossorigin-attr
  • b848ec5 Merge pull request #6346 from Connormiha/simplife-has-dependencies
  • 8420c73 Merge branch 'master' into define-functions
  • ef2ec25 update template.md too
  • 5c4ffd5 fix tests and code
  • 6478fb9 Merge branch 'master' into crossorigin-attr
  • dcf3e09 Merge pull request #7399 from webpack/feat-implement-option-for-hashed-module-ids-plugin
  • f41b829 Merge pull request #7604 from webpack/feature/update-snapshot-script
  • 17fa26c use jest directly

There are 52 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

stateTransformer Mutating State

Hi,

Maybe this is intentional behaviour and it should in fact be down do me to not mutate it, but, when I use the stateTransformer callback, any modifications I make to the state being passed to Raven are also present in the actual application state.

This is my cb function:

Sentry discarding invalid parameter 'lastAction'

I'm currently swapping out redux-raven-middleware for raven-for-redux (much prefer your implementation πŸ‘ ) and I've just run into this error in Sentry:

Sentry discarding invalid parameter 'lastAction'

Not sure if this is actually a bug with this project, but wanted to check if this something you've come across before, or have any thoughts on how to resolve?

Creating duplicate Raven errors.

First off, thanks for putting this together! It's a huge improvement on redux-raven-middleware by being able to pass in an initialized Raven object.

I seem to be receiving duplicate errors in Sentry when throwing an error inside reducer code. One comes from Object.ReactErrorUtils.invokeGuardedCallback, and then another gets sent as well.

I'm guessing it's because we already have an initialized window.Raven object and it's also listening for an error, and raven-for-redux ends up rethrowing the error after capturing the exception with the Raven object?

Have you come across this issue before?

An in-range update of webpack-dev-server is breaking the build 🚨

Version 3.1.6 of webpack-dev-server was just published.

Branch Build failing 🚨
Dependency webpack-dev-server
Current Version 3.1.5
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

webpack-dev-server is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes v3.1.6

2018-08-26

Bug Fixes

  • bin: handle process signals correctly when the server isn't ready yet (#1432) (334c3a5)
  • examples/cli: correct template path in open-page example (#1401) (df30727)
  • schema: allow the output filename to be a {Function} (#1409) (e2220c4)
Commits

The new version differs by 21 commits.

  • 0e1f0c1 chore(release): 3.1.6
  • aaabeb8 test(cli): remove outdated dependency lock test
  • 4e27954 chore(package): update yargs v11.0.0...12.0.1 (dependencies)
  • c4a1038 chore(package): update devDependencies (#1474)
  • 3e764c5 chore(package): update webpack-dev-middleware v3.1.3...v3.2.0 (dependencies) (#1473)
  • c854743 chore(package): update webpack-log v1.1.2...v2.0.0 (dependencies) (#1472)
  • c760c44 ci(travis): add build stages (#1467)
  • b445b68 chore(package): add release script (scripts) (#1461)
  • 334c3a5 fix(bin): handle process signals correctly when the server isn't ready yet (#1432)
  • e2220c4 fix(schema): allow the output filename to be a {Function} (#1409)
  • 807c846 refactor: drop array-includes
  • 5b6bb5e Merge pull request #1460 from webpack/docs/maintenance
  • b838274 Merge pull request #1462 from webpack/chore/codeowners
  • 1707e9e chore(.github/CODEOWNERS): add code owners
  • 6c1d8d8 docs(readme): remove obsolete maintenance note

There are 21 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Use with react-redux-universal-hot-example

I've been trying for some time to use this in my app based on erikras/react-redux-universal-hot-example.

Whenever I throw an error in a reducer, no request is sent to Sentry.

I have done a lot of configuration, reconfiguration and such, including implementing Rasmusen's great ./ApiClient into the the ./examples here, but that worked as expected. As a result I have not narrowed down the issue to that part.

Here is the relevant (I think) section of Rasmussen'a repo.

Any quick insight from someone more experienced the I would be greatly appreciated.

An in-range update of eslint-plugin-react is breaking the build 🚨

Version 7.11.0 of eslint-plugin-react was just published.

Branch Build failing 🚨
Dependency eslint-plugin-react
Current Version 7.10.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes v7.11.0

Added

Fixed

Changed

Commits

The new version differs by 65 commits.

  • 599c028 Update CHANGELOG and bump version
  • 1eccf7f Merge pull request #1924 from alexzherdev/1775-one-expression-options
  • c1c3d19 Merge pull request #1911 from alexzherdev/1674-prop-types-refactoring
  • 3567c5b [New] Add allow option to jsx-one-expression-per-line
  • 9258d79 Merge pull request #1918 from BenRichter/patch-1
  • bc9a8ea Update jsx-props-no-multi-spaces.md
  • a466a77 Merge pull request #1909 from alexandernanberg/fix/class-property-destructure-assignment
  • 50cd5a6 Clean up and code review
  • 5b5ebfa Made prop-types pass
  • f2fdaa3 Extract declared propTypes detection code
  • 9dbb834 Merge pull request #1914 from alexzherdev/is-function-helper
  • 7edc982 Fix lint error
  • ef36ba9 Add a helper function for determining function-like expressions
  • 4382aa5 fix: destructuring-assignment ignore class properties
  • efe0c0c Merge pull request #1907 from alexzherdev/1637-destructuring-assignment-greedy

There are 65 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of react is breaking the build 🚨

Version 16.4.2 of the react packages was just published.

Branch Build failing 🚨
Monorepo release group react
Current Version 16.4.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the react group definition.

react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes v16.4.2

16.4.2 (August 1, 2018)

React DOM Server

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

calls next(action) but doesn't return it

I was running into an error where I was chaining off a promise returned by redux-api-middleware:

this.props.createThing().then((result) => ...)

Without raven-for-redux, result is the correct value (the result of the API call). With raven-for-redux, result is undefined.

I modified the middleware to remove the call here:
https://github.com/captbaritone/raven-for-redux/blob/master/index.js#L33, which calls next(action) but does not return it. I replaced it with return next(action) and my app again works as expected.

looking at http://redux.js.org/docs/advanced/Middleware.html, all the examples return next(action) at some point. I believe it's part of the contract a middleware has to fulfill.

I believe the fix for this is:

      // Set the action as context in case we crash in the reducer.
      const result = next(action)
      const extra = { lastAction: action };
      Raven.context({ extra }, () => result);

      ...

      return result; 

An in-range update of prettier is breaking the build 🚨

Version 1.4.0 of prettier just got published.

Branch Build failing 🚨
Dependency prettier
Current Version 1.3.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As prettier is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes 1.4.0: TypeScript and CSS support

prettier-revolution-conf

TypeScript Support

This is the most requested feature for prettier. With 1.4.0, you can now use prettier to format your .ts and .tsx files!

The way prettier works is by using those project to generate an AST representation of the code and print it. Both babylon (the parser that powers babel) and flow are producing an AST approximately following the estree format for the JavaScript parts and then have special nodes for Flow-specific ones.

TypeScript, the same way as Flow, introduces special nodes for the syntax it introduces. Unfortunately, it doesn't follow the estree format for the rest of the JavaScript language. This puts us in a rough spot with prettier as we would have to essentially completely fork it in order to print TypeScript.

This incompatibility with the AST is not a new problem and another project struggled with it: ESLint. Because the AST is different, none of the ESLint rules are working. Fortunately for us, @JamesHenry and @soda0289 wrote a project called typescript-eslint-parser which takes a TypeScript AST and convert it to an estree one, just what we need for prettier!

After that project got setup inside of prettier, @azz, @despairblue and @Pajn implemented all the TypeScript-specific nodes and ensured that the 13k tests of the TypeScript test suite are correctly passing. This was a huge undertaking and it is finally ready to be used :)

We tested prettier on the biggest TypeScript projects we could find on GitHub to ensure that it prints correct code. We haven't spent a lot of time trying to optimize the way code is formatted yet, so if you see something strange, please raise an issue!

CSS, Less and SCSS Support

While TypeScript is the most requested feature from open source, CSS is the biggest one from Facebook engineers. Once you are used to pretty print your code in one language, you want to do it everywhere!

It turns out that CSS is a much smaller language than JavaScript and supporting it only took a few days. We are using postcss by @ai as the underlying parser which is able to parse CSS, Less and SCSS. We also depend on postcss-values-parser, postcss-selector-parser by @ben-eb postcss-media-query-parser by @dryoma.

Unfortunately, postcss right now doesn't parse Sass nor Stylus. We'd be happy to support them if someone is willing to do the work of printing them.

Note that prettier is currently just formatting the code, it does not respect any options yet such as singleQuote nor is doing any color or number normalization like we do for JavaScript.

Editor Integration

The first phase of the project was to make prettier output correct and good looking code. Now that it's in a good shape, we can spend time on making the integrations better. We just introduced support for two great features: maintain cursor position and being able to format a range instead of the entire file.

Note that we just landed the support inside of prettier itself, none of the editor integrations are using it yet. Also, we haven't really tried them out in practice so we're likely going to have to fix rough edges with them!

Add cursorOffset option for cursor translation (#1637) by @josephfrazier

Right now, we let editors figure out where the cursor should be, which they do an okay job at. But since we are printing the code, we can give the correct position!

Add --range-start/end options to format only parts of the input (#1609) by @josephfrazier

This one is a very often requested feature. Right now prettier only formats the entire file. Now it is possible to format a range.

The way it works is by going up through the AST in order to find the closest statement. This way you don't need to select exactly the right range that is valid. You can just drag in the rough place where the code you want to reformat it, and it's going to!

Adding filepath option in order to enable filetype inference (#1835) by @mitermayer

Since we are now formatting CSS and TypeScript, it is not convenient to have to specify the parser for every file. You can now pass the filepath of the file you are working on and prettier will read the extension and figure out the right parser to use.

Highlights

Wrap text content inside of JSX (#1120, #1671, #1827, #1829) by @karl

The biggest remaining issue that people have with prettier when printing JSX is when it is used when printing text. The behavior of prettier used to add an ugly {" "} before and if a line was too long, just leave it alone. Now we treat each word as a token and are able to make it flow correctly.

This is an awesome piece of work by @karl as not only did he implement the feature, but also introduced a new primitive inside of prettier in order to print a sequence of elements and break as soon as one hits the edge.

// Before
<div>
  Please state your
  {" "}
  <b>name</b>
  {" "}
  and
  {" "}
  <b>occupation</b>
  {" "}
  for the board of directors.
</div>

// After
<div>
Please state your <b>name</b> and <b>occupation</b> for the board of
directors.
</div>

Remove parenthesis for JSX inside of arrow functions (#1733) by @xixixao

People writing functional components are going to be happy about this one. We no longer put parens for arrow functions that return JSX.

// Before
const render1 = ({ styles }) => (
  <div style={styles}>
      Keep the wrapping parens. Put each key on its own line.
  </div>
);

// After
const render1 = ({ styles }) =>
<div style={styles}>
Keep the wrapping parens. Put each key on its own line.
</div>;

Improve template literal printing (#1664, #1714) by @josephfrazier

Template literal printing has always caused prettier a lot of difficulties. With 1.3.0 we massively improved the situation and with this release, I believe that we handle all the common situations in a good way.

In order to workaround issues, we added an utility that removes empty lines from the output, but it yielded some really weird results sometimes, this is now gone. Another tweak we've done is instead of indenting when ${ starts, we indent where the line that contains ${ starts.

Let us know if you still have issues with how template literals output after this release!

// Before
const Bar = styled.div`
  color: ${props => (props.highlight.length > 0 ? palette([
                 'text',
                 'dark',
                 'tertiary'
               ])(props) : palette([
                 'text',
                 'dark',
                 'primary'
               ])(props))} !important;
`

// After
const Bar = styled.div</span></span> <span class="pl-s"> color: <span class="pl-s1"><span class="pl-pse">${</span><span class="pl-smi">props</span> <span class="pl-k">=&gt;</span></span></span> <span class="pl-s"><span class="pl-s1"> <span class="pl-smi">props</span>.<span class="pl-smi">highlight</span>.<span class="pl-c1">length</span> <span class="pl-k">&gt;</span> <span class="pl-c1">0</span></span></span> <span class="pl-s"><span class="pl-s1"> <span class="pl-k">?</span> <span class="pl-en">palette</span>([<span class="pl-s"><span class="pl-pds">"</span>text<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>dark<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>tertiary<span class="pl-pds">"</span></span>])(props)</span></span> <span class="pl-s"><span class="pl-s1"> <span class="pl-k">:</span> <span class="pl-en">palette</span>([<span class="pl-s"><span class="pl-pds">"</span>text<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>dark<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>primary<span class="pl-pds">"</span></span>])(props)<span class="pl-pse">}</span></span> !important;</span> <span class="pl-s"><span class="pl-pds">

Use the same breaking rules for assignment and object values (#1721)

We have a lot of fine-tuned logic for how to break things after assignment (eg a = ...). We are now using the same one for object values. This should help for multi-line boolean logic, or big conditionals. This is also a good example of how we can create a consistent printer.

// Before
const o = {
  somethingThatsAReallyLongPropName: this.props.cardType ===
    AwesomizerCardEnum.SEEFIRST,
};

// After
const o = {
somethingThatsAReallyLongPropName:
this.props.cardType === AwesomizerCardEnum.SEEFIRST,
};

Indent conditions inside of !() (#1731)

There's been a steady stream of people complaining about the way it was rendered and was put on the list of things that are probably hard to do, will check later. It turned out to be super easy, so here you go!

// Before
const anyTestFailures = !(aggregatedResults.numFailedTests === 0 &&
  aggregatedResults.numRuntimeErrorTestSuites === 0);

// After
const anyTestFailures = !(
aggregatedResults.numFailedTests === 0 &&
aggregatedResults.numRuntimeErrorTestSuites === 0
);

Formatting Fixes

Put loop bodies on the same line when possible (#1498)

We were already doing this for if statements, we should be consistent and also do it for loops.

// Before
for (a in b)
  var c = {};

// After
for (a in b) var c = {};

Fix empty line with flow union (#1511) by @existentialism

We shouldn't indent things twice ;)

// Before
type Foo = Promise<
<span class="pl-k">|</span> { ok<span class="pl-k">:</span> <span class="pl-c1">true</span>, bar<span class="pl-k">:</span> string, baz<span class="pl-k">:</span> SomeOtherLongType }
<span class="pl-k">|</span> { ok<span class="pl-k">:</span> <span class="pl-c1">false</span>, bar<span class="pl-k">:</span> SomeOtherLongType }

>;

// After
type Foo = Promise<
{ ok: true, bar: string, baz: SomeOtherLongType } |
{ ok: false, bar: SomeOtherLongType }
>;

Do not put parens for single argument with end of line comment (#1518)

The detection code for whether an arrow function should be written without parenthesis just checked if there was a comment, but instead we only want comments that are inline like (/* comment */ num), not end of line comments.

// Before
KEYPAD_NUMBERS.map((num) => ( // Buttons 0-9
  <div />
));

KEYPAD_NUMBERS.map(num => ( // Buttons 0-9
<div />
));

Do not indent nested ternaries (#1822)

This avoids making it seems like it is indented by 4 characters instead of two. The downside is that if the condition is multi-line it's not going to be properly aligned, but I feel it's a better trade-offs. If you are doing nested ternaries, you usually have small conditions.

// Before
aaaaaaaaaaaaaaa
  ? bbbbbbbbbbbbbbbbbb
  : ccccccccccccccc
      ? ddddddddddddddd
      : eeeeeeeeeeeeeee ? fffffffffffffff : gggggggggggggggg;

// After
aaaaaaaaaaaaaaa
? bbbbbbbbbbbbbbbbbb
: ccccccccccccccc
? ddddddddddddddd
: eeeeeeeeeeeeeee ? fffffffffffffff : gggggggggggggggg;

Inline chained conditionals inside of jsx attribute (#1519)

We don't need to use the indentation to disambiguate another block as nothing can come after.

// Before
<div
  src={
    !isEnabled &&
      diffUpdateMessageInput != null &&
      this.state.isUpdateMessageEmpty
  }
/>;

// After
<div
src={
!isEnabled &&
diffUpdateMessageInput != null &&
this.state.isUpdateMessageEmpty
}
/>;

Unescape unnecessarily escaped characters in strings (#1575) by @josephfrazier

We are already trying to cleanup strings in various ways, this is another small addition that's going to remove \ that are not needed.

// Before
a = 'hol\a';

// After
a = 'hola';

Fix boolean for empty objects (#1590) by @dmitrika

We want to inline objects inside of a boolean expression as it looks weird to have { on its own line. But it turns out that it leads to weird behaviors for empty objects. So we keep them on their own line if they are empty.

const x = firstItemWithAVeryLongNameThatKeepsGoing ||
secondItemWithALongNameAsWell || {};

// After
const x =
firstItemWithAVeryLongNameThatKeepsGoing ||
secondItemWithALongNameAsWell ||
{};

Remove Parens from SequenceExpressions in ForStatements (#1597) by @k15a

It is common to assign multiple values inside of a for loop, now we don't add parenthesis anymore.

// Before
for ((i = 0), (len = arr.length); i < len; i++) {

// After
for (i = 0, len = arr.length; i < len; i++) {

Do not inline arrow when argument has a leading comment (#1660)

If you put block comments inside of arrow functions, we no longer mess everything up!

// Before
export const bem = block => /**
   * @param {String} [element] - the BEM Element within that block; if undefined, selects the block itself.
   */
element => /**
     * @param {?String} [modifier] - the BEM Modifier for the Block or Element; if undefined, selects the Block or Element unmodified.
     */
modifier =>

// After
export const bem = block =>
/
* @param {String} [element] - the BEM Element within that block; if undefined, selects the block itself.
*/
element =>
/

* @param {?String} [modifier] - the BEM Modifier for the Block or Element; if undefined, selects the Block or Element unmodified.
*/
modifier =>

Fix last comments of imports (#1677)

Another place where we have to do special logic for comments!

// Before
import {
  ExecutionResult,
  DocumentNode,
  /* tslint:disable */
  SelectionSetNode,
} /* tslint:enable */ from 'graphql';

// After
import {
DocumentNode,
/* tslint:disable /
SelectionSetNode,
/
tslint:enable */
} from 'graphql';

Handle comments in member chain (#1686, #1691)

We handled some placements before and kept adding places where they could appear, now we switch to a more general approach. Hopefully those issues shouldn't crop up in the future anymore.

// Before
const configModel = this.baseConfigurationService.getCache().consolidated // global/default values (do NOT modify)
  .merge(this.cachedWorkspaceConfig);

// After
const configModel = this.baseConfigurationService
.getCache()
.consolidated // global/default values (do NOT modify)
.merge(this.cachedWorkspaceConfig);

Use expandLast for nested arrow functions (#1720)

// Before
f(action => next =>
    next(action));

// After
f(action => next =>
next(action),
);

Put JSX comments inside of the parenthesis (#1712)

This mostly affects Facebook engineers where we automatically add $FlowFixMe when pushing a new version of flow. Now it no longer messes up those comments.

// Before
const aDiv = /* $FlowFixMe */
(
  <div className="foo">
    Foo bar
  </div>
);

// After
const aDiv = (
/* $FlowFixMe */
<div className="foo">
Foo bar
</div>
);

Force \n for multiple variable declarations (#1723)

This one has been very often requested. We used to only break multiple variable declarations if the line was > 80 columns. Now we do it regardless if there's at least one with an assignment.

// Before
var numberValue1 = 1, numberValue2 = 2;

// After
var numberValue1 = 1,
numberValue2 = 2;

Inline | null and | void (#1734)

The expanded version of flow union looks good when they are many objects but if it's used for nullability, the it looks very weird. We're now inlining | null and | void.

// Before
interface RelayProps {
  articles:
    | Array<
      | {
        __id: string,
      }
      | null
    >
    | null
}

// After
interface RelayProps {
articles: Array<{
__id: string,
} | null> | null,
}

Break on implements instead of extends (#1730)

We no longer break on extends. This should make classes with extends that can break look less wonky.

// Before
class MyContractSelectionWidget
  extends React.Component<
    void,
    MyContractSelectionWidgetPropsType,
    void
  > {
  method() {}
}

// After
class MyContractSelectionWidget extends React.Component<
void,
MyContractSelectionWidgetPropsType,
void
> {
method() {}
}

Inline single import (#1729)

The same way we don't break long require calls, we no longer break import statements if there is only a single thing being imported.

// Before
import somethingSuperLongsomethingSuperLong
  from "somethingSuperLongsomethingSuperLongsomethingSuperLong";

// After
import somethingSuperLongsomethingSuperLong from "somethingSuperLongsomethingSuperLongsomethingSuperLong";

Add the ability for SequenceExpression to break (#1749)

Did you know that if none of your code were statements, you could use () instead of {} and , instead of ;? Now you do. Some people exploit this fact when returning things from arrow functions. This is not recommended but it's easy to support in prettier so might as well Β―_(ツ)_/Β―

// Before
const f = (argument1, argument2, argument3) =>
  (doSomethingWithArgument(argument1), doSomethingWithArgument(
    argument2
  ), argument1);

// After
const f = (argument1, argument2, argument3) => (
doSomethingWithArgument(argument1),
doSomethingWithArgument(argument2),
argument1
);

Don't force line break in empty loop bodies (#1815)

Loops with empty body no longer have their {} split into two lines.

// Before
while (true) {
}

// After
while (true) {}

Preserve empty lines between switch cases with comments (#1708)

// Before
switch (true) {
  case true:
  // Good luck getting here
  case false:
}

// After
switch (true) {
case true:

// Good luck getting here
case false:
}

Correctness

Remove ast-types (#1743, #1744, #1745, #1746, #1747)

We used to find where to put comments by traversing the AST using the definition from ast-types. This occasionally caused issues when some field wasn't declared, we wouldn't find the node and either print comments in an incorrect location or throw an error. It turns out that we don't need to keep this mapping and can just traverse the objects and if a node has a type field, then it's a node.

// Before
Error: did not recognize object of type "ObjectTypeSpreadProperty"

// After
type X = {...Y//};
type X = {/
/...Y};

Preserve unusual unicode whitespace (#1658, #1165) by @karl and @yamafaktory

If you were adding invisible characters inside of JSX text, we would replace them by regular spaces. I don't know why anyone would ever want to do that, but now we print it back as is!

Don't let trailing template literal comments escape (#1580, #1713, #1598, #1713) by @josephfrazier and @k15a

We used to have some pretty complicated (and not working well) code to handle comments inside of template literals. We introduced a really nice solution for JSX {} expressions. The idea is to introduce a boundary before the end of the } and if we still have unprinted comments, then flush them all at once, put a \n and print the }. We are now using this logic for template literals :)

// Before
`${0} // comment`;

// After
</span><span class="pl-s1"><span class="pl-pse">${</span></span></span> <span class="pl-s"><span class="pl-s1"><span class="pl-c1">0</span></span></span> <span class="pl-s"><span class="pl-s1"><span class="pl-c"><span class="pl-c">//</span> comment</span></span></span> <span class="pl-s"><span class="pl-s1"><span class="pl-pse">}</span></span><span class="pl-pds">;

Parenthesize await correctly (#1513, #1595, #1593) by @bakkot and @existentialism

We don't have an automated way to put parenthesis, we instead specify all the possible combinations of nodes and when they should or shouldn't have parenthesis. So there's likely a long tail of unusual combinations that are still remaining. In this case, we made await handling a lot more robust by both adding parenthesis where they are needed and removing them when they are not.

// Before
(await spellcheck) && spellcheck.setChecking(false);
new A((await x));

// After
await (spellcheck && spellcheck.setChecking(false));
new A(await x);

Preserve getter/setter info on flow ObjectTypeProperty (#1585) by @josephfrazier

Another long tail option that we haven't got right!

// Before
type T = { method: () => void };

// After
type T = { get method(): void }

Add parenthesis for single arg types with generics (#1814)

Another case of sneaky parenthesis that we didn't properly add!

// Before
type ExtractType = <A>B<C> => D

// After
type ExtractType = <A>(B<C>) => D

Fall back to non-strict mode in babylon (#1587, #1608) by @josephfrazier

We want prettier to be able to parse all the JavaScript out there. For babylon parser, we have to chose whether a file is using strict mode or not. We opted in to use strict mode by default as most files parse that way. But if you have octal literals like 0775, it would not even parse. Now if it fails to parse in strict mode, we're going to try again in non-strict. We also allow return outside of a function as it's valid in node files.

// Before
SyntaxError

// After
return 0775;

CLI

Allow --write to be used with --list-different (#1633)

This is useful to combine the two if you are writing a commit hook to tell the user what actually changed in a single command.

Ignore node_modules when running prettier from CLI (#1683) by @thymikee

It's very easy to run prettier over the node_modules/ folder by mistake which is something you almost never want to. So now we disable it by default and add a --with-node-modules option if you really want to.

Traverse dot files for glob (#1844) by @jhgg

We enabled the option to go through .dotfiles in the glob parsing library we are using. This means that writing * will now catch .eslintrc.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

npm build?

When I pull version 1.1.0 from npm (actually I'm using yarn), the built version of the code (built/index.js) doesn't reflect what I'm seeing on GitHub. But the README is up to date.

stateTransformer Usage.

Hi - is there anyway to have this be called (or run) only if an error happens and only when the state is actually being submitted?

I ask because my state can get a little large and in testing I've occasionally hit the 'Request Entity too Large' error. So, I've set up a function that removes a couple of fields from my state before passing to Raven. But it is an iterative function and therefore potentially expensive so I'd prefer not to run it every time my state changes.

I guess I could use some shallow checking on the parts of the state I'm interested in, but I wonder if there's a better way?

An in-range update of jest is breaking the build 🚨

Version 21.2.1 of jest just got published.

Branch Build failing 🚨
Dependency jest
Current Version 21.2.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As jest is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

React Native Sentry dosn't collect extradata

I am building for android on windows. As mentioned in your readme i used createRavenMiddleware(Sentry) but it is not collecting extradata. If i only switch from Sentry to Raven it works, but i would like to use Sentry.

Package.json:

    "raven-for-redux": "^1.3.0",
    "raven-js": "^3.23.3",
    "react": "16.0.0-alpha.12",
    "react-native": "0.48.4",
    "react-native-sentry": "^0.35.3",

It seems like Raven.setDataCallback(function (data, original) { is never called.

An in-range update of raven-js is breaking the build 🚨

Version 3.20.0 of raven-js was just published.

Branch Build failing 🚨
Dependency raven-js
Current Version 3.19.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

raven-js is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes 3.20.0
  • NEW: autoBreadcrumbs can now disable sentry breadcrumbs and configure them on demand #1099
  • NEW: Add maxBreadcrumbs and sampleRate to Typescript typings 29b89de 989f43a
  • CHANGE: isEmptyObject utility now checks for object's own properties only #1100
  • CHANGE: Update how wrapped functions are detected as native functions #1106
  • CHANGE: Update integration tests on SauceLabs to use Safari 11.0
  • BUGFIX: Send raw error when vm is undefined while using Vue plugin #1118
Commits

The new version differs by 14 commits.

  • 30c0da4 3.20.0
  • e6baafa ci: Update Safari to 11.0 (OSX) on SauceLabs (#1127)
  • 55e9805 ci: Update Safari to 11.0 on SauceLabs (#1126)
  • 989f43a fix: Add sampleRate typing
  • 29b89de Add maxBreadcrumbs to Typescript typings
  • 0fbdf95 fix: Send raw error when vm is undefined in Vue plugin (#1118)
  • 4c41fef fix: Vue plugin doesnt explode if vm is undefined (#1111)
  • cf89f86 fix: Update how wrapped functions are detected as native functions (#1106)
  • 9cb17c1 ref: Remove doubled isObject declaration
  • f74498e feat: Disable automatic breadcrumbs collection #782 (#1099)
  • 783a4ee meta: Remove jsDelivr badge
  • df8a89b Add jsDelivr hits badge
  • 66a5db5 utils: make isEmptyObject check prototype #940
  • 3858b07 build: Reduce publishing to just one step

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of prettier is breaking the build 🚨

Version 1.7.1 of prettier just got published.

Branch Build failing 🚨
Dependency prettier
Current Version 1.7.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As prettier is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Warn if createRavenMiddleware is called more than once

Currently this is the source of a potential memory leak (see #50), since Raven will continue to hold a reference our original dataCallback which has the store implicitly bound into it.

Additionally, we hard code where in the context we put the state, (data.extra.state), so the second call will cause any context provided by the first call to be overwritten.

I can foresee a possible use case where a user might have n different Redux stores on a given page, and might want to record context about all of them so let's have the warning include a link to our documentation where we can explain these things and give people a chance to request support for multiple calls.

I'll wrap the link in an http://bit.ly URL shortener so that we can track how many people are hitting the warning and clicking through.

Is it possible to capture only certain errors?

I was reading through the docs and saw the instruction asking to do Raven.install().
Some background context: my app is placed on a page that contains other projects as well, I don't want to use Raven.install() and all errors on the page, including the ones thrown from the other projects.

Ravenjs itself provides a way to

try {
... some piece of code
} catch(e) {
Raven.captureException(e)
}

Is this something that can be done using this middleware?

An in-range update of react is breaking the build 🚨

☝️ Greenkeeper’s updated Terms of Service will come into effect on April 6th, 2018.

Version 16.3.0 of react was just published.

Branch Build failing 🚨
Dependency react
Current Version 16.2.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v16.3.0

16.3.0 (March 29, 2018)

React

  • Add a new officially supported context API. (@acdlite in #11818)
  • Add a new React.createRef() API as an ergonomic alternative to callback refs. (@trueadm in #12162)
  • Add a new React.forwardRef() API to let components forward their refs to a child. (@bvaughn in #12346)
  • Fix a false positive warning in IE11 when using React.Fragment. (@XaveScor in #11823)
  • Replace React.unstable_AsyncComponent with React.unstable_AsyncMode. (@acdlite in #12117)
  • Improve the error message when calling setState() on an unmounted component. (@sophiebits in #12347)

React DOM

  • Add a new getDerivedStateFromProps() lifecycle and UNSAFE_ aliases for the legacy lifecycles. (@bvaughn in #12028)
  • Add a new getSnapshotBeforeUpdate() lifecycle. (@bvaughn in #12404)
  • Add a new <React.StrictMode> wrapper to help prepare apps for async rendering. (@bvaughn in #12083)
  • Add support for onLoad and onError events on the <link> tag. (@roderickhsiao in #11825)
  • Add support for noModule boolean attribute on the <script> tag. (@aweary in #11900)
  • Fix minor DOM input bugs in IE and Safari. (@nhunzaker in #11534)
  • Correctly detect Ctrl + Enter in onKeyPress in more browsers. (@nstraub in #10514)
  • Fix containing elements getting focused on SSR markup mismatch. (@koba04 in #11737)
  • Fix value and defaultValue to ignore Symbol values. (@nhunzaker in #11741)
  • Fix refs to class components not getting cleaned up when the attribute is removed. (@bvaughn in #12178)
  • Throw with a meaningful message if the component runs after jsdom has been destroyed. (@gaearon in #11677)
  • Don't crash if there is a global variable called opera with a null value. @alisherdavronov in #11854)
  • Don't check for old versions of Opera. (@skiritsis in #11921)
  • Deduplicate warning messages about <option selected>. (@watadarkstar in #11821)
  • Deduplicate warning messages about invalid callback. (@yenshih in #11833)
  • Deprecate ReactDOM.unstable_createPortal() in favor of ReactDOM.createPortal(). (@prometheansacrifice in #11747)
  • Don't emit User Timing entries for context types. (@abhaynikam in #12250)
  • Improve the error message when context consumer child isn't a function. (@raunofreiberg in #12267)
  • Improve the error message when adding a ref to a functional component. (@skiritsis in #11782)

React DOM Server

  • Prevent an infinite loop when attempting to render portals with SSR. (@gaearon in #11709)
  • Warn if a class doesn't extend React.Component. (@wyze in #11993)
  • Fix an issue with this.state of different components getting mixed up. (@sophiebits in #12323)
  • Provide a better message when component type is undefined. (@HeroProtagonist in #11966)

React Test Renderer

  • Fix handling of fragments in toTree(). (@maciej-ka in #12107 and @gaearon in #12154)
  • Shallow renderer should assign state to null for components that don't set it. (@jwbay in #11965)
  • Shallow renderer should filter legacy context according to contextTypes. (@koba04 in #11922)
  • Add an unstable API for testing asynchronous rendering. (@acdlite in #12478)

React Is (New)

  • First release of the new package that libraries can use to detect different React node types. (@bvaughn in #12199)
  • Add ReactIs.isValidElementType() to help higher-order components validate their inputs. (@jamesreggio in #12483)

React Lifecycles Compat (New)

Create Subscription (New)

React Reconciler (Experimental)

  • Expose react-reconciler/persistent for building renderers that use persistent data structures. (@gaearon in #12156)
  • Pass host context to finalizeInitialChildren(). (@jquense in #11970)
  • Remove useSyncScheduling from the host config. (@acdlite in #11771)

React Call Return (Experimental)

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Support for @sentry/browser

Hi, I'm trying to set up raven-for-redux with @sentry/browser but can't find a way to set up the middleware. The init method adds a window.__SENTRY__ object but it doesn't have the necessary setDataCallback hook. Here's my setup:

import thunk from 'redux-thunk';
import { applyMiddleware, createStore, compose } from 'redux';
import { init } from '@sentry/browser';
import createRavenMiddleware from 'raven-for-redux';

// Init Sentry
init({
  dsn: process.env.SENTRY_URL,
  environment: process.env.NODE_ENV
});

// Create the store
const reduxStore = createStore(
  rootReducer,
  compose(applyMiddleware(thunk, createRavenMiddleware(window.__SENTRY__)))
);

Any ideas?

An in-range update of eslint-config-prettier is breaking the build 🚨

Version 2.10.0 of eslint-config-prettier was just published.

Branch Build failing 🚨
Dependency eslint-config-prettier
Current Version 2.9.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint-config-prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 4 commits.

  • 9f42779 eslint-config-prettier v2.10.0
  • 7a95862 Add more eslint-plugin-react rules
  • becbdf3 Add flowtype/boolean-style
  • 0f13166 Fix wording in readme

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-config-prettier is breaking the build 🚨

Version 2.1.0 of eslint-config-prettier just got published.

Branch Build failing 🚨
Dependency eslint-config-prettier
Current Version 2.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint-config-prettier is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 5 commits0.

  • 47ca973 eslint-config-prettier v2.1.0
  • dfa6e2b Update the documentation for adding a new plugin
  • f5ffd3a Capitalize the P in Prettier in two places
  • 872f08a Add no-tabs as a special rule
  • d37ba4b Lint the project with the 'no-dupe-keys' rule

false

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of raven-js is breaking the build 🚨

Version 3.26.4 of raven-js was just published.

Branch Build failing 🚨
Dependency raven-js
Current Version 3.26.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

raven-js is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

What kind of errors will be captured?

Thanks for a great package!

I'm using this together with preact and I'm wondering what kind of actions really get captured. In your example I can see that you're throwing errors inside the reducer, outside of the reducer and inside a click event. To me it looks like you're capturing most of thrown errors, but is there any cases where I need to handle it "manually" on the client side? It would be great if this could be clarified in the docs. Thanks!

An in-range update of prettier is breaking the build 🚨

Version 1.13.2 of prettier was just published.

Branch Build failing 🚨
Dependency prettier
Current Version 1.13.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Add an action's 'payload' property to breadcrumb data if it exists

Just a thought that could potentially be a useful addition - It's quite likely that a lot of people using Redux will also be using the flux-standard-actions standard for structuring their actions.

It could be useful to include the action's payload property (if it exists) in the data property of Raven's breadcrumb to help add a bit more context to actions in the breadcrumb in Sentry.

This could also be extended to including all of an action's properties (apart from type) in the breadcrumb's data, which would then mean that all actions (in whatever format) could be passed through to Sentry and examined.

Interested to hear your thoughts on this!

Add support for @sentry/browser

@sentry/browser is the latest version of Sentry SDK. I tried to upgrade my project, but my application fails to run with an error Raven.setDataCallback is not a function. That's because the Sentry API changed significantly and this library would have to be updated...

License

Hi,

thanks for the package. The best Sentry package for redux out there.
Can you let me know which license is in this package?

Thank you πŸ‘

An in-range update of prettier is breaking the build 🚨

Version 1.6.0 of prettier just got published.

Branch Build failing 🚨
Dependency prettier
Current Version 1.5.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As prettier is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes 1.6.0: Config File, JSX

image

I want to give a special shout out to @azz who has been maintaining the repository and implementing a bunch of the changes in this release as I had less time to devote to prettier due to vacation and switching team :)

Highlights

Configuration

Implement cosmiconfig for workspace configuration (#2434) by @azz

Since the very first release of prettier, people have asked for a .prettierrc file. We've been trying to have as few options as possible and tried to avoid being one more .dotfile that you have to have when starting a new project.

But, the truth is, we need to have some way to configure prettier that can be kept in sync with all the integrations. By not having one, we pushed the problem to them and saw a bunch of incompatible ways of handling the problem. So now, it's handled by prettier itself.

// .prettierrc
{
  "trailingComma": "es5",
  "singleQuote": true
}

For more information on configuration file support, see the README.

Support .prettierignore files (#2412) by @evilebottnawi

Along with telling what configuration to use, you can write a file .prettierignore to tell which files not to convert.

# .prettierignore
dist/
package.json

JSX

Improve JSX Formatting (#2398) by @suchipi

The last big friction point from people trying to adopt prettier was around how JSX was being printed. We went through all the issues that were raised and made a bunch of changes:

  • Arrow Function Expressions returning JSX will now add parens when the JSX breaks
// Before
const Component = props =>
  <div>
    Hello {props.name}!
  </div>;

// After
const Component = props => (
<div>
Hello {props.name}!
</div>
);

  • Conditional expressions within (or containing) JSX are formatted in a different way using parenthesis
// Before
<div>
  {props.isVisible
    ? <BaseForm
        url="/auth/google"
        method="GET"
      />
    : <Placeholder />}
</div>;

// After
<div>
{props.isVisible ? (
<BaseForm
url="/auth/google"
method="GET"
/>
) : (
<Placeholder />
)}
</div>

  • JSX in logical expressions (|| or &&) is always wrapped in parens when the JSX breaks
// Before
<div>
  {props.isVisible &&
    <BaseForm
      url="/auth/google"
      method="GET"
    />}
</div>;

// After
<div>
{props.isVisible && (
<BaseForm
url="/auth/google"
method="GET"
/>
)}
</div>

Hopefully this is going to be more in line with how the majority of the community is writing JSX and we can have prettier be used in more place ;)

Inline single expressions in JSX (#2442) by @karl

With JSX, we started by respecting a lot of line breaks that were in the original source. This had the advantage of doing fewer changes to your codebase but chipped away the value of a consistent pretty printer as the same semantic code could be written in two ways.

During each new release we've tightened this and made decisions around how to always print a piece of code. The latest of those is what happens if there's a single child in a JSX object, we're now always going to inline it.

// Before
return (
  <div>
    {this.props.test}
  </div>
);
return <div>{this.props.test}</div>;

// After
return <div>{this.props.test}</div>;
return <div>{this.props.test}</div>;

Ensure there is a line break after leading JSX white space (#2348) by @karl

Leading JSX empty spaces are now on their own line. It looked weird to have them before a tag as it "indented" it differently compared to the rest.

// Before
<span className="d1">
  {' '}<a
    href="https://github.schibsted.io/finn/troika"
    className="link"
  />
</span>

// After
<span className="d1">
{' '}
<a
href="https://github.schibsted.io/finn/troika"
className="link"
/>
</span>

Other Changes

JSON

Use babylon.parseExpression for JSON (#2476) by @josephfrazier

We used to use a strict JSON parser that would throw if there was a comment or a trailing comma. This was inconvenient as many JSON files in practice are parsed using JavaScript or json5 that are not as strict. Now, we have relaxed this and are using the JavaScript parser to parse and print JSON. This means that comments will be maintained if there were some.

Note that this is purely additive, if your original file was JSON compliant, it will keep printing a valid JSON.

// Before
Syntax error

// After
{ / some comment / "a": 1 }

JavaScript

Add more supervisory parens (#2423) by @azz

Parenthesis are a hot topic because they are not part of the AST, so prettier ignores all the ones you are putting and re-creating them from scratch. We went through all the things that people reported and came up with a few edge cases that were very confusing when comparisons were chained and % was mixed with * or /.

One thing that we are not changing is the fact that we remove extra parenthesis around combinations of basic arithmetic operators: +-*/.

// Before
x !== y === z;
x * y % z;

// After
(x !== y) === z;
(x * y) % z;

Implement prettier-ignore inside JSX (#2487) by @azz

It's useful to be able to ignore pieces of JSX, it's now possible to add a comment inside of a JSX expression to ignore the formatting of the next element.

// Before
<Component>
  {/*prettier-ignore*/}
  <span ugly format="" />
</Component>

// Before
<Component>
{/prettier-ignore/}
<span ugly format='' />
</Component>

Do not swallow prettier-ignore comments (#2664)

In order to support some edge cases, in the internals, we have the ability to avoid printing comments in a generic way and print them in the call site instead. It turns out that when we used prettier-ignore, we didn't print the comments at all! This is now fixed.

// Before
push(
  <td> :)
  </td>,
);

// After
push(
// prettier-ignore
<td> :)
</td>,
);

Fix indentation of a do-while condition (#2359) by @jsnajdr

It took 6 months for someone to report that do-while were broken when the while condition is multi-line, it confirms my hunch that this construct is not widely used in practice.

// Before
do {} while (
  someVeryLongFunc(
  someVeryLongArgA,
  someVeryLongArgB,
  someVeryLongArgC
)
);

// After
do {} while (
someVeryLongFunc(
someVeryLongArgA,
someVeryLongArgB,
someVeryLongArgC
)
);

Break sequence expressions (#2388) by @bakkot

Another underused feature of JavaScript is sequence expressions. We used to do a bad job at printing them when they would go multi-line, this has been corrected :)

// Before
(a = b ? c : "lllllllllllllllllllllll"), (a = b
  ? c
  : "lllllllllllllllllllllll"), (a = b ? c : "lllllllllllllllllllllll"), (a = b
  ? c
  : "lllllllllllllllllllllll"), (a = b ? c : "lllllllllllllllllllllll");

// After
(a = b ? c : 'lllllllllllllllllllllll'),
(a = b ? c : 'lllllllllllllllllllllll'),
(a = b ? c : 'lllllllllllllllllllllll'),
(a = b ? c : 'lllllllllllllllllllllll'),
(a = b ? c : 'lllllllllllllllllllllll')

Trim trailing whitespace from comments (#2494) by @azz

We took the stance with prettier to remove all the trailing whitespaces. We used to not touch comments because it's user generated, but that doesn't mean that they should have whitespace :)

// Before
// There is some space here ->______________

// After
// There is some space here ->

Fix interleaved comments in class decorators (#2660, #2661)

Our handling for comments inside of the class declaration was very naive, we would just move all the comments to the top. We now are more precise and respect the comments that are interleaved inside of decorators and around extends.

// Before
// A
// B
// C
@Foo()
@Bar()
class Bar {}

// After
// A
@Foo()
// B
@Bar()
// C
class Bar {}

Improve bind expression formatting (#2493) by @azz

Bind expressions are being discussed at TC39 and we figured we could print it with prettier. We used to be very naive about it and just chain it. Now, we use the same logic as we have for method chaining with the . operator for it. We also fixed some edge cases where it would output invalid code.

// Before
observable::filter(data => data.someTest)::throttle(() =>
  interval(10)::take(1)::takeUntil(observable::filter(data => someOtherTest))
)::map(someFunction);

// After
observable
::filter(data => data.someTest)
::throttle(() =>
interval(10)::take(1)::takeUntil(observable::filter(data => someOtherTest))
)
::map(someFunction);

Add support for printing optional catch binding (#2570) by @existentialism

It's being discussed at TC39 to be able to make the argument of a catch(e) optional. Let's make sure we can support it in prettier if people use it.

// Before
Syntax error

// After
try {} catch {}

Add support for printing optional chaining syntax (#2572) by @azz

Another new proposal being discussed at TC39 is an optional chaining syntax. This is currently a stage 1 proposal, so the syntax may change at any time.

obj?.prop       // optional static property access
obj?.[expr]     // optional dynamic property access
func?.(...args) // optional function or method call

Handle Closure Compiler type cast syntax correctly (#2484) by @yangsu

Comments are tricky to get right, but especially when they have meaning based on where they are positioned. We're now special casing the way we deal with comments used as type cast for Closure Compiler such that they keep having the same semantics.

// Before
let assignment /** @type {string} */ = getValue();

// After
let assignment = /** @type {string} */ (getValue());

Inline first computed property lookup in member chain (#2670) by @azz

It looks kind of odd to have a computed property lookup on the next line, so we added a special case to inline it.

// Before
data
  [key]('foo')
  .then(() => console.log('bar'))
  .catch(() => console.log('baz'));

// After
data[key]('foo')
.then(() => console.log('bar'))
.catch(() => console.log('baz'));

Flow

Support opaque types and export star (#2543, #2542) by @existentialism

The flow team introduced two very exciting features under a new syntax. We now support them in prettier. I've personally been waiting for opaque types for a veerrryyyy long time!

// Before
Syntax error

// After
opaque type ID = string;
export type * from "module";

Strip away unnecessary quotes in keys in type objects and interfaces (#2643)

We've been doing this on JavaScript objects since the early days of prettier but forgot to apply the same thing to Flow and TypeScript types.

// Before
type A = {
  "string": "A";
}

// After
type A = {
string: "A";
}

Print TypeParameter even when unary function type (#2406) by @danwang

Oopsy, we were dropping the generic in this very specific case.

// Before
type myFunction = A => B;

// After
type myFunction = <T>(A) => B;

Keep parens around FunctionTypeAnnotation inside ArrayTypeAnnotation (#2561) by @azz

Parenthesis... someday we'll get all of them fixed :)

// Before
const actionArray: () => void[] = [];

// After
const actionArray: (() => void)[] = [];

TypeScript

Support TypeScript 2.5 RC (#2672) by @azz

TypeScript 2.5 RC was recently announced, allowing you to use the upcoming "optional catch binding" syntax in TypeScript, too. πŸŽ‰

Don't add namespace keyword to global declaration (#2329) by @azz

// Before
namespace global {
  export namespace JSX {  }
}

// After
global {
export namespace JSX {}
}

Fix <this.Component /> (#2472) by @backus

Thanks to the untyped and permissive nature of JavaScript, we've been able to concat undefined to a string and get some interesting code as a result. Now fixed for this case :)

// Before
<undefined.Author />

// After
<this.Author />

Allow type assertions to hug (#2439) by @azz

We want to make sure that all the special cases that we added for JavaScript and Flow also work for TypeScript constructs. In this case, objects should also hug if they are wrapped in a as operator.

// Before
const state = JSON.stringify(
  {
    next: window.location.href,
    nonce,
  } as State
);

// After
const state = JSON.stringify({
next: window.location.href,
nonce,
} as State);

Remove parens for type assertions in binary expressions (#2419) by @azz

Most of the time we add parenthesis for correctness but in this case, we added them for nothing, so we can just get rid of them and have a cleaner code :)

// Before
(<x>a) || {};

// After
<x>a || {};

Print parens around type assertion as LHS in assignment (#2525) by @azz

Yet another case of missing parenthesis. Thankfully we're getting very few of them nowadays and they are for extremely rare edge cases.

// Before
foo.bar as Baz = [bar];

// After
(foo.bar as Baz) = [bar];

Print declare for TSInterfaceDeclaration (#2574) by @existentialism

The declare keyword doesn't do anything for interface so we never put it there. However, it felt weird if you were in a declaration file and seeing everything have declare before it except for interfaces. So now we reprint declare if it was there in the first place.

// Before
interface Dictionary<T> {
  [index: string]: T
}

// After
declare interface Dictionary<T> {
[index: string]: T
}

CSS

Normalize quotes in CSS (#2624) by @lydell

In order to get a first version of CSS to ship, we kept string quotes as is. We are now respecting the singleQuote option of prettier. The difficulty here was to make sure that we output correct code for all the crazy escapes, unicode characters, emoji, special rules like charset which only work with double quotes...

// Before
div {
  content: "abc";
}

// After
div {
content: 'abc';
}

Normalize numbers in CSS (#2627) by @lydell

Another place where we can reuse the logic we've done for JavaScript to improve CSS printing.

// Before
border: 1px solid rgba(0., 0.0, .0, .3);

// After
border: 1px solid rgba(0, 0, 0, 0.3);

Quote unquoted CSS attribute values in selectors (#2644) by @lydell

I can never quite remember the rules behind quotes around attributes so we're now always putting quotes there.

// Before
a[id=test] {}

// After
a[id="test"] {}

Add support for css keyword (#2337) by @zanza00

// Before
const header = css`.top-bar {background: black;margin: 0;position: fixed;}`

// After
const header = css</span></span> <span class="pl-s"> .top-bar {</span> <span class="pl-s"> background: black;</span> <span class="pl-s"> margin: 0;</span> <span class="pl-s"> position: fixed;</span> <span class="pl-s"> }</span> <span class="pl-s"><span class="pl-pds">;

Support styled-components with existing component (#2552, #2619) by @azz

styled-components has a lot of different variants for tagging template literals as CSS. It's not ideal that we've got to encode all those ways inside of prettier but since we started, might as well do it for real.

styled(ExistingComponent)`
  css: property;
`;

styled.button.attr({})</span></span> <span class="pl-s"> border: rebeccapurple;</span> <span class="pl-s"><span class="pl-pds">;

Trim whitespace in descendant combinator (#2411) by @azz

The CSS parsers we use do not give us a 100% semantic tree: in many occasions they bail and just give us what is being entered. It's up to us to make sure we clean this up while maintaining correctness. In this case, we just printed spaces between selectors as is but we know it's correct to always replace it by a single space.

// Before
.hello
        .<span class="pl-smi">how</span><span class="pl-k">-</span>you<span class="pl-k">-</span>doin {

height: 42;
}

// After
.hello .how-you-doin {
height: 42;
}

Strip BOM before parsing (#2373) by @azz

I still have nightmares from dealing with BOM in a previous life. Thankfully, in 2017 it's no longer a big issue as most tooling is now aware of it. Thanks @azz for fixing an edge cases related to CSS parsing.

// Before
[BOM]/* Block comment *
html {
  content: "#{1}";  
}
// After
[BOM]/* Block comment */
html {
  content: "#{1}";  
}

GraphQL

Add support for range-formatting GraphQL (#2319) by @josephfrazier

If you tried to use the range formatting feature in a GraphQL file, it would throw an exception, now it properly worked again and only reformats the piece you selected.

Add .gql file extension to be parsed as GraphQL (#2357) by @rrdelaney

At Facebook, we use .graphql extension but it looks like it's common to have .gql as well, doesn't cost a lot to support it in the heuristic that figures out what parser to use.

CLI

Support multiple patterns with ignore pattern (#2356) by @evilebottnawi

It was already possible to have multiple glob patterns but they would be additive, with this change, you can add a glob pattern to ignore some files. It should be very handy to ignore folders that are deeply nested.

prettier --write '{**/*,*}.{js,jsx,json}' '!vendor/**'

Make --list-different to work with --stdin (#2393) by @josephfrazier

This is a handy way of knowing if prettier would print a piece of code in a different way. We already had all the concepts in place, we just needed to wire them up correctly.

$ echo 'call ( ) ;' | prettier --list-different
(stdin)
$ echo $?
1
Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.