From 5a02508c8be6ae0add95bddb686b8f0b3bb69a3d Mon Sep 17 00:00:00 2001 From: Adnan Asani Date: Wed, 15 Feb 2017 18:30:13 +0100 Subject: [PATCH] add missing prefix on option examples --- docs/rules/jsx-closing-bracket-location.md | 10 ++--- docs/rules/jsx-max-props-per-line.md | 6 +-- docs/rules/no-unused-prop-types.md | 2 +- docs/rules/prop-types.md | 2 +- docs/rules/require-extension.md | 48 ++++++++++++++++++++++ docs/rules/self-closing-comp.md | 2 +- docs/rules/sort-comp.md | 2 +- 7 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 docs/rules/require-extension.md diff --git a/docs/rules/jsx-closing-bracket-location.md b/docs/rules/jsx-closing-bracket-location.md index 67d3dd5687..f524b87905 100644 --- a/docs/rules/jsx-closing-bracket-location.md +++ b/docs/rules/jsx-closing-bracket-location.md @@ -71,7 +71,7 @@ The following patterns are considered warnings: // 'jsx-closing-bracket-location': 1 // 'jsx-closing-bracket-location': [1, 'tag-aligned'] // 'jsx-closing-bracket-location': [1, 'line-aligned'] -; @@ -114,7 +114,7 @@ var x = function() { }; // 'jsx-closing-bracket-location': [1, 'after-props'] -; @@ -127,7 +127,7 @@ var x = function() { ; // 'jsx-closing-bracket-location': [1, 'props-aligned'] -; @@ -188,7 +188,7 @@ var x = function() { }; // 'jsx-closing-bracket-location': [1, {selfClosing: 'after-props'}] -; @@ -200,7 +200,7 @@ var x = function() { ; // 'jsx-closing-bracket-location': [1, {selfClosing: 'props-aligned', nonEmpty: 'after-props'}] -; diff --git a/docs/rules/jsx-max-props-per-line.md b/docs/rules/jsx-max-props-per-line.md index 4baaf90e14..eedba3d3b8 100644 --- a/docs/rules/jsx-max-props-per-line.md +++ b/docs/rules/jsx-max-props-per-line.md @@ -76,9 +76,9 @@ The following patterns are not considered warnings: ```jsx // [1, { "when": "multiline" }] - ``` diff --git a/docs/rules/no-unused-prop-types.md b/docs/rules/no-unused-prop-types.md index f4982abdc7..1b919b7f1f 100644 --- a/docs/rules/no-unused-prop-types.md +++ b/docs/rules/no-unused-prop-types.md @@ -45,7 +45,7 @@ var Hello = createReactClass({ This rule can take one argument to ignore some specific props during validation. -``` +```js ... "react/no-unused-prop-types": [, { customValidators: , skipShapeProps: }] ... diff --git a/docs/rules/prop-types.md b/docs/rules/prop-types.md index 6819f8406b..15ceb3fd3c 100644 --- a/docs/rules/prop-types.md +++ b/docs/rules/prop-types.md @@ -100,7 +100,7 @@ Hello.propTypes = { This rule can take one argument to ignore some specific props during validation. -``` +```js ... "react/prop-types": [, { ignore: , customValidators: }] ... diff --git a/docs/rules/require-extension.md b/docs/rules/require-extension.md new file mode 100644 index 0000000000..686206f7fa --- /dev/null +++ b/docs/rules/require-extension.md @@ -0,0 +1,48 @@ +# Restrict file extensions that may be required (require-extension) + +**Deprecation notice**: This rule is deprecated. Please use the eslint-plugin-import [extensions](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md) rule instead. + +`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 +... +"react/require-extension": [1, { "extensions": [".js", ".jsx"] }], +... +``` + +To configure WebPack to resolve '.jsx' add the following to `webpack.config.js`: + +```js +resolve: { + 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. diff --git a/docs/rules/self-closing-comp.md b/docs/rules/self-closing-comp.md index 2913c5ef3c..a81d54f274 100644 --- a/docs/rules/self-closing-comp.md +++ b/docs/rules/self-closing-comp.md @@ -1,4 +1,4 @@ -# Prevent extra closing tags for components without children (self-closing-comp) +# Prevent extra closing tags for components without children (react/self-closing-comp) Components without children can be self-closed to avoid unnecessary extra closing tag. diff --git a/docs/rules/sort-comp.md b/docs/rules/sort-comp.md index 88da135b23..adac465cff 100644 --- a/docs/rules/sort-comp.md +++ b/docs/rules/sort-comp.md @@ -39,7 +39,7 @@ var Hello = createReactClass({ This rule can take one argument to customize the components organisation. -``` +```js ... "react/sort-comp": [, { order: , groups: }] ...