Skip to content

Commit

Permalink
chore: update eslint-plugin-eslint-plugin to v3 and prepare suggestab…
Browse files Browse the repository at this point in the history
…le rules for ESLint v8

* A lot of the rules/functionality in `eslint-internal-rules` have been replaced by public rules in [eslint-plugin-eslint-plugin](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin)
* The upcoming [ESLint v8](https://eslint.org/blog/2021/06/whats-coming-in-eslint-8.0.0#rules-with-suggestions-now-require-the-metahassuggestions-property) release will require rules that provide suggestions to enable `meta.hasSuggestions` so I have autofixed that using the [eslint-plugin/require-meta-has-suggestions](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-has-suggestions.md) rule
  • Loading branch information
bmish committed Aug 13, 2021
1 parent f6a1475 commit 1271d99
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 506 deletions.
15 changes: 9 additions & 6 deletions .eslintrc.js
Expand Up @@ -126,18 +126,21 @@ module.exports = {
{
files: ['lib/rules/*.js'],
rules: {
'consistent-docs-description': 'error',
'no-invalid-meta': 'error',
'no-invalid-meta-docs-categories': 'error',
'eslint-plugin/no-deprecated-context-methods': 'error',
'eslint-plugin/no-only-tests': 'error',
'eslint-plugin/prefer-object-rule': 'error',
'eslint-plugin/require-meta-docs-description': 'error',
'eslint-plugin/require-meta-has-suggestions': 'error',
'eslint-plugin/require-meta-schema': 'error',
'eslint-plugin/require-meta-type': 'error',
'require-meta-docs-url': [
'eslint-plugin/require-meta-docs-url': [
'error',
{
pattern: `https://eslint.vuejs.org/rules/{{name}}.html`
}
],

'eslint-plugin/fixer-return': 'off'
'no-invalid-meta': 'error',
'no-invalid-meta-docs-categories': 'error'
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion eslint-internal-rules/.eslintrc.json
@@ -1,6 +1,6 @@
{
"rules": {
"consistent-docs-description": "error",
"no-invalid-meta-docs-categories": "error",
"no-invalid-meta": "error"
}
}
141 changes: 0 additions & 141 deletions eslint-internal-rules/consistent-docs-description.js

This file was deleted.

19 changes: 0 additions & 19 deletions eslint-internal-rules/no-invalid-meta-docs-categories.js
Expand Up @@ -108,16 +108,6 @@ function checkMetaValidity(context, exportsNode) {
}
}

/**
* Whether this node is the correct format for a rule definition or not.
*
* @param {ASTNode} node node that the rule exports.
* @returns {boolean} `true` if the exported node is the correct format for a rule definition
*/
function isCorrectExportsFormat(node) {
return node != null && node.type === 'ObjectExpression'
}

// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------
Expand Down Expand Up @@ -149,15 +139,6 @@ module.exports = {
},

'Program:exit'(programNode) {
if (!isCorrectExportsFormat(exportsNode)) {
context.report({
node: exportsNode || programNode,
message:
'Rule does not export an Object. Make sure the rule follows the new rule format.'
})
return
}

checkMetaValidity(context, exportsNode)
}
}
Expand Down
53 changes: 0 additions & 53 deletions eslint-internal-rules/no-invalid-meta.js
Expand Up @@ -49,18 +49,6 @@ function hasMetaDocs(metaPropertyNode) {
return Boolean(getPropertyFromObject('docs', metaPropertyNode.value))
}

/**
* Whether this `meta` ObjectExpression has a `docs.description` property defined or not.
*
* @param {ASTNode} metaPropertyNode The `meta` ObjectExpression for this rule.
* @returns {boolean} `true` if a `docs.description` property exists.
*/
function hasMetaDocsDescription(metaPropertyNode) {
const metaDocs = getPropertyFromObject('docs', metaPropertyNode.value)

return metaDocs && getPropertyFromObject('description', metaDocs.value)
}

/**
* Whether this `meta` ObjectExpression has a `docs.category` property defined or not.
*
Expand All @@ -73,16 +61,6 @@ function hasMetaDocsCategories(metaPropertyNode) {
return metaDocs && getPropertyFromObject('categories', metaDocs.value)
}

/**
* Whether this `meta` ObjectExpression has a `schema` property defined or not.
*
* @param {ASTNode} metaPropertyNode The `meta` ObjectExpression for this rule.
* @returns {boolean} `true` if a `schema` property exists.
*/
function hasMetaSchema(metaPropertyNode) {
return getPropertyFromObject('schema', metaPropertyNode.value)
}

/**
* Checks the validity of the meta definition of this rule and reports any errors found.
*
Expand All @@ -104,35 +82,13 @@ function checkMetaValidity(context, exportsNode) {
return
}

if (!hasMetaDocsDescription(metaProperty)) {
context.report(
metaProperty,
'Rule is missing a meta.docs.description property.'
)
return
}

if (!hasMetaDocsCategories(metaProperty)) {
context.report(
metaProperty,
'Rule is missing a meta.docs.categories property.'
)
return
}

if (!hasMetaSchema(metaProperty)) {
context.report(metaProperty, 'Rule is missing a meta.schema property.')
}
}

/**
* Whether this node is the correct format for a rule definition or not.
*
* @param {ASTNode} node node that the rule exports.
* @returns {boolean} `true` if the exported node is the correct format for a rule definition
*/
function isCorrectExportsFormat(node) {
return node != null && node.type === 'ObjectExpression'
}

// ------------------------------------------------------------------------------
Expand Down Expand Up @@ -166,15 +122,6 @@ module.exports = {
},

'Program:exit'(programNode) {
if (!isCorrectExportsFormat(exportsNode)) {
context.report({
node: exportsNode || programNode,
message:
'Rule does not export an Object. Make sure the rule follows the new rule format.'
})
return
}

checkMetaValidity(context, exportsNode)
}
}
Expand Down

0 comments on commit 1271d99

Please sign in to comment.