Skip to content

Commit

Permalink
Merge pull request #99 from seegno/feature/react-prefer-stateless-fun…
Browse files Browse the repository at this point in the history
…ction

Add react prefer-stateless-function rule
  • Loading branch information
bsonntag authored Mar 27, 2019
2 parents ecc610e + bade78f commit fd5a543
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ module.exports = {
'react/no-string-refs': 'error',
'react/no-unknown-property': 'error',
'react/prefer-es6-class': 'error',
'react/prefer-stateless-function': 'error',
'react/react-in-jsx-scope': 'error',
'react/self-closing-comp': 'error',
'react/sort-comp': ['error', {
Expand Down
15 changes: 15 additions & 0 deletions test/fixtures/correct.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,18 @@ const TagSpacing = () => (
);

noop(TagSpacing);

// `react/prefer-stateless-function`.
class PreferStatelessFunction extends React.Component {

getFoo = () => {
return 'foo';
}

render() {
return this.getFoo();
}

}

noop(PreferStatelessFunction);
11 changes: 11 additions & 0 deletions test/fixtures/incorrect.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,14 @@ const TagSpacingClosingSlash = () => (
);

noop(TagSpacingClosingSlash);

// `react/prefer-stateless-function`.
class PreferStatelessFunction extends React.Component {

render() {
return null;
}

}

noop(PreferStatelessFunction);
3 changes: 2 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ describe('eslint-config-seegno', () => {
'react/jsx-tag-spacing',
'react/jsx-tag-spacing',
'react/jsx-tag-spacing',
'react/jsx-tag-spacing'
'react/jsx-tag-spacing',
'react/prefer-stateless-function'
]);
});
});

0 comments on commit fd5a543

Please sign in to comment.