diff --git a/lib/rules/boolean-prop-naming.js b/lib/rules/boolean-prop-naming.js index 6b09b4ba32..eb9a663072 100644 --- a/lib/rules/boolean-prop-naming.js +++ b/lib/rules/boolean-prop-naming.js @@ -7,6 +7,7 @@ const has = require('has'); const Components = require('../util/Components'); const propsUtil = require('../util/props'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -17,7 +18,8 @@ module.exports = { docs: { category: 'Stylistic Issues', description: 'Enforces consistent naming for boolean props', - recommended: false + recommended: false, + url: docsUrl('boolean-prop-naming') }, schema: [{ diff --git a/lib/rules/button-has-type.js b/lib/rules/button-has-type.js index e720bcd040..fa9fb850d2 100644 --- a/lib/rules/button-has-type.js +++ b/lib/rules/button-has-type.js @@ -6,6 +6,7 @@ const getProp = require('jsx-ast-utils/getProp'); const getLiteralPropValue = require('jsx-ast-utils/getLiteralPropValue'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Helpers @@ -27,7 +28,8 @@ module.exports = { docs: { description: 'Forbid "button" element without an explicit "type" attribute', category: 'Possible Errors', - recommended: false + recommended: false, + url: docsUrl('button-has-type') }, schema: [{ type: 'object', diff --git a/lib/rules/default-props-match-prop-types.js b/lib/rules/default-props-match-prop-types.js index 9f0bda4a78..9e0f994878 100644 --- a/lib/rules/default-props-match-prop-types.js +++ b/lib/rules/default-props-match-prop-types.js @@ -11,6 +11,7 @@ const variableUtil = require('../util/variable'); const annotations = require('../util/annotations'); const astUtil = require('../util/ast'); const propsUtil = require('../util/props'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -20,7 +21,8 @@ module.exports = { meta: { docs: { description: 'Enforce all defaultProps are defined and not "required" in propTypes.', - category: 'Best Practices' + category: 'Best Practices', + url: docsUrl('default-props-match-prop-types') }, schema: [{ diff --git a/lib/rules/destructuring-assignment.js b/lib/rules/destructuring-assignment.js index 2f6601a1a0..93bbaed704 100644 --- a/lib/rules/destructuring-assignment.js +++ b/lib/rules/destructuring-assignment.js @@ -4,6 +4,7 @@ 'use strict'; const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); const DEFAULT_OPTION = 'always'; @@ -12,7 +13,8 @@ module.exports = { docs: { description: 'Enforce consistent usage of destructuring assignment of props, state, and context', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('destructuring-assignment') }, schema: [{ type: 'string', diff --git a/lib/rules/display-name.js b/lib/rules/display-name.js index d3aca1f7cf..8fa67761cb 100644 --- a/lib/rules/display-name.js +++ b/lib/rules/display-name.js @@ -6,6 +6,7 @@ const has = require('has'); const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -16,7 +17,8 @@ module.exports = { docs: { description: 'Prevent missing displayName in a React component definition', category: 'Best Practices', - recommended: true + recommended: true, + url: docsUrl('display-name') }, schema: [{ diff --git a/lib/rules/forbid-component-props.js b/lib/rules/forbid-component-props.js index a5951e551a..9c0b072971 100644 --- a/lib/rules/forbid-component-props.js +++ b/lib/rules/forbid-component-props.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------------ @@ -19,7 +21,8 @@ module.exports = { docs: { description: 'Forbid certain props on components', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('forbid-component-props') }, schema: [{ diff --git a/lib/rules/forbid-dom-props.js b/lib/rules/forbid-dom-props.js index 324f6f27a0..1e3ac8668e 100644 --- a/lib/rules/forbid-dom-props.js +++ b/lib/rules/forbid-dom-props.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------------ @@ -19,7 +21,8 @@ module.exports = { docs: { description: 'Forbid certain props on DOM Nodes', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('forbid-dom-props') }, schema: [{ diff --git a/lib/rules/forbid-elements.js b/lib/rules/forbid-elements.js index 6651ecf952..482b27e864 100644 --- a/lib/rules/forbid-elements.js +++ b/lib/rules/forbid-elements.js @@ -5,6 +5,7 @@ 'use strict'; const has = require('has'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -15,7 +16,8 @@ module.exports = { docs: { description: 'Forbid certain elements', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('forbid-elements') }, schema: [{ diff --git a/lib/rules/forbid-foreign-prop-types.js b/lib/rules/forbid-foreign-prop-types.js index 18f2208ed9..0ea1e1bd64 100644 --- a/lib/rules/forbid-foreign-prop-types.js +++ b/lib/rules/forbid-foreign-prop-types.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------------ @@ -18,7 +20,8 @@ module.exports = { docs: { description: 'Forbid using another component\'s propTypes', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('forbid-foreign-prop-types') } }, diff --git a/lib/rules/forbid-prop-types.js b/lib/rules/forbid-prop-types.js index 11c275f021..afb171a348 100644 --- a/lib/rules/forbid-prop-types.js +++ b/lib/rules/forbid-prop-types.js @@ -6,6 +6,7 @@ const variableUtil = require('../util/variable'); const propsUtil = require('../util/props'); const astUtil = require('../util/ast'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Constants @@ -22,7 +23,8 @@ module.exports = { docs: { description: 'Forbid certain propTypes', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('forbid-prop-types') }, schema: [{ diff --git a/lib/rules/jsx-boolean-value.js b/lib/rules/jsx-boolean-value.js index ec1c757fbb..e56cac289f 100644 --- a/lib/rules/jsx-boolean-value.js +++ b/lib/rules/jsx-boolean-value.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -48,7 +50,8 @@ module.exports = { docs: { description: 'Enforce boolean attributes notation in JSX', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-boolean-value') }, fixable: 'code', diff --git a/lib/rules/jsx-closing-bracket-location.js b/lib/rules/jsx-closing-bracket-location.js index 356547b156..745d0df200 100644 --- a/lib/rules/jsx-closing-bracket-location.js +++ b/lib/rules/jsx-closing-bracket-location.js @@ -5,6 +5,7 @@ 'use strict'; const has = require('has'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -14,7 +15,8 @@ module.exports = { docs: { description: 'Validate closing bracket location in JSX', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-closing-bracket-location') }, fixable: 'code', diff --git a/lib/rules/jsx-closing-tag-location.js b/lib/rules/jsx-closing-tag-location.js index 5b0e85da02..81c1f77686 100644 --- a/lib/rules/jsx-closing-tag-location.js +++ b/lib/rules/jsx-closing-tag-location.js @@ -5,6 +5,7 @@ 'use strict'; const astUtil = require('../util/ast'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -14,7 +15,8 @@ module.exports = { docs: { description: 'Validate closing tag location for multiline JSX', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-closing-tag-location') }, fixable: 'whitespace' }, diff --git a/lib/rules/jsx-curly-brace-presence.js b/lib/rules/jsx-curly-brace-presence.js index ecb9576777..a4fecf4759 100644 --- a/lib/rules/jsx-curly-brace-presence.js +++ b/lib/rules/jsx-curly-brace-presence.js @@ -5,6 +5,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------------ @@ -31,7 +33,8 @@ module.exports = { 'Disallow unnecessary JSX expressions when literals alone are sufficient ' + 'or enfore JSX expressions on literals in JSX children or attributes', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-curly-brace-presence') }, fixable: 'code', diff --git a/lib/rules/jsx-curly-spacing.js b/lib/rules/jsx-curly-spacing.js index e67a229d40..d9db3c2fb3 100644 --- a/lib/rules/jsx-curly-spacing.js +++ b/lib/rules/jsx-curly-spacing.js @@ -11,6 +11,7 @@ 'use strict'; const has = require('has'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -27,7 +28,8 @@ module.exports = { docs: { description: 'Enforce or disallow spaces inside of curly braces in JSX attributes', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-curly-spacing') }, fixable: 'code', diff --git a/lib/rules/jsx-equals-spacing.js b/lib/rules/jsx-equals-spacing.js index 05bf95c7a4..2c927496e1 100644 --- a/lib/rules/jsx-equals-spacing.js +++ b/lib/rules/jsx-equals-spacing.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -13,7 +15,8 @@ module.exports = { docs: { description: 'Disallow or enforce spaces around equal signs in JSX attributes', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-equals-spacing') }, fixable: 'code', diff --git a/lib/rules/jsx-filename-extension.js b/lib/rules/jsx-filename-extension.js index 1aeadd309a..fecfa88e64 100644 --- a/lib/rules/jsx-filename-extension.js +++ b/lib/rules/jsx-filename-extension.js @@ -5,6 +5,7 @@ 'use strict'; const path = require('path'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Constants @@ -23,7 +24,8 @@ module.exports = { docs: { description: 'Restrict file extensions that may contain JSX', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-filename-extension') }, schema: [{ diff --git a/lib/rules/jsx-first-prop-new-line.js b/lib/rules/jsx-first-prop-new-line.js index 9d96b14c88..24d063b9bf 100644 --- a/lib/rules/jsx-first-prop-new-line.js +++ b/lib/rules/jsx-first-prop-new-line.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -13,7 +15,8 @@ module.exports = { docs: { description: 'Ensure proper position of the first property in JSX', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-first-prop-new-line') }, fixable: 'code', diff --git a/lib/rules/jsx-handler-names.js b/lib/rules/jsx-handler-names.js index 413949a5d9..29a2db3d3b 100644 --- a/lib/rules/jsx-handler-names.js +++ b/lib/rules/jsx-handler-names.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -13,7 +15,8 @@ module.exports = { docs: { description: 'Enforce event handler naming conventions in JSX', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-handler-names') }, schema: [{ diff --git a/lib/rules/jsx-indent-props.js b/lib/rules/jsx-indent-props.js index bfdaaed660..66d463dfc5 100644 --- a/lib/rules/jsx-indent-props.js +++ b/lib/rules/jsx-indent-props.js @@ -30,6 +30,7 @@ 'use strict'; const astUtil = require('../util/ast'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -39,7 +40,8 @@ module.exports = { docs: { description: 'Validate props indentation in JSX', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-indent-props') }, fixable: 'code', diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js index f668bd5e06..21ae3683be 100644 --- a/lib/rules/jsx-indent.js +++ b/lib/rules/jsx-indent.js @@ -30,6 +30,7 @@ 'use strict'; const astUtil = require('../util/ast'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -39,7 +40,8 @@ module.exports = { docs: { description: 'Validate JSX indentation', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-indent') }, fixable: 'whitespace', schema: [{ diff --git a/lib/rules/jsx-key.js b/lib/rules/jsx-key.js index ccc91a470e..4583531f38 100644 --- a/lib/rules/jsx-key.js +++ b/lib/rules/jsx-key.js @@ -4,8 +4,8 @@ */ 'use strict'; -// var Components = require('../util/Components'); const hasProp = require('jsx-ast-utils/hasProp'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ @@ -17,7 +17,8 @@ module.exports = { docs: { description: 'Report missing `key` props in iterators/collection literals', category: 'Possible Errors', - recommended: true + recommended: true, + url: docsUrl('jsx-key') }, schema: [] }, diff --git a/lib/rules/jsx-max-props-per-line.js b/lib/rules/jsx-max-props-per-line.js index 153d1eff88..2fa8d96423 100644 --- a/lib/rules/jsx-max-props-per-line.js +++ b/lib/rules/jsx-max-props-per-line.js @@ -5,6 +5,8 @@ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -14,7 +16,8 @@ module.exports = { docs: { description: 'Limit maximum of props on a single line in JSX', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-max-props-per-line') }, fixable: 'code', schema: [{ diff --git a/lib/rules/jsx-no-bind.js b/lib/rules/jsx-no-bind.js index f463f1c992..f16bb5ecde 100644 --- a/lib/rules/jsx-no-bind.js +++ b/lib/rules/jsx-no-bind.js @@ -6,8 +6,9 @@ */ 'use strict'; -const Components = require('../util/Components'); const propName = require('jsx-ast-utils/propName'); +const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); // ----------------------------------------------------------------------------- // Rule Definition @@ -25,7 +26,8 @@ module.exports = { docs: { description: 'Prevents usage of Function.prototype.bind and arrow functions in React component props', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('jsx-no-bind') }, schema: [{ diff --git a/lib/rules/jsx-no-comment-textnodes.js b/lib/rules/jsx-no-comment-textnodes.js index 1dc7b1b8cb..62da4e5b73 100644 --- a/lib/rules/jsx-no-comment-textnodes.js +++ b/lib/rules/jsx-no-comment-textnodes.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -13,7 +15,8 @@ module.exports = { docs: { description: 'Comments inside children section of tag should be placed inside braces', category: 'Possible Errors', - recommended: true + recommended: true, + url: docsUrl('jsx-no-comment-textnodes') }, schema: [{ diff --git a/lib/rules/jsx-no-duplicate-props.js b/lib/rules/jsx-no-duplicate-props.js index a57d236cae..7fc2c51db7 100644 --- a/lib/rules/jsx-no-duplicate-props.js +++ b/lib/rules/jsx-no-duplicate-props.js @@ -6,6 +6,7 @@ 'use strict'; const has = require('has'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -16,7 +17,8 @@ module.exports = { docs: { description: 'Enforce no duplicate props', category: 'Possible Errors', - recommended: true + recommended: true, + url: docsUrl('jsx-no-duplicate-props') }, schema: [{ diff --git a/lib/rules/jsx-no-literals.js b/lib/rules/jsx-no-literals.js index 797f5fc566..daec7eafeb 100644 --- a/lib/rules/jsx-no-literals.js +++ b/lib/rules/jsx-no-literals.js @@ -5,6 +5,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -14,7 +16,8 @@ module.exports = { docs: { description: 'Prevent using string literals in React component definition', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-no-literals') }, schema: [{ diff --git a/lib/rules/jsx-no-target-blank.js b/lib/rules/jsx-no-target-blank.js index ccba0e21a2..a5b34c2d19 100644 --- a/lib/rules/jsx-no-target-blank.js +++ b/lib/rules/jsx-no-target-blank.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -36,7 +38,8 @@ module.exports = { docs: { description: 'Forbid target="_blank" attribute without rel="noopener noreferrer"', category: 'Best Practices', - recommended: true + recommended: true, + url: docsUrl('jsx-no-target-blank') }, schema: [] }, diff --git a/lib/rules/jsx-no-undef.js b/lib/rules/jsx-no-undef.js index 5f84a9a137..c177bf3413 100644 --- a/lib/rules/jsx-no-undef.js +++ b/lib/rules/jsx-no-undef.js @@ -5,6 +5,8 @@ 'use strict'; +const docsUrl = require('../util/docsUrl'); + /** * Checks if a node name match the JSX tag convention. * @param {String} name - Name of the node to check. @@ -24,7 +26,8 @@ module.exports = { docs: { description: 'Disallow undeclared variables in JSX', category: 'Possible Errors', - recommended: true + recommended: true, + url: docsUrl('jsx-no-undef') }, schema: [{ type: 'object', diff --git a/lib/rules/jsx-one-expression-per-line.js b/lib/rules/jsx-one-expression-per-line.js index fa0a164af1..4e815c0013 100644 --- a/lib/rules/jsx-one-expression-per-line.js +++ b/lib/rules/jsx-one-expression-per-line.js @@ -5,6 +5,8 @@ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -14,7 +16,8 @@ module.exports = { docs: { description: 'Limit to one expression per line in JSX', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-one-expression-per-line') }, fixable: 'whitespace', schema: [] diff --git a/lib/rules/jsx-pascal-case.js b/lib/rules/jsx-pascal-case.js index 25589be96b..12d5fecf17 100644 --- a/lib/rules/jsx-pascal-case.js +++ b/lib/rules/jsx-pascal-case.js @@ -6,6 +6,7 @@ 'use strict'; const elementType = require('jsx-ast-utils/elementType'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Constants @@ -24,7 +25,8 @@ module.exports = { docs: { description: 'Enforce PascalCase for user-defined JSX components', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-pascal-case') }, schema: [{ diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index cb09747bb7..9b9435b49c 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -6,6 +6,7 @@ const elementType = require('jsx-ast-utils/elementType'); const propName = require('jsx-ast-utils/propName'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -168,7 +169,8 @@ module.exports = { docs: { description: 'Enforce props alphabetical sorting', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-sort-props') }, fixable: 'code', schema: [{ diff --git a/lib/rules/jsx-space-before-closing.js b/lib/rules/jsx-space-before-closing.js index 299fbfc4c8..4f76e98b55 100644 --- a/lib/rules/jsx-space-before-closing.js +++ b/lib/rules/jsx-space-before-closing.js @@ -6,6 +6,8 @@ 'use strict'; const getTokenBeforeClosingBracket = require('../util/getTokenBeforeClosingBracket'); +const docsUrl = require('../util/docsUrl'); + let isWarnedForDeprecation = false; // ------------------------------------------------------------------------------ @@ -18,7 +20,8 @@ module.exports = { docs: { description: 'Validate spacing before closing bracket in JSX', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-space-before-closing') }, fixable: 'code', diff --git a/lib/rules/jsx-tag-spacing.js b/lib/rules/jsx-tag-spacing.js index f61533863d..359044847e 100644 --- a/lib/rules/jsx-tag-spacing.js +++ b/lib/rules/jsx-tag-spacing.js @@ -6,6 +6,7 @@ const has = require('has'); const getTokenBeforeClosingBracket = require('../util/getTokenBeforeClosingBracket'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Validators @@ -174,7 +175,9 @@ function validateAfterOpening(context, node, option) { module.exports = { meta: { - docs: {}, + docs: { + url: docsUrl('jsx-tag-spacing') + }, fixable: 'whitespace', schema: [ { diff --git a/lib/rules/jsx-uses-react.js b/lib/rules/jsx-uses-react.js index e6b9c6b527..51ba2fc320 100644 --- a/lib/rules/jsx-uses-react.js +++ b/lib/rules/jsx-uses-react.js @@ -5,6 +5,7 @@ 'use strict'; const pragmaUtil = require('../util/pragma'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -15,7 +16,8 @@ module.exports = { docs: { description: 'Prevent React to be marked as unused', category: 'Best Practices', - recommended: true + recommended: true, + url: docsUrl('jsx-uses-react') }, schema: [] }, diff --git a/lib/rules/jsx-uses-vars.js b/lib/rules/jsx-uses-vars.js index 8040eb455c..8fb0967c37 100644 --- a/lib/rules/jsx-uses-vars.js +++ b/lib/rules/jsx-uses-vars.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -13,7 +15,8 @@ module.exports = { docs: { description: 'Prevent variables used in JSX to be marked as unused', category: 'Best Practices', - recommended: true + recommended: true, + url: docsUrl('jsx-uses-vars') }, schema: [] }, diff --git a/lib/rules/jsx-wrap-multilines.js b/lib/rules/jsx-wrap-multilines.js index a42741eeb0..ca9b980d62 100644 --- a/lib/rules/jsx-wrap-multilines.js +++ b/lib/rules/jsx-wrap-multilines.js @@ -5,6 +5,7 @@ 'use strict'; const has = require('has'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Constants @@ -32,7 +33,8 @@ module.exports = { docs: { description: 'Prevent missing parentheses around multilines JSX', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('jsx-wrap-multilines') }, fixable: 'code', diff --git a/lib/rules/no-access-state-in-setstate.js b/lib/rules/no-access-state-in-setstate.js index 5a8d2e36ea..9065250b13 100644 --- a/lib/rules/no-access-state-in-setstate.js +++ b/lib/rules/no-access-state-in-setstate.js @@ -5,6 +5,8 @@ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -14,7 +16,8 @@ module.exports = { docs: { description: 'Reports when this.state is accessed within setState', category: 'Possible Errors', - recommended: false + recommended: false, + url: docsUrl('no-access-state-in-setstate') } }, diff --git a/lib/rules/no-array-index-key.js b/lib/rules/no-array-index-key.js index 7652466afb..37e93b04dd 100644 --- a/lib/rules/no-array-index-key.js +++ b/lib/rules/no-array-index-key.js @@ -5,6 +5,7 @@ 'use strict'; const has = require('has'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -15,7 +16,8 @@ module.exports = { docs: { description: 'Prevent usage of Array index in keys', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('no-array-index-key') }, schema: [] diff --git a/lib/rules/no-children-prop.js b/lib/rules/no-children-prop.js index 492878d49a..f8e341dab7 100644 --- a/lib/rules/no-children-prop.js +++ b/lib/rules/no-children-prop.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Helpers // ------------------------------------------------------------------------------ @@ -31,7 +33,8 @@ module.exports = { docs: { description: 'Prevent passing of children as props.', category: 'Best Practices', - recommended: true + recommended: true, + url: docsUrl('no-children-prop') }, schema: [] }, diff --git a/lib/rules/no-danger-with-children.js b/lib/rules/no-danger-with-children.js index a2df00361c..b4f4551ce9 100644 --- a/lib/rules/no-danger-with-children.js +++ b/lib/rules/no-danger-with-children.js @@ -5,6 +5,7 @@ 'use strict'; const variableUtil = require('../util/variable'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -14,7 +15,8 @@ module.exports = { docs: { description: 'Report when a DOM element is using both children and dangerouslySetInnerHTML', category: '', - recommended: true + recommended: true, + url: docsUrl('no-danger-with-children') }, schema: [] // no options }, diff --git a/lib/rules/no-danger.js b/lib/rules/no-danger.js index ea36747d67..5d40d923f8 100644 --- a/lib/rules/no-danger.js +++ b/lib/rules/no-danger.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------------ @@ -51,7 +53,8 @@ module.exports = { docs: { description: 'Prevent usage of dangerous JSX props', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('no-danger') }, schema: [] }, diff --git a/lib/rules/no-deprecated.js b/lib/rules/no-deprecated.js index 73f1f6d29e..78ae1c8106 100644 --- a/lib/rules/no-deprecated.js +++ b/lib/rules/no-deprecated.js @@ -9,6 +9,7 @@ const has = require('has'); const pragmaUtil = require('../util/pragma'); const versionUtil = require('../util/version'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Constants @@ -30,7 +31,8 @@ module.exports = { docs: { description: 'Prevent usage of deprecated methods', category: 'Best Practices', - recommended: true + recommended: true, + url: docsUrl('no-deprecated') }, schema: [] }, diff --git a/lib/rules/no-direct-mutation-state.js b/lib/rules/no-direct-mutation-state.js index 40e877a19a..a4daed44ec 100644 --- a/lib/rules/no-direct-mutation-state.js +++ b/lib/rules/no-direct-mutation-state.js @@ -6,6 +6,7 @@ 'use strict'; const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -16,7 +17,8 @@ module.exports = { docs: { description: 'Prevent direct mutation of this.state', category: 'Possible Errors', - recommended: true + recommended: true, + url: docsUrl('no-direct-mutation-state') } }, diff --git a/lib/rules/no-find-dom-node.js b/lib/rules/no-find-dom-node.js index 10e1fbc21d..1beb30c84e 100644 --- a/lib/rules/no-find-dom-node.js +++ b/lib/rules/no-find-dom-node.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -13,7 +15,8 @@ module.exports = { docs: { description: 'Prevent usage of findDOMNode', category: 'Best Practices', - recommended: true + recommended: true, + url: docsUrl('no-find-dom-node') }, schema: [] }, diff --git a/lib/rules/no-is-mounted.js b/lib/rules/no-is-mounted.js index 2c9fcfb27b..23a9084d23 100644 --- a/lib/rules/no-is-mounted.js +++ b/lib/rules/no-is-mounted.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -13,7 +15,8 @@ module.exports = { docs: { description: 'Prevent usage of isMounted', category: 'Best Practices', - recommended: true + recommended: true, + url: docsUrl('no-is-mounted') }, schema: [] }, diff --git a/lib/rules/no-multi-comp.js b/lib/rules/no-multi-comp.js index 9674b058f0..4d6082d767 100644 --- a/lib/rules/no-multi-comp.js +++ b/lib/rules/no-multi-comp.js @@ -6,6 +6,7 @@ const has = require('has'); const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -16,7 +17,8 @@ module.exports = { docs: { description: 'Prevent multiple component definition per file', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('no-multi-comp') }, schema: [{ diff --git a/lib/rules/no-redundant-should-component-update.js b/lib/rules/no-redundant-should-component-update.js index 5f9e46ec62..de0b6e7fad 100644 --- a/lib/rules/no-redundant-should-component-update.js +++ b/lib/rules/no-redundant-should-component-update.js @@ -5,6 +5,7 @@ const Components = require('../util/Components'); const astUtil = require('../util/ast'); +const docsUrl = require('../util/docsUrl'); function errorMessage(node) { return `${node} does not need shouldComponentUpdate when extending React.PureComponent.`; @@ -19,7 +20,8 @@ module.exports = { docs: { description: 'Flag shouldComponentUpdate when extending PureComponent', category: 'Possible Errors', - recommended: false + recommended: false, + url: docsUrl('no-redundant-should-component-update') }, schema: [] }, diff --git a/lib/rules/no-render-return-value.js b/lib/rules/no-render-return-value.js index db38731026..e31552de73 100644 --- a/lib/rules/no-render-return-value.js +++ b/lib/rules/no-render-return-value.js @@ -5,6 +5,7 @@ 'use strict'; const versionUtil = require('../util/version'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -15,7 +16,8 @@ module.exports = { docs: { description: 'Prevent usage of the return value of React.render', category: 'Best Practices', - recommended: true + recommended: true, + url: docsUrl('no-render-return-value') }, schema: [] }, diff --git a/lib/rules/no-set-state.js b/lib/rules/no-set-state.js index d952912d2d..3b18b5c182 100644 --- a/lib/rules/no-set-state.js +++ b/lib/rules/no-set-state.js @@ -6,6 +6,7 @@ const has = require('has'); const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -16,7 +17,8 @@ module.exports = { docs: { description: 'Prevent usage of setState', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('no-set-state') }, schema: [] }, diff --git a/lib/rules/no-string-refs.js b/lib/rules/no-string-refs.js index 8ec5cccc5b..ef8195a7bb 100644 --- a/lib/rules/no-string-refs.js +++ b/lib/rules/no-string-refs.js @@ -5,6 +5,7 @@ 'use strict'; const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -15,7 +16,8 @@ module.exports = { docs: { description: 'Prevent string definitions for references and prevent referencing this.refs', category: 'Best Practices', - recommended: true + recommended: true, + url: docsUrl('no-string-refs') }, schema: [] }, diff --git a/lib/rules/no-this-in-sfc.js b/lib/rules/no-this-in-sfc.js index 443fbdcc52..3883a36d69 100644 --- a/lib/rules/no-this-in-sfc.js +++ b/lib/rules/no-this-in-sfc.js @@ -4,6 +4,7 @@ 'use strict'; const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Constants @@ -20,7 +21,8 @@ module.exports = { docs: { description: 'Report "this" being used in stateless components', category: 'Possible Errors', - recommended: false + recommended: false, + url: docsUrl('no-this-in-sfc') }, schema: [] }, diff --git a/lib/rules/no-typos.js b/lib/rules/no-typos.js index 5720503736..29c38b633c 100644 --- a/lib/rules/no-typos.js +++ b/lib/rules/no-typos.js @@ -4,6 +4,7 @@ 'use strict'; const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -28,7 +29,8 @@ module.exports = { docs: { description: 'Prevent common typos', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('no-typos') }, schema: [] }, diff --git a/lib/rules/no-unescaped-entities.js b/lib/rules/no-unescaped-entities.js index 2b04ffffc5..8e4ca1f445 100644 --- a/lib/rules/no-unescaped-entities.js +++ b/lib/rules/no-unescaped-entities.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -18,7 +20,8 @@ module.exports = { docs: { description: 'Detect unescaped HTML entities, which might represent malformed tags', category: 'Possible Errors', - recommended: true + recommended: true, + url: docsUrl('no-unescaped-entities') }, schema: [{ type: 'object', diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index d8191b3b03..e431587254 100644 --- a/lib/rules/no-unknown-property.js +++ b/lib/rules/no-unknown-property.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------------ @@ -176,7 +178,8 @@ module.exports = { docs: { description: 'Prevent usage of unknown DOM property', category: 'Possible Errors', - recommended: true + recommended: true, + url: docsUrl('no-unknown-property') }, fixable: 'code', diff --git a/lib/rules/no-unused-prop-types.js b/lib/rules/no-unused-prop-types.js index cfaa806074..687b129e5e 100644 --- a/lib/rules/no-unused-prop-types.js +++ b/lib/rules/no-unused-prop-types.js @@ -13,6 +13,7 @@ const variable = require('../util/variable'); const annotations = require('../util/annotations'); const versionUtil = require('../util/version'); const propsUtil = require('../util/props'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Constants @@ -32,7 +33,8 @@ module.exports = { docs: { description: 'Prevent definitions of unused prop types', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('no-unused-prop-types') }, schema: [{ diff --git a/lib/rules/no-unused-state.js b/lib/rules/no-unused-state.js index 421678fe88..f140491f0d 100644 --- a/lib/rules/no-unused-state.js +++ b/lib/rules/no-unused-state.js @@ -10,6 +10,7 @@ 'use strict'; const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); // Descend through all wrapping TypeCastExpressions and return the expression // that was cast. @@ -63,7 +64,8 @@ module.exports = { docs: { description: 'Prevent definition of unused state fields', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('no-unused-state') }, schema: [] }, diff --git a/lib/rules/prefer-es6-class.js b/lib/rules/prefer-es6-class.js index 6a23d91bf6..c5e510a27e 100644 --- a/lib/rules/prefer-es6-class.js +++ b/lib/rules/prefer-es6-class.js @@ -5,6 +5,7 @@ 'use strict'; const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -15,7 +16,8 @@ module.exports = { docs: { description: 'Enforce ES5 or ES6 class for React Components', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('prefer-es6-class') }, schema: [{ diff --git a/lib/rules/prefer-stateless-function.js b/lib/rules/prefer-stateless-function.js index b559a997b8..13f79193e5 100644 --- a/lib/rules/prefer-stateless-function.js +++ b/lib/rules/prefer-stateless-function.js @@ -10,6 +10,7 @@ const has = require('has'); const Components = require('../util/Components'); const versionUtil = require('../util/version'); const astUtil = require('../util/ast'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -20,7 +21,8 @@ module.exports = { docs: { description: 'Enforce stateless components to be written as a pure function', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('prefer-stateless-function') }, schema: [{ type: 'object', diff --git a/lib/rules/prop-types.js b/lib/rules/prop-types.js index 16d09d8e54..e6226d80dc 100644 --- a/lib/rules/prop-types.js +++ b/lib/rules/prop-types.js @@ -13,6 +13,7 @@ const variable = require('../util/variable'); const annotations = require('../util/annotations'); const versionUtil = require('../util/version'); const propsUtil = require('../util/props'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Constants @@ -30,7 +31,8 @@ module.exports = { docs: { description: 'Prevent missing props validation in a React component definition', category: 'Best Practices', - recommended: true + recommended: true, + url: docsUrl('prop-types') }, schema: [{ diff --git a/lib/rules/react-in-jsx-scope.js b/lib/rules/react-in-jsx-scope.js index 5dfa4c5a1f..492f9e3c4d 100644 --- a/lib/rules/react-in-jsx-scope.js +++ b/lib/rules/react-in-jsx-scope.js @@ -6,6 +6,7 @@ const variableUtil = require('../util/variable'); const pragmaUtil = require('../util/pragma'); +const docsUrl = require('../util/docsUrl'); // ----------------------------------------------------------------------------- // Rule Definition @@ -16,7 +17,8 @@ module.exports = { docs: { description: 'Prevent missing React when using JSX', category: 'Possible Errors', - recommended: true + recommended: true, + url: docsUrl('react-in-jsx-scope') }, schema: [] }, diff --git a/lib/rules/require-default-props.js b/lib/rules/require-default-props.js index 505b1be3fe..f787efb783 100644 --- a/lib/rules/require-default-props.js +++ b/lib/rules/require-default-props.js @@ -10,6 +10,7 @@ const variableUtil = require('../util/variable'); const annotations = require('../util/annotations'); const astUtil = require('../util/ast'); const propsUtil = require('../util/props'); +const docsUrl = require('../util/docsUrl'); const QUOTES_REGEX = /^["']|["']$/g; @@ -21,7 +22,8 @@ module.exports = { meta: { docs: { description: 'Enforce a defaultProps definition for every prop that is not a required prop.', - category: 'Best Practices' + category: 'Best Practices', + url: docsUrl('require-default-props') }, schema: [{ diff --git a/lib/rules/require-optimization.js b/lib/rules/require-optimization.js index b1b85db3bc..670c7fc2ed 100644 --- a/lib/rules/require-optimization.js +++ b/lib/rules/require-optimization.js @@ -6,13 +6,15 @@ const has = require('has'); const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); module.exports = { meta: { docs: { description: 'Enforce React components to have a shouldComponentUpdate method', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('require-optimization') }, schema: [{ diff --git a/lib/rules/require-render-return.js b/lib/rules/require-render-return.js index 7da2757355..356bb9a885 100644 --- a/lib/rules/require-render-return.js +++ b/lib/rules/require-render-return.js @@ -7,6 +7,7 @@ const has = require('has'); const Components = require('../util/Components'); const astUtil = require('../util/ast'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -17,7 +18,8 @@ module.exports = { docs: { description: 'Enforce ES5 or ES6 class for returning value in render function', category: 'Possible Errors', - recommended: true + recommended: true, + url: docsUrl('require-render-return') }, schema: [{}] }, diff --git a/lib/rules/self-closing-comp.js b/lib/rules/self-closing-comp.js index 94a64db77b..636469a403 100644 --- a/lib/rules/self-closing-comp.js +++ b/lib/rules/self-closing-comp.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('../util/docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -13,7 +15,8 @@ module.exports = { docs: { description: 'Prevent extra closing tags for components without children', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('self-closing-comp') }, fixable: 'code', diff --git a/lib/rules/sort-comp.js b/lib/rules/sort-comp.js index 171fb25010..e5e141fcb1 100644 --- a/lib/rules/sort-comp.js +++ b/lib/rules/sort-comp.js @@ -9,6 +9,7 @@ const util = require('util'); const Components = require('../util/Components'); const astUtil = require('../util/ast'); +const docsUrl = require('../util/docsUrl'); const defaultConfig = { order: [ @@ -76,7 +77,8 @@ module.exports = { docs: { description: 'Enforce component methods order', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('sort-comp') }, schema: [{ diff --git a/lib/rules/sort-prop-types.js b/lib/rules/sort-prop-types.js index 1e48b954aa..8ca7879623 100644 --- a/lib/rules/sort-prop-types.js +++ b/lib/rules/sort-prop-types.js @@ -5,6 +5,7 @@ const variableUtil = require('../util/variable'); const propsUtil = require('../util/props'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -15,7 +16,8 @@ module.exports = { docs: { description: 'Enforce propTypes declarations alphabetical sorting', category: 'Stylistic Issues', - recommended: false + recommended: false, + url: docsUrl('sort-prop-types') }, schema: [{ diff --git a/lib/rules/style-prop-object.js b/lib/rules/style-prop-object.js index 83a9f5a322..4a29d33d25 100644 --- a/lib/rules/style-prop-object.js +++ b/lib/rules/style-prop-object.js @@ -5,6 +5,7 @@ 'use strict'; const variableUtil = require('../util/variable'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Rule Definition @@ -15,7 +16,8 @@ module.exports = { docs: { description: 'Enforce style prop value is an object', category: '', - recommended: false + recommended: false, + url: docsUrl('style-prop-object') }, schema: [] }, diff --git a/lib/rules/void-dom-elements-no-children.js b/lib/rules/void-dom-elements-no-children.js index 95eac3d394..af3a7ca659 100644 --- a/lib/rules/void-dom-elements-no-children.js +++ b/lib/rules/void-dom-elements-no-children.js @@ -8,6 +8,7 @@ const has = require('has'); const Components = require('../util/Components'); +const docsUrl = require('../util/docsUrl'); // ------------------------------------------------------------------------------ // Helpers @@ -51,7 +52,8 @@ module.exports = { docs: { description: 'Prevent passing of children to void DOM elements (e.g.
).', category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl('void-dom-elements-no-children') }, schema: [] }, diff --git a/lib/util/docsUrl.js b/lib/util/docsUrl.js new file mode 100644 index 0000000000..f579409a0a --- /dev/null +++ b/lib/util/docsUrl.js @@ -0,0 +1,7 @@ +'use strict'; + +function docsUrl(ruleName) { + return `https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules/${ruleName}.md`; +} + +module.exports = docsUrl; diff --git a/lib/util/makeNoMethodSetStateRule.js b/lib/util/makeNoMethodSetStateRule.js index 361c8e27da..2b497581e9 100644 --- a/lib/util/makeNoMethodSetStateRule.js +++ b/lib/util/makeNoMethodSetStateRule.js @@ -4,6 +4,8 @@ */ 'use strict'; +const docsUrl = require('./docsUrl'); + // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ @@ -14,7 +16,8 @@ function makeNoMethodSetStateRule(methodName) { docs: { description: `Prevent usage of setState in ${methodName}`, category: 'Best Practices', - recommended: false + recommended: false, + url: docsUrl(methodName) }, schema: [{