Skip to content

Commit d85c446

Browse files
authored
Breaking: Add hasSuggestions property to meta-property-ordering rule (#119)
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
1 parent 4fa5172 commit d85c446

File tree

5 files changed

+5
-4
lines changed

5 files changed

+5
-4
lines changed

docs/rules/meta-property-ordering.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This rule enforces that meta properties of a rule are placed in a consistent ord
1010

1111
This rule has an array option:
1212

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

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

lib/rules/meta-property-ordering.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = {
3232
const sourceCode = context.getSourceCode();
3333
const info = getRuleInfo(sourceCode);
3434

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

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

lib/rules/no-only-tests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ module.exports = {
1111
category: 'Tests',
1212
recommended: false,
1313
},
14+
hasSuggestions: true,
1415
schema: [],
1516
messages: {
1617
foundOnly:
1718
'The test case property `only` can be used during development, but should not be checked-in, since it prevents all the tests from running.',
1819
removeOnly: 'Remove `only`.',
1920
},
20-
hasSuggestions: true,
2121
},
2222

2323
create (context) {

lib/rules/require-meta-schema.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = {
1515
category: 'Rules',
1616
recommended: false, // TODO: enable it in a major release.
1717
},
18+
hasSuggestions: true,
1819
schema: [
1920
{
2021
type: 'object',
@@ -33,7 +34,6 @@ module.exports = {
3334
missing: '`meta.schema` is required (use [] if rule has no schema).',
3435
wrongType: '`meta.schema` should be an array or object (use [] if rule has no schema).',
3536
},
36-
hasSuggestions: true,
3737
},
3838

3939
create (context) {

tests/lib/rules/meta-property-ordering.js

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ ruleTester.run('test-case-property-ordering', rule, {
5252
type: 'problem',
5353
docs: {},
5454
fixable: 'code',
55+
hasSuggestions: true,
5556
schema: [],
5657
messages: {}
5758
},

0 commit comments

Comments
 (0)