diff --git a/docs/rules/prefer-stateless-function.md b/docs/rules/prefer-stateless-function.md
index 8d844ed69d..4d8be4cb19 100644
--- a/docs/rules/prefer-stateless-function.md
+++ b/docs/rules/prefer-stateless-function.md
@@ -66,7 +66,7 @@ class Foo extends React.Component {
When `true` the rule will ignore Components extending from `React.PureComponent` that use `this.props` or `this.context`.
-The following pattern is considered okay and does **not** cause warnings:
+The following patterns are considered okay and does **not** cause warnings:
```jsx
class Foo extends React.PureComponent {
@@ -74,14 +74,10 @@ class Foo extends React.PureComponent {
return
{this.props.foo}
;
}
}
-```
-
-The following pattern is considered a warning because it's not using props or context:
-```jsx
-class Foo extends React.PureComponent {
+class Bar extends React.PureComponent {
render() {
- return Bar
;
+ return Baz
;
}
}
```
diff --git a/lib/rules/prefer-stateless-function.js b/lib/rules/prefer-stateless-function.js
index 4550cb54d1..1dd6e63204 100644
--- a/lib/rules/prefer-stateless-function.js
+++ b/lib/rules/prefer-stateless-function.js
@@ -369,7 +369,7 @@ module.exports = {
return;
}
- if (list[component].hasSCU && list[component].usePropsOrContext) {
+ if (list[component].hasSCU) {
return;
}
context.report({
diff --git a/tests/lib/rules/prefer-stateless-function.js b/tests/lib/rules/prefer-stateless-function.js
index 24ad7c3496..22f6b8fe98 100644
--- a/tests/lib/rules/prefer-stateless-function.js
+++ b/tests/lib/rules/prefer-stateless-function.js
@@ -304,6 +304,18 @@ ruleTester.run('prefer-stateless-function', rule, {
}
`,
parser: 'babel-eslint'
+ },
+ {
+ code: `
+ class Child extends PureComponent {
+ render() {
+ return I don't
;
+ }
+ }
+ `,
+ options: [{
+ ignorePureComponents: true
+ }]
}
],
@@ -339,9 +351,6 @@ ruleTester.run('prefer-stateless-function', rule, {
}
}
`,
- options: [{
- ignorePureComponents: true
- }],
errors: [{
message: 'Component should be written as a pure function'
}]