Skip to content

Commit 3aa552c

Browse files
author
Joachim Seminck
committed
Add support for childContextTypes
1 parent 84ee72e commit 3aa552c

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

docs/rules/no-static-typos.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ no casing typos:
1010

1111
* propTypes
1212
* contextTypes
13+
* childContextTypes
1314
* defaultProps
1415

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

35+
class MyComponent extends React.Component {
36+
static ChildContextTypes = {}
37+
}
38+
39+
class MyComponent extends React.Component {
40+
static childcontexttypes = {}
41+
}
42+
3443
class MyComponent extends React.Component {
3544
static DefaultProps = {}
3645
}
@@ -51,6 +60,10 @@ class MyComponent extends React.Component {
5160
static contextTypes = {}
5261
}
5362

63+
class MyComponent extends React.Component {
64+
static childContextTypes = {}
65+
}
66+
5467
class MyComponent extends React.Component {
5568
static defaultProps = {}
5669
}

lib/rules/no-static-typos.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var Components = require('../util/Components');
99
// Rule Definition
1010
// ------------------------------------------------------------------------------
1111

12-
var STATIC_CLASS_PROPERTIES = ['propTypes', 'contextTypes', 'defaultProps'];
12+
var STATIC_CLASS_PROPERTIES = ['propTypes', 'contextTypes', 'childContextTypes', 'defaultProps'];
1313

1414
module.exports = {
1515
meta: {

tests/lib/rules/no-static-typos.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ ruleTester.run('no-static-typos', rule, {
3030
'class First {',
3131
' static PropTypes = {key: "myValue"};',
3232
' static ContextTypes = {key: "myValue"};',
33+
' static ChildContextTypes = {key: "myValue"};',
3334
' static DefaultProps = {key: "myValue"};',
3435
'}'
3536
].join('\n'),
@@ -40,6 +41,7 @@ ruleTester.run('no-static-typos', rule, {
4041
'class First extends React.Component {',
4142
' static propTypes = {key: "myValue"};',
4243
' static contextTypes = {key: "myValue"};',
44+
' static childContextTypes = {key: "myValue"};',
4345
' static defaultProps = {key: "myValue"};',
4446
'}'
4547
].join('\n'),
@@ -50,6 +52,7 @@ ruleTester.run('no-static-typos', rule, {
5052
'class MyClass {',
5153
' propTypes = {key: "myValue"};',
5254
' contextTypes = {key: "myValue"};',
55+
' childContextTypes = {key: "myValue"};',
5356
' defaultProps = {key: "myValue"};',
5457
'}'
5558
].join('\n'),
@@ -60,6 +63,7 @@ ruleTester.run('no-static-typos', rule, {
6063
'class MyClass {',
6164
' PropTypes = {key: "myValue"};',
6265
' ContextTypes = {key: "myValue"};',
66+
' ChildContextTypes = {key: "myValue"};',
6367
' DefaultProps = {key: "myValue"};',
6468
'}'
6569
].join('\n'),
@@ -70,6 +74,7 @@ ruleTester.run('no-static-typos', rule, {
7074
'class MyClass {',
7175
' proptypes = {key: "myValue"};',
7276
' contexttypes = {key: "myValue"};',
77+
' childcontextypes = {key: "myValue"};',
7378
' defaultprops = {key: "myValue"};',
7479
'}'
7580
].join('\n'),
@@ -80,6 +85,7 @@ ruleTester.run('no-static-typos', rule, {
8085
'class MyClass {',
8186
' static PropTypes() {};',
8287
' static ContextTypes() {};',
88+
' static ChildContextTypes() {};',
8389
' static DefaultProps() {};',
8490
'}'
8591
].join('\n'),
@@ -90,6 +96,7 @@ ruleTester.run('no-static-typos', rule, {
9096
'class MyClass {',
9197
' static proptypes() {};',
9298
' static contexttypes() {};',
99+
' static childcontexttypes() {};',
93100
' static defaultprops() {};',
94101
'}'
95102
].join('\n'),
@@ -133,6 +140,24 @@ ruleTester.run('no-static-typos', rule, {
133140
parser: 'babel-eslint',
134141
parserOptions: parserOptions,
135142
errors: [{message: ERROR_MESSAGE}]
143+
}, {
144+
code: [
145+
'class Component extends React.Component {',
146+
' static ChildContextTypes = {};',
147+
'}'
148+
].join('\n'),
149+
parser: 'babel-eslint',
150+
parserOptions: parserOptions,
151+
errors: [{message: ERROR_MESSAGE}]
152+
}, {
153+
code: [
154+
'class Component extends React.Component {',
155+
' static childcontexttypes = {};',
156+
'}'
157+
].join('\n'),
158+
parser: 'babel-eslint',
159+
parserOptions: parserOptions,
160+
errors: [{message: ERROR_MESSAGE}]
136161
}, {
137162
code: [
138163
'class Component extends React.Component {',

0 commit comments

Comments
 (0)