Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Update rules for eslint-plugin-react to v7.13 #114

Merged
merged 5 commits into from
May 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion config/eslintrc_react.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ module.exports = {
'react/no-render-return-value': 2,
'react/no-redundant-should-component-update': 1,
'react/no-set-state': 0,
'react/no-string-refs': 2,
'react/no-string-refs': [2, {
'noTemplateLiterals': true,
}],
'react/no-this-in-sfc': 1,
'react/no-typos': 0,
'react/no-unescaped-entities': 2,
Expand All @@ -78,6 +80,8 @@ module.exports = {
// We don't think this code is produced in a common case. If you need it, let's opt out/
'react/no-will-update-set-state': 2,
'react/prefer-es6-class': 2,
// At v7.13, this only supports Flowtype.
'react/prefer-read-only-props': 'off',
'react/prefer-stateless-function': [1, {
'ignorePureComponents': true,
}],
Expand All @@ -94,6 +98,13 @@ module.exports = {
'component': true,
'html': false,
}],
// A _state_ usually depends on some value hold by its instance.
// So it's more reasonable way to init in the constructor.
'react/state-in-constructor': ['error', 'always'],
// I seem this might be a problematic only for class component,
// But we lives in the era of hooks and almost properties which is targeted by this rule
// are classic (non-recommended in today) ones.
'react/static-property-placement': 'off',
'react/void-dom-elements-no-children': 1,

// We define customized rules because we thought default settings mixes with
Expand Down Expand Up @@ -186,6 +197,12 @@ module.exports = {
'allowAllCaps': false,
'ignore': [],
}],
// This is good for maintainability by avoiding passing unintentional extra props.
'react/jsx-props-no-spreading': ['error', {
'html': 'enforce',
'custom': 'enforce',
'exceptions': [],
}],
'react/jsx-sort-default-props': 0,
'react/jsx-sort-props': 0, // we cannot force alphabetical order to our old codebase, and this is meaningless.
'react/jsx-props-no-multi-spaces': 1,
Expand Down