diff --git a/docs/rules/display-name.md b/docs/rules/display-name.md
index e7c13772cd..99e7a7941a 100644
--- a/docs/rules/display-name.md
+++ b/docs/rules/display-name.md
@@ -35,7 +35,7 @@ var Hello = React.createClass({
### `acceptTranspilerName`
-When `true` the rule will accept the name set by the transpiler and does not require a `displayName` property in this case.
+When `true` (default) the rule will accept the name set by the transpiler and does not require a `displayName` property in this case.
The following patterns are considered okay and do not cause warnings:
diff --git a/lib/rules/display-name.js b/lib/rules/display-name.js
index 728c843cbe..3b742d742b 100644
--- a/lib/rules/display-name.js
+++ b/lib/rules/display-name.js
@@ -13,7 +13,9 @@ var Components = require('../util/Components');
module.exports = Components.detect(function(context, components, utils) {
var config = context.options[0] || {};
- var acceptTranspilerName = config.acceptTranspilerName || false;
+ var acceptTranspilerName = config.hasOwnProperty('acceptTranspilerName') ?
+ config.acceptTranspilerName :
+ true;
var MISSING_MESSAGE = 'Component definition is missing display name';
diff --git a/tests/lib/rules/display-name.js b/tests/lib/rules/display-name.js
index 62e3cc105a..3b94c5399a 100644
--- a/tests/lib/rules/display-name.js
+++ b/tests/lib/rules/display-name.js
@@ -43,6 +43,9 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parserOptions: parserOptions
}, {
code: [
@@ -53,6 +56,9 @@ ruleTester.run('display-name', rule, {
'}',
'Hello.displayName = \'Hello\''
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parserOptions: parserOptions
}, {
code: [
@@ -62,6 +68,9 @@ ruleTester.run('display-name', rule, {
' }',
'}'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parserOptions: parserOptions
}, {
code: [
@@ -72,6 +81,9 @@ ruleTester.run('display-name', rule, {
' }',
'}'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint'
}, {
code: [
@@ -79,6 +91,9 @@ ruleTester.run('display-name', rule, {
' method;',
'}'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint',
parserOptions: parserOptions
}, {
@@ -92,6 +107,9 @@ ruleTester.run('display-name', rule, {
' }',
'}'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parserOptions: parserOptions
}, {
code: [
@@ -102,6 +120,9 @@ ruleTester.run('display-name', rule, {
' }',
'}'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint',
parserOptions: parserOptions
}, {
@@ -112,9 +133,6 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
- options: [{
- acceptTranspilerName: true
- }],
parserOptions: parserOptions
}, {
code: [
@@ -124,10 +142,7 @@ ruleTester.run('display-name', rule, {
' }',
'}'
].join('\n'),
- parser: 'babel-eslint',
- options: [{
- acceptTranspilerName: true
- }]
+ parser: 'babel-eslint'
}, {
code: [
'export default class Hello {',
@@ -136,10 +151,7 @@ ruleTester.run('display-name', rule, {
' }',
'}'
].join('\n'),
- parser: 'babel-eslint',
- options: [{
- acceptTranspilerName: true
- }]
+ parser: 'babel-eslint'
}, {
code: [
'var Hello;',
@@ -149,9 +161,6 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
- options: [{
- acceptTranspilerName: true
- }],
parserOptions: parserOptions
}, {
code: [
@@ -164,6 +173,9 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parserOptions: parserOptions
}, {
code: [
@@ -173,6 +185,9 @@ ruleTester.run('display-name', rule, {
' }',
'}'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint'
}, {
code: [
@@ -180,40 +195,28 @@ ruleTester.run('display-name', rule, {
' return
Hello {this.props.name}
;',
'}'
].join('\n'),
- parser: 'babel-eslint',
- options: [{
- acceptTranspilerName: true
- }]
+ parser: 'babel-eslint'
}, {
code: [
'function Hello() {',
' return Hello {this.props.name}
;',
'}'
].join('\n'),
- parser: 'babel-eslint',
- options: [{
- acceptTranspilerName: true
- }]
+ parser: 'babel-eslint'
}, {
code: [
'var Hello = () => {',
' return Hello {this.props.name}
;',
'}'
].join('\n'),
- parser: 'babel-eslint',
- options: [{
- acceptTranspilerName: true
- }]
+ parser: 'babel-eslint'
}, {
code: [
'module.exports = function Hello() {',
' return Hello {this.props.name}
;',
'}'
].join('\n'),
- parser: 'babel-eslint',
- options: [{
- acceptTranspilerName: true
- }]
+ parser: 'babel-eslint'
}, {
code: [
'function Hello() {',
@@ -221,6 +224,9 @@ ruleTester.run('display-name', rule, {
'}',
'Hello.displayName = \'Hello\';'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint'
}, {
code: [
@@ -229,6 +235,9 @@ ruleTester.run('display-name', rule, {
'}',
'Hello.displayName = \'Hello\';'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint'
}, {
code: [
@@ -237,6 +246,9 @@ ruleTester.run('display-name', rule, {
'}',
'Hello.displayName = \'Hello\';'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint'
}, {
code: [
@@ -249,6 +261,9 @@ ruleTester.run('display-name', rule, {
'}',
'Mixins.Greetings.Hello.displayName = \'Hello\';'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint'
}, {
code: [
@@ -261,10 +276,7 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
- parser: 'babel-eslint',
- options: [{
- acceptTranspilerName: true
- }]
+ parser: 'babel-eslint'
}, {
code: [
'var Hello = React.createClass({',
@@ -277,6 +289,9 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint'
}, {
code: [
@@ -288,10 +303,7 @@ ruleTester.run('display-name', rule, {
' }',
'};'
].join('\n'),
- parser: 'babel-eslint',
- options: [{
- acceptTranspilerName: true
- }]
+ parser: 'babel-eslint'
}, {
code: [
'var obj = {',
@@ -300,10 +312,7 @@ ruleTester.run('display-name', rule, {
' }',
'};'
].join('\n'),
- parser: 'babel-eslint',
- options: [{
- acceptTranspilerName: true
- }]
+ parser: 'babel-eslint'
}, {
code: [
'export default {',
@@ -313,6 +322,9 @@ ruleTester.run('display-name', rule, {
' }',
'};'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint'
}, {
code: [
@@ -324,6 +336,9 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint'
}
],
@@ -336,6 +351,9 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parserOptions: parserOptions,
errors: [{
message: 'Component definition is missing display name'
@@ -348,6 +366,9 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parserOptions: parserOptions,
errors: [{
message: 'Component definition is missing display name'
@@ -360,6 +381,9 @@ ruleTester.run('display-name', rule, {
' }',
'}'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parserOptions: parserOptions,
errors: [{
message: 'Component definition is missing display name'
@@ -375,9 +399,6 @@ ruleTester.run('display-name', rule, {
'}',
'module.exports = HelloComponent();'
].join('\n'),
- options: [{
- acceptTranspilerName: true
- }],
parserOptions: parserOptions,
errors: [{
message: 'Component definition is missing display name'
@@ -389,9 +410,6 @@ ruleTester.run('display-name', rule, {
'}'
].join('\n'),
parser: 'babel-eslint',
- options: [{
- acceptTranspilerName: true
- }],
errors: [{
message: 'Component definition is missing display name'
}]
@@ -402,9 +420,6 @@ ruleTester.run('display-name', rule, {
'}'
].join('\n'),
parser: 'babel-eslint',
- options: [{
- acceptTranspilerName: true
- }],
errors: [{
message: 'Component definition is missing display name'
}]
@@ -419,6 +434,9 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint',
errors: [{
message: 'Component definition is missing display name'
@@ -434,6 +452,9 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint',
settings: settings,
errors: [{
@@ -451,6 +472,9 @@ ruleTester.run('display-name', rule, {
' }',
'});'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint',
errors: [{
message: 'Component definition is missing display name'
@@ -465,6 +489,9 @@ ruleTester.run('display-name', rule, {
' }',
'};'
].join('\n'),
+ options: [{
+ acceptTranspilerName: false
+ }],
parser: 'babel-eslint',
errors: [{
message: 'Component definition is missing display name'