forked from jsx-eslint/eslint-plugin-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:yannickcr/eslint-plugin-react
* 'master' of github.com:yannickcr/eslint-plugin-react: Add require-extension rule to Readme Add acceptTranspilerName option to display-name rule (fixes jsx-eslint#75) Added support for prop-types check of type `this.props['this-format']`. Used list of nested names instead of dot-separated names to avoid conflict with properties like `this.props['this.format']` Fix crash if a ClassProperty has only one token (fixes jsx-eslint#125) Fix `prop-types` desctructuring with properties as string. Added support for prop type identified by strings in rule `jsx-sort-prop-types` fix detection of missing propTypes validations on ecmaFeatures.jsx false fix detect missing displayName in React class when ecmaFeatures.jsx is false Allow blocking of '.jsx' extensions with `require()` Point directly to mocha instead of symlink in .bin. On Windows the file in .bin is not a symlink. Inspired by solution in eslint Support nested prop types and use react propTypes to make further analysis. Minimal analyse of primitive propTypes.
- Loading branch information
Showing
13 changed files
with
1,275 additions
and
36 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
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
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,38 @@ | ||
# Restrict file extensions that may be required (require-extension) | ||
|
||
`require()` statements should generally not include a file extension as there is a well defined mechanism for resolving a module ID to a specific file. This rule inspects the module ID being required and creates a warning if the ID contains a '.jsx' file extension. | ||
|
||
Note: this rule does not prevent required files from containing these extensions, it merely prevents the extension from being included in the `require()` statement. | ||
|
||
## Rule Details | ||
|
||
The following patterns are considered warnings: | ||
|
||
```js | ||
var index = require('./index.jsx'); | ||
|
||
// When [1, {extensions: ['.js']}] | ||
var index = require('./index.js'); | ||
``` | ||
|
||
The following patterns are not considered warnings: | ||
|
||
```js | ||
var index = require('./index'); | ||
|
||
var eslint = require('eslint'); | ||
``` | ||
|
||
## Rule Options | ||
|
||
The set of forbidden extensions is configurable. By default '.jsx' is blocked. If you wanted to forbid both '.jsx' and '.js', the configuration would be: | ||
|
||
```js | ||
"rules": { | ||
"react/require-extension": [1, { "extensions": [".js", ".jsx"] }], | ||
} | ||
``` | ||
|
||
## When Not To Use It | ||
|
||
If you have file in your project with a '.jsx' file extension and do not have `require()` configured to automatically resolve '.jsx' files. |
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
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
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
Oops, something went wrong.