Skip to content

Commit

Permalink
Add hasSuggestions property to meta-property-ordering rule
Browse files Browse the repository at this point in the history
It makes most sense to order the new ESLint 8 property `meta.hasSuggestions` after the related property `meta.fixable`.

https://eslint.org/blog/2021/06/whats-coming-in-eslint-8.0.0#rules-with-suggestions-now-require-the-metahassuggestions-property
  • Loading branch information
bmish committed Sep 24, 2021
1 parent 20235b6 commit 62716a4
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/rules/meta-property-ordering.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This rule enforces that meta properties of a rule are placed in a consistent ord

This rule has an array option:

* `['type', 'docs', 'fixable', 'schema', 'messages', 'deprecated', 'replacedBy']` (default): The order that the properties of `meta` should be placed in.
* `['type', 'docs', 'fixable', 'hasSuggestions', 'schema', 'messages', 'deprecated', 'replacedBy']` (default): The order that the properties of `meta` should be placed in.

Examples of **incorrect** code for this rule:

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/meta-property-ordering.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
const sourceCode = context.getSourceCode();
const info = getRuleInfo(sourceCode);

const order = context.options[0] || ['type', 'docs', 'fixable', 'schema', 'messages'];
const order = context.options[0] || ['type', 'docs', 'fixable', 'hasSuggestions', 'schema', 'messages'];

const orderMap = new Map(order.map((name, i) => [name, i]));

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-only-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ module.exports = {
category: 'Tests',
recommended: false,
},
hasSuggestions: true,
schema: [],
messages: {
foundOnly:
'The test case property `only` can be used during development, but should not be checked-in, since it prevents all the tests from running.',
removeOnly: 'Remove `only`.',
},
hasSuggestions: true,
},

create (context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/require-meta-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
category: 'Rules',
recommended: false, // TODO: enable it in a major release.
},
hasSuggestions: true,
schema: [
{
type: 'object',
Expand All @@ -33,7 +34,6 @@ module.exports = {
missing: '`meta.schema` is required (use [] if rule has no schema).',
wrongType: '`meta.schema` should be an array or object (use [] if rule has no schema).',
},
hasSuggestions: true,
},

create (context) {
Expand Down
1 change: 1 addition & 0 deletions tests/lib/rules/meta-property-ordering.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ruleTester.run('test-case-property-ordering', rule, {
type: 'problem',
docs: {},
fixable: 'code',
hasSuggestions: true,
schema: [],
messages: {}
},
Expand Down

0 comments on commit 62716a4

Please sign in to comment.