-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yannick Croissant
committed
Dec 28, 2014
1 parent
f2faa43
commit fda9f8f
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @fileoverview Prevent multiple component definition per file | ||
* @author Yannick Croissant | ||
*/ | ||
'use strict'; | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Requirements | ||
// ------------------------------------------------------------------------------ | ||
|
||
var eslint = require('eslint').linter; | ||
var ESLintTester = require('eslint-tester'); | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Tests | ||
// ------------------------------------------------------------------------------ | ||
|
||
var eslintTester = new ESLintTester(eslint); | ||
eslintTester.addRuleTest('lib/rules/no-multi-comp', { | ||
|
||
valid: [ | ||
{ | ||
code: 'var Hello = require(\'./components/Hello\');var HelloJohn = React.createClass({render: function() {return <Hello name="John" />;}});', | ||
settings: { | ||
ecmascript: 6, | ||
jsx: true | ||
} | ||
} | ||
], | ||
|
||
invalid: [ | ||
{ | ||
code: 'var Hello = React.createClass({render: function() {return <div>Hello {this.props.name}</div>;}});var HelloJohn = React.createClass({render: function() {return <Hello name="John" />;}});', | ||
settings: { | ||
ecmascript: 6, | ||
jsx: true | ||
}, | ||
errors: [{ | ||
message: 'Declare only one React component per file' | ||
}] | ||
} | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @fileoverview Prevent missing propTypes in a React component definition | ||
* @author Yannick Croissant | ||
*/ | ||
'use strict'; | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Requirements | ||
// ------------------------------------------------------------------------------ | ||
|
||
var eslint = require('eslint').linter; | ||
var ESLintTester = require('eslint-tester'); | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Tests | ||
// ------------------------------------------------------------------------------ | ||
|
||
var eslintTester = new ESLintTester(eslint); | ||
eslintTester.addRuleTest('lib/rules/prop-types', { | ||
|
||
valid: [ | ||
{ | ||
code: 'var Hello = React.createClass({propTypes: {name: React.PropTypes.string.isRequired},render: function() {return <div>Hello {this.props.name}</div>;}});', | ||
settings: { | ||
ecmascript: 6, | ||
jsx: true | ||
} | ||
} | ||
], | ||
|
||
invalid: [ | ||
{ | ||
code: 'var Hello = React.createClass({render: function() {return <div>Hello {this.props.name}</div>;}});', | ||
settings: { | ||
ecmascript: 6, | ||
jsx: true | ||
}, | ||
errors: [{ | ||
message: 'Component definition is missing props validation' | ||
}] | ||
} | ||
] | ||
}); |