Skip to content

Commit d693820

Browse files
Dimitri POSTOLOVdimitri
andauthored
fix eslint options in generate-docs.ts (#411)
Co-authored-by: dimitri <[email protected]>
1 parent fae5588 commit d693820

8 files changed

+20
-19
lines changed

docs/rules/avoid-operation-name-prefix.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Enforce/avoid operation name prefix, useful if you wish to avoid prefix in your
1212
### Incorrect
1313

1414
```graphql
15-
# eslint @graphql-eslint/avoid-operation-name-prefix: ["error", [{"keywords":["get"]}]]
15+
# eslint @graphql-eslint/avoid-operation-name-prefix: ["error", {"keywords":["get"]}]
1616

1717
query getUserDetails {
1818
# ...
@@ -22,7 +22,7 @@ query getUserDetails {
2222
### Correct
2323

2424
```graphql
25-
# eslint @graphql-eslint/avoid-operation-name-prefix: ["error", [{"keywords":["get"]}]]
25+
# eslint @graphql-eslint/avoid-operation-name-prefix: ["error", {"keywords":["get"]}]
2626

2727
query userDetails {
2828
# ...

docs/rules/description-style.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Require all comments to follow the same style (either block or inline)
1212
### Incorrect
1313

1414
```graphql
15-
# eslint @graphql-eslint/description-style: ["error", [{"style":"inline"}]]
15+
# eslint @graphql-eslint/description-style: ["error", {"style":"inline"}]
1616

1717
""" Description """
1818
type someTypeName {
@@ -23,7 +23,7 @@ type someTypeName {
2323
### Correct
2424

2525
```graphql
26-
# eslint @graphql-eslint/description-style: ["error", [{"style":"inline"}]]
26+
# eslint @graphql-eslint/description-style: ["error", {"style":"inline"}]
2727

2828
" Description "
2929
type someTypeName {

docs/rules/input-name.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Using the same name for all input parameters will make your schemas easier to co
1313
### Incorrect
1414

1515
```graphql
16-
# eslint @graphql-eslint/input-name: ["error", [{"checkInputType":true}]]
16+
# eslint @graphql-eslint/input-name: ["error", {"checkInputType":true}]
1717

1818
type Mutation {
1919
SetMessage(message: InputMessage): String
@@ -23,7 +23,7 @@ type Mutation {
2323
### Correct (with checkInputType)
2424

2525
```graphql
26-
# eslint @graphql-eslint/input-name: ["error", [{"checkInputType":true}]]
26+
# eslint @graphql-eslint/input-name: ["error", {"checkInputType":true}]
2727

2828
type Mutation {
2929
SetMessage(input: SetMessageInput): String
@@ -33,7 +33,7 @@ type Mutation {
3333
### Correct (without checkInputType)
3434

3535
```graphql
36-
# eslint @graphql-eslint/input-name: ["error", [{"checkInputType":false}]]
36+
# eslint @graphql-eslint/input-name: ["error", {"checkInputType":false}]
3737

3838
type Mutation {
3939
SetMessage(input: AnyInputTypeName): String

docs/rules/naming-convention.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Require names to follow specified conventions.
1212
### Incorrect
1313

1414
```graphql
15-
# eslint @graphql-eslint/naming-convention: ["error", [{"ObjectTypeDefinition":"PascalCase"}]]
15+
# eslint @graphql-eslint/naming-convention: ["error", {"ObjectTypeDefinition":"PascalCase"}]
1616

1717
type someTypeName {
1818
f: String!
@@ -22,7 +22,7 @@ type someTypeName {
2222
### Correct
2323

2424
```graphql
25-
# eslint @graphql-eslint/naming-convention: ["error", [{"FieldDefinition":"camelCase","ObjectTypeDefinition":"PascalCase"}]]
25+
# eslint @graphql-eslint/naming-convention: ["error", {"FieldDefinition":"camelCase","ObjectTypeDefinition":"PascalCase"}]
2626

2727
type SomeTypeName {
2828
someFieldName: String

docs/rules/require-description.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Enforce descriptions in your type definitions
1212
### Incorrect
1313

1414
```graphql
15-
# eslint @graphql-eslint/require-description: ["error", [{"on":["ObjectTypeDefinition","FieldDefinition"]}]]
15+
# eslint @graphql-eslint/require-description: ["error", {"on":["ObjectTypeDefinition","FieldDefinition"]}]
1616

1717
type someTypeName {
1818
name: String
@@ -22,7 +22,7 @@ type someTypeName {
2222
### Correct
2323

2424
```graphql
25-
# eslint @graphql-eslint/require-description: ["error", [{"on":["ObjectTypeDefinition","FieldDefinition"]}]]
25+
# eslint @graphql-eslint/require-description: ["error", {"on":["ObjectTypeDefinition","FieldDefinition"]}]
2626

2727
"""
2828
Some type description

docs/rules/selection-set-depth.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Limit the complexity of the GraphQL operations solely by their depth. Based on h
1212
### Incorrect
1313

1414
```graphql
15-
# eslint @graphql-eslint/selection-set-depth: ["error", [{"maxDepth":1}]]
15+
# eslint @graphql-eslint/selection-set-depth: ["error", {"maxDepth":1}]
1616

1717
query deep2 {
1818
viewer { # Level 0
@@ -26,7 +26,7 @@ query deep2 {
2626
### Correct
2727

2828
```graphql
29-
# eslint @graphql-eslint/selection-set-depth: ["error", [{"maxDepth":4}]]
29+
# eslint @graphql-eslint/selection-set-depth: ["error", {"maxDepth":4}]
3030

3131
query deep2 {
3232
viewer { # Level 0
@@ -40,7 +40,7 @@ query deep2 {
4040
### Correct (ignored field)
4141

4242
```graphql
43-
# eslint @graphql-eslint/selection-set-depth: ["error", [{"maxDepth":1,"ignore":["albums"]}]]
43+
# eslint @graphql-eslint/selection-set-depth: ["error", {"maxDepth":1,"ignore":["albums"]}]
4444

4545
query deep2 {
4646
viewer { # Level 0

docs/rules/strict-id-in-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Requires output types to have one unique identifier unless they do not have a lo
1212
### Incorrect
1313

1414
```graphql
15-
# eslint @graphql-eslint/strict-id-in-types: ["error", [{"acceptedIdNames":["id","_id"],"acceptedIdTypes":["ID"],"exceptions":{"suffixes":["Payload"]}}]]
15+
# eslint @graphql-eslint/strict-id-in-types: ["error", {"acceptedIdNames":["id","_id"],"acceptedIdTypes":["ID"],"exceptions":{"suffixes":["Payload"]}}]
1616

1717
# Incorrect field name
1818
type InvalidFieldName {
@@ -39,7 +39,7 @@ type InvalidFieldName {
3939
### Correct
4040

4141
```graphql
42-
# eslint @graphql-eslint/strict-id-in-types: ["error", [{"acceptedIdNames":["id","_id"],"acceptedIdTypes":["ID"],"exceptions":{"types":["Error"],"suffixes":["Payload"]}}]]
42+
# eslint @graphql-eslint/strict-id-in-types: ["error", {"acceptedIdNames":["id","_id"],"acceptedIdTypes":["ID"],"exceptions":{"types":["Error"],"suffixes":["Payload"]}}]
4343

4444
type User {
4545
id: ID!

scripts/generate-docs.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ async function main() {
4848
blocks.push(BR, `## Usage Examples`);
4949

5050
for (const example of examples) {
51+
// ESLint RuleTester accept options as array but in eslintrc config we must provide options as object
52+
const options = example.usage ? ', ' + JSON.stringify(example.usage[0]) : '';
53+
5154
blocks.push(
52-
`\n### ${example.title}\n\n\`\`\`graphql\n# eslint @graphql-eslint/${ruleName}: ["error"${
53-
example.usage ? ', ' + JSON.stringify(example.usage) : ''
54-
}]\n\n${dedent(example.code)}\n\`\`\``
55+
`\n### ${example.title}\n\n\`\`\`graphql\n# eslint @graphql-eslint/${ruleName}: ["error"${options}]\n\n${dedent(example.code)}\n\`\`\``,
5556
);
5657
}
5758
}

0 commit comments

Comments
 (0)