Skip to content

Commit

Permalink
Add support for childContextTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Joachim Seminck committed May 21, 2017
1 parent c3e1964 commit 9ad59da
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
13 changes: 13 additions & 0 deletions docs/rules/no-static-typos.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ no casing typos:

* propTypes
* contextTypes
* childContextTypes
* defaultProps

The following patterns are considered warnings:
Expand All @@ -31,6 +32,14 @@ class MyComponent extends React.Component {
static contexttypes = {}
}

class MyComponent extends React.Component {
static ChildContextTypes = {}
}

class MyComponent extends React.Component {
static childcontexttypes = {}
}

class MyComponent extends React.Component {
static DefaultProps = {}
}
Expand All @@ -51,6 +60,10 @@ class MyComponent extends React.Component {
static contextTypes = {}
}

class MyComponent extends React.Component {
static childContextTypes = {}
}

class MyComponent extends React.Component {
static defaultProps = {}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-static-typos.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var Components = require('../util/Components');
// Rule Definition
// ------------------------------------------------------------------------------

var STATIC_CLASS_PROPERTIES = ['propTypes', 'contextTypes', 'defaultProps'];
var STATIC_CLASS_PROPERTIES = ['propTypes', 'contextTypes', 'childContextTypes', 'defaultProps'];

module.exports = {
meta: {
Expand Down
25 changes: 25 additions & 0 deletions tests/lib/rules/no-static-typos.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ruleTester.run('no-static-typos', rule, {
'class First {',
' static PropTypes = {key: "myValue"};',
' static ContextTypes = {key: "myValue"};',
' static ChildContextTypes = {key: "myValue"};',
' static DefaultProps = {key: "myValue"};',
'}'
].join('\n'),
Expand All @@ -40,6 +41,7 @@ ruleTester.run('no-static-typos', rule, {
'class First extends React.Component {',
' static propTypes = {key: "myValue"};',
' static contextTypes = {key: "myValue"};',
' static childContextTypes = {key: "myValue"};',
' static defaultProps = {key: "myValue"};',
'}'
].join('\n'),
Expand All @@ -50,6 +52,7 @@ ruleTester.run('no-static-typos', rule, {
'class MyClass {',
' propTypes = {key: "myValue"};',
' contextTypes = {key: "myValue"};',
' childContextTypes = {key: "myValue"};',
' defaultProps = {key: "myValue"};',
'}'
].join('\n'),
Expand All @@ -60,6 +63,7 @@ ruleTester.run('no-static-typos', rule, {
'class MyClass {',
' PropTypes = {key: "myValue"};',
' ContextTypes = {key: "myValue"};',
' ChildContextTypes = {key: "myValue"};',
' DefaultProps = {key: "myValue"};',
'}'
].join('\n'),
Expand All @@ -70,6 +74,7 @@ ruleTester.run('no-static-typos', rule, {
'class MyClass {',
' proptypes = {key: "myValue"};',
' contexttypes = {key: "myValue"};',
' childcontextypes = {key: "myValue"};',
' defaultprops = {key: "myValue"};',
'}'
].join('\n'),
Expand All @@ -80,6 +85,7 @@ ruleTester.run('no-static-typos', rule, {
'class MyClass {',
' static PropTypes() {};',
' static ContextTypes() {};',
' static ChildContextTypes() {};',
' static DefaultProps() {};',
'}'
].join('\n'),
Expand All @@ -90,6 +96,7 @@ ruleTester.run('no-static-typos', rule, {
'class MyClass {',
' static proptypes() {};',
' static contexttypes() {};',
' static childcontexttypes() {};',
' static defaultprops() {};',
'}'
].join('\n'),
Expand Down Expand Up @@ -133,6 +140,24 @@ ruleTester.run('no-static-typos', rule, {
parser: 'babel-eslint',
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'class Component extends React.Component {',
' static ChildContextTypes = {};',
'}'
].join('\n'),
parser: 'babel-eslint',
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'class Component extends React.Component {',
' static childcontexttypes = {};',
'}'
].join('\n'),
parser: 'babel-eslint',
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'class Component extends React.Component {',
Expand Down

0 comments on commit 9ad59da

Please sign in to comment.