Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare suggestable rules for ESLint v8 (and update eslint-plugin-eslint-plugin to v3) #1607

Merged
merged 1 commit into from Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 10 additions & 7 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/require-meta-type': 'error',
'require-meta-docs-url': [
'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-docs-url': [
'error',
{
pattern: `https://eslint.vuejs.org/rules/{{name}}.html`
}
],

'eslint-plugin/fixer-return': 'off'
'eslint-plugin/require-meta-has-suggestions': 'error',
'eslint-plugin/require-meta-schema': 'error',
'eslint-plugin/require-meta-type': 'error',
'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