Skip to content

Changes no-unused-expressions lint from warning to error#2319

Merged
gaearon merged 3 commits into
react:nextfrom
amupitan:2303-forgetting-to-return-JSX-should-crash-build
Jan 17, 2018
Merged

Changes no-unused-expressions lint from warning to error#2319
gaearon merged 3 commits into
react:nextfrom
amupitan:2303-forgetting-to-return-JSX-should-crash-build

Conversation

@amupitan
Copy link
Copy Markdown
Contributor

Build crashes whenever JSX is not returned as proposed here: #2303.

The build crashes whenever JSX isn't returned, as opposed to just giving a warning.

screenshot

To test:

Create a stateless component without a return clause.
For example:
import React from 'react';
export default function Logo(){
<div className="App-header">
<img src="./logo.svg" className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
}

@gaearon gaearon added this to the 2.0.0 milestone May 22, 2017
@gaearon
Copy link
Copy Markdown
Contributor

gaearon commented May 22, 2017

I’m going to come back to this after we’re ready to cut over to 2.0 (with some other breaking changes). Thanks!

@kachkaev
Copy link
Copy Markdown

It'd be great if you considered adding allowTaggedTemplates: true if accepting this PR. See motivation in eslint/eslint#7632.

Without allowTaggedTemplates: true, things like this will cause an error, which is definitely not wanted:

import { injectGlobal } from 'styled-components';

injectGlobal`
  body {
    background: #f00,
  }
`;

@gaearon gaearon changed the base branch from master to next January 16, 2018 16:23
@gaearon gaearon merged commit ed27629 into react:next Jan 17, 2018
akstuhl pushed a commit to akstuhl/create-react-app that referenced this pull request Mar 15, 2018
* Changes no-unused-expressions lint from warning to error

* Update index.js

* Update index.js
@lock lock Bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants