Skip to content

Commit 1fc3485

Browse files
authored
fix: prepare suggestable rules for ESLint v8 (and update eslint-plugin-eslint-plugin to v3) (#1607)
* 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 * 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)
1 parent f6a1475 commit 1fc3485

19 files changed

+25
-507
lines changed

.eslintrc.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,21 @@ module.exports = {
126126
{
127127
files: ['lib/rules/*.js'],
128128
rules: {
129-
'consistent-docs-description': 'error',
130-
'no-invalid-meta': 'error',
131-
'no-invalid-meta-docs-categories': 'error',
132-
'eslint-plugin/require-meta-type': 'error',
133-
'require-meta-docs-url': [
129+
'eslint-plugin/no-deprecated-context-methods': 'error',
130+
'eslint-plugin/no-only-tests': 'error',
131+
'eslint-plugin/prefer-object-rule': 'error',
132+
'eslint-plugin/require-meta-docs-description': 'error',
133+
'eslint-plugin/require-meta-docs-url': [
134134
'error',
135135
{
136136
pattern: `https://eslint.vuejs.org/rules/{{name}}.html`
137137
}
138138
],
139-
140-
'eslint-plugin/fixer-return': 'off'
139+
'eslint-plugin/require-meta-has-suggestions': 'error',
140+
'eslint-plugin/require-meta-schema': 'error',
141+
'eslint-plugin/require-meta-type': 'error',
142+
'no-invalid-meta': 'error',
143+
'no-invalid-meta-docs-categories': 'error'
141144
}
142145
}
143146
]

eslint-internal-rules/.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"rules": {
3-
"consistent-docs-description": "error",
3+
"no-invalid-meta-docs-categories": "error",
44
"no-invalid-meta": "error"
55
}
66
}

eslint-internal-rules/consistent-docs-description.js

Lines changed: 0 additions & 141 deletions
This file was deleted.

eslint-internal-rules/no-invalid-meta-docs-categories.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,6 @@ function checkMetaValidity(context, exportsNode) {
108108
}
109109
}
110110

111-
/**
112-
* Whether this node is the correct format for a rule definition or not.
113-
*
114-
* @param {ASTNode} node node that the rule exports.
115-
* @returns {boolean} `true` if the exported node is the correct format for a rule definition
116-
*/
117-
function isCorrectExportsFormat(node) {
118-
return node != null && node.type === 'ObjectExpression'
119-
}
120-
121111
// ------------------------------------------------------------------------------
122112
// Rule Definition
123113
// ------------------------------------------------------------------------------
@@ -149,15 +139,6 @@ module.exports = {
149139
},
150140

151141
'Program:exit'(programNode) {
152-
if (!isCorrectExportsFormat(exportsNode)) {
153-
context.report({
154-
node: exportsNode || programNode,
155-
message:
156-
'Rule does not export an Object. Make sure the rule follows the new rule format.'
157-
})
158-
return
159-
}
160-
161142
checkMetaValidity(context, exportsNode)
162143
}
163144
}

eslint-internal-rules/no-invalid-meta.js

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,6 @@ function hasMetaDocs(metaPropertyNode) {
4949
return Boolean(getPropertyFromObject('docs', metaPropertyNode.value))
5050
}
5151

52-
/**
53-
* Whether this `meta` ObjectExpression has a `docs.description` property defined or not.
54-
*
55-
* @param {ASTNode} metaPropertyNode The `meta` ObjectExpression for this rule.
56-
* @returns {boolean} `true` if a `docs.description` property exists.
57-
*/
58-
function hasMetaDocsDescription(metaPropertyNode) {
59-
const metaDocs = getPropertyFromObject('docs', metaPropertyNode.value)
60-
61-
return metaDocs && getPropertyFromObject('description', metaDocs.value)
62-
}
63-
6452
/**
6553
* Whether this `meta` ObjectExpression has a `docs.category` property defined or not.
6654
*
@@ -73,16 +61,6 @@ function hasMetaDocsCategories(metaPropertyNode) {
7361
return metaDocs && getPropertyFromObject('categories', metaDocs.value)
7462
}
7563

76-
/**
77-
* Whether this `meta` ObjectExpression has a `schema` property defined or not.
78-
*
79-
* @param {ASTNode} metaPropertyNode The `meta` ObjectExpression for this rule.
80-
* @returns {boolean} `true` if a `schema` property exists.
81-
*/
82-
function hasMetaSchema(metaPropertyNode) {
83-
return getPropertyFromObject('schema', metaPropertyNode.value)
84-
}
85-
8664
/**
8765
* Checks the validity of the meta definition of this rule and reports any errors found.
8866
*
@@ -104,35 +82,13 @@ function checkMetaValidity(context, exportsNode) {
10482
return
10583
}
10684

107-
if (!hasMetaDocsDescription(metaProperty)) {
108-
context.report(
109-
metaProperty,
110-
'Rule is missing a meta.docs.description property.'
111-
)
112-
return
113-
}
114-
11585
if (!hasMetaDocsCategories(metaProperty)) {
11686
context.report(
11787
metaProperty,
11888
'Rule is missing a meta.docs.categories property.'
11989
)
12090
return
12191
}
122-
123-
if (!hasMetaSchema(metaProperty)) {
124-
context.report(metaProperty, 'Rule is missing a meta.schema property.')
125-
}
126-
}
127-
128-
/**
129-
* Whether this node is the correct format for a rule definition or not.
130-
*
131-
* @param {ASTNode} node node that the rule exports.
132-
* @returns {boolean} `true` if the exported node is the correct format for a rule definition
133-
*/
134-
function isCorrectExportsFormat(node) {
135-
return node != null && node.type === 'ObjectExpression'
13692
}
13793

13894
// ------------------------------------------------------------------------------
@@ -166,15 +122,6 @@ module.exports = {
166122
},
167123

168124
'Program:exit'(programNode) {
169-
if (!isCorrectExportsFormat(exportsNode)) {
170-
context.report({
171-
node: exportsNode || programNode,
172-
message:
173-
'Rule does not export an Object. Make sure the rule follows the new rule format.'
174-
})
175-
return
176-
}
177-
178125
checkMetaValidity(context, exportsNode)
179126
}
180127
}

0 commit comments

Comments
 (0)