Skip to content

Commit

Permalink
Add URL to rule documentation to the metadata
Browse files Browse the repository at this point in the history
ESLint v4.15.0 added an official location for rules to store a URL to
their documentation in the rule metadata in eslint/eslint#9788. This
adds the URL to all the existing rules so anything consuming them can
know where their documentation is without having to resort to external
packages to guess.
  • Loading branch information
Arcanemagus authored and ganimomer committed Jan 9, 2018
1 parent 4858fda commit 69e7386
Show file tree
Hide file tree
Showing 39 changed files with 191 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/rules/callback-binding.js
Expand Up @@ -11,6 +11,12 @@
// ------------------------------------------------------------------------------

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/callback-binding.md'
}
},

create(context) {
const {getLodashMethodVisitors} = require('../util/lodashUtil')
const {getFunctionMaxArity} = require('../util/methodDataUtil')
Expand Down
5 changes: 4 additions & 1 deletion src/rules/chain-style.js
Expand Up @@ -11,6 +11,9 @@
//------------------------------------------------------------------------------
module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/chain-style.md'
},
schema: [{
enum: ['as-needed', 'implicit', 'explicit']
}]
Expand Down Expand Up @@ -53,4 +56,4 @@ module.exports = {
visitors.CallExpression = callExpressionVisitors[context.options[0] || 'as-needed']
return visitors
}
}
}
3 changes: 3 additions & 0 deletions src/rules/chaining.js
Expand Up @@ -12,6 +12,9 @@

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/chaining.md'
},
schema: [{
enum: ['always', 'never']
}, {
Expand Down
6 changes: 6 additions & 0 deletions src/rules/collection-method-value.js
Expand Up @@ -10,6 +10,12 @@
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/collection-method-value.md'
}
},

create(context) {
const {isChainBreaker, getLodashMethodVisitors, isCallToMethod} = require('../util/lodashUtil')
const {getMethodName} = require('../util/astUtil')
Expand Down
6 changes: 6 additions & 0 deletions src/rules/collection-return.js
Expand Up @@ -11,6 +11,12 @@
//------------------------------------------------------------------------------

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/collection-return.md'
}
},

create(context) {
const {getLodashMethodCallExpVisitor, getLodashContext} = require('../util/lodashUtil')
const {isCollectionMethod} = require('../util/methodDataUtil')
Expand Down
5 changes: 4 additions & 1 deletion src/rules/consistent-compose.js
Expand Up @@ -10,6 +10,9 @@ const possibleDirections = ['pipe', 'compose', 'flow', 'flowRight']

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/consistent-compose.md'
},
schema: [{
enum: possibleDirections
}]
Expand Down Expand Up @@ -37,4 +40,4 @@ module.exports = {
}
})
}
}
}
3 changes: 3 additions & 0 deletions src/rules/identity-shorthand.js
Expand Up @@ -13,6 +13,9 @@

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/identity-shorthand.md'
},
schema: [{
enum: ['always', 'never']
}]
Expand Down
4 changes: 4 additions & 0 deletions src/rules/import-scope.js
Expand Up @@ -34,10 +34,14 @@ const allImportsAreOfType = (node, types) => every(node.specifiers, specifier =>

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/import-scope.md'
},
schema: [{
enum: ['method', 'member', 'full', 'method-package']
}]
},

create(context) {
const importType = context.options[0] || 'method'

Expand Down
3 changes: 3 additions & 0 deletions src/rules/matches-prop-shorthand.js
Expand Up @@ -11,6 +11,9 @@
// ------------------------------------------------------------------------------
module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/matches-prop-shorthand.md'
},
schema: [{
enum: ['always', 'never']
}, {
Expand Down
3 changes: 3 additions & 0 deletions src/rules/matches-shorthand.js
Expand Up @@ -12,6 +12,9 @@

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/matches-shorthand.md'
},
schema: [{
enum: ['always', 'never']
}, {
Expand Down
6 changes: 6 additions & 0 deletions src/rules/no-commit.js
Expand Up @@ -11,6 +11,12 @@
//------------------------------------------------------------------------------

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/no-commit.md'
}
},

create(context) {
const {getLodashContext, isCallToMethod} = require('../util/lodashUtil')
const {isMethodCall} = require('../util/astUtil')
Expand Down
4 changes: 4 additions & 0 deletions src/rules/no-double-unwrap.js
Expand Up @@ -12,8 +12,12 @@

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/no-double-unwrap.md'
},
fixable: "code"
},

create(context) {
const {getLodashContext, isChainBreaker, isChainable} = require('../util/lodashUtil')
const {isMethodCall, getCaller, getMethodName} = require('../util/astUtil')
Expand Down
6 changes: 6 additions & 0 deletions src/rules/no-extra-args.js
Expand Up @@ -11,6 +11,12 @@
//------------------------------------------------------------------------------

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/no-extra-args.md'
}
},

create(context) {
const {version} = require('../util/settingsUtil').getSettings(context)
const {getLodashMethodVisitors} = require('../util/lodashUtil')
Expand Down
6 changes: 6 additions & 0 deletions src/rules/no-unbound-this.js
Expand Up @@ -7,6 +7,12 @@
//------------------------------------------------------------------------------

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/no-unbound-this.md'
}
},

create(context) {
const {getLodashMethodCallExpVisitor, getLodashContext} = require('../util/lodashUtil')
const {isCollectionMethod} = require('../util/methodDataUtil')
Expand Down
5 changes: 4 additions & 1 deletion src/rules/path-style.js
Expand Up @@ -12,6 +12,9 @@

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/path-style.md'
},
schema: [{
enum: ['as-needed', 'array', 'string']
}]
Expand Down Expand Up @@ -110,4 +113,4 @@ module.exports = {
}
})
}
}
}
6 changes: 6 additions & 0 deletions src/rules/prefer-compact.js
Expand Up @@ -11,6 +11,12 @@
//------------------------------------------------------------------------------

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-compact.md'
}
},

create(context) {
const {getLodashMethodVisitors} = require('../util/lodashUtil')
const {isNegationExpression, isIdentifierWithName, getValueReturnedInFirstStatement, getFirstParamName} = require('../util/astUtil')
Expand Down
4 changes: 4 additions & 0 deletions src/rules/prefer-constant.js
Expand Up @@ -12,6 +12,10 @@

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-constant.md'
},

schema: [{
type: 'boolean'
}, {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/prefer-filter.js
Expand Up @@ -12,6 +12,9 @@

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-filter.md'
},
schema: [{
type: 'integer'
}]
Expand Down Expand Up @@ -54,4 +57,4 @@ module.exports = {
}
})
}
}
}
8 changes: 7 additions & 1 deletion src/rules/prefer-flat-map.js
Expand Up @@ -11,6 +11,12 @@
//------------------------------------------------------------------------------

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-flat-map.md'
}
},

create(context) {
const {getLodashMethodVisitors, isCallToMethod, isCallToLodashMethod} = require('../util/lodashUtil')
const {getCaller} = require('../util/astUtil')
Expand All @@ -28,4 +34,4 @@ module.exports = {
}
})
}
}
}
5 changes: 4 additions & 1 deletion src/rules/prefer-get.js
Expand Up @@ -12,6 +12,9 @@

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-get.md'
},
schema: [{
type: 'integer',
minimum: 2
Expand Down Expand Up @@ -52,4 +55,4 @@ module.exports = {
}
}
}
}
}
5 changes: 4 additions & 1 deletion src/rules/prefer-includes.js
Expand Up @@ -12,6 +12,9 @@

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-includes.md'
},
schema: [{
type: 'object',
properties: {
Expand Down Expand Up @@ -42,4 +45,4 @@ module.exports = {
}
return visitors
}
}
}
6 changes: 4 additions & 2 deletions src/rules/prefer-invoke-map.js
Expand Up @@ -9,7 +9,9 @@

module.exports = {
meta: {
docs: {}
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-invoke-map.md'
}
},

create(context) {
Expand All @@ -33,4 +35,4 @@ module.exports = {
}
})
}
}
}
6 changes: 6 additions & 0 deletions src/rules/prefer-is-nil.js
Expand Up @@ -11,6 +11,12 @@
//------------------------------------------------------------------------------

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-is-nil.md'
}
},

create(context) {
const {isNegationExpression, isEquivalentMemberExp} = require('../util/astUtil')
const {isCallToLodashMethod, getLodashContext} = require('../util/lodashUtil')
Expand Down
6 changes: 6 additions & 0 deletions src/rules/prefer-lodash-chain.js
Expand Up @@ -11,6 +11,12 @@
//------------------------------------------------------------------------------

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-lodash-chain.md'
}
},

create(context) {
const {getLodashContext, isChainBreaker, isNativeCollectionMethodCall, isLodashWrapperMethod} = require('../util/lodashUtil')
const {isMethodCall, isObjectOfMethodCall, getMethodName} = require('../util/astUtil')
Expand Down
3 changes: 3 additions & 0 deletions src/rules/prefer-lodash-method.js
Expand Up @@ -9,6 +9,9 @@

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-lodash-method.md'
},
schema: [{
type: 'object',
properties: {
Expand Down
6 changes: 6 additions & 0 deletions src/rules/prefer-lodash-typecheck.js
Expand Up @@ -11,6 +11,12 @@
//------------------------------------------------------------------------------

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-lodash-typecheck.md'
}
},

create(context) {
const some = require('lodash/some')
const {getIsTypeMethod} = require('../util/lodashUtil')
Expand Down
6 changes: 6 additions & 0 deletions src/rules/prefer-map.js
Expand Up @@ -11,6 +11,12 @@
//------------------------------------------------------------------------------

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-map.md'
}
},

create(context) {
const {getLodashMethodVisitors} = require('../util/lodashUtil')
const {getFirstFunctionLine, hasOnlyOneStatement, getMethodName, isFunctionDefinitionWithBlock, collectParameterValues} = require('../util/astUtil')
Expand Down
5 changes: 4 additions & 1 deletion src/rules/prefer-matches.js
Expand Up @@ -12,6 +12,9 @@

module.exports = {
meta: {
docs: {
url: 'https://github.com/wix/eslint-plugin-lodash/tree/master/docs/rules/prefer-matches.md'
},
schema: [{
type: 'integer',
minimum: 2
Expand Down Expand Up @@ -56,4 +59,4 @@ module.exports = {
}
}
}
}
}

0 comments on commit 69e7386

Please sign in to comment.