Skip to content

Commit

Permalink
[v4] rule changes (#1812)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Aug 10, 2023
1 parent f5cda6d commit bf475e8
Show file tree
Hide file tree
Showing 51 changed files with 1,062 additions and 528 deletions.
57 changes: 57 additions & 0 deletions .changeset/few-mails-sparkle.md
@@ -0,0 +1,57 @@
---
'@graphql-eslint/eslint-plugin': major
---

- `alphabetize` rule changes

- add `definitions: true` option for `schema-all`/`operations-all` configs
- rename `values: ['EnumTypeDefinition']` to `values: true`
- rename `variables: ['OperationDefinition']` to `variables: true`
- add `groups: ['id', '*', 'createdAt', 'updatedAt']` for `schema-all`/`operations-all` configs

- `require-id-when-available` rule changes

- rename rule to `require-selections`

- update `schema-all`/`operations-all` configs

- `require-description` rule changes

- add `rootField: true` option for `schema-recommended` config

- require `eslint` at least `>=8.44.0` as peerDependency

- `naming-convention`

- add new options for `schema-recommended` config

```json5
{
'EnumTypeDefinition,EnumTypeExtension': {
forbiddenPrefixes: ['Enum'],
forbiddenSuffixes: ['Enum']
},
'InterfaceTypeDefinition,InterfaceTypeExtension': {
forbiddenPrefixes: ['Interface'],
forbiddenSuffixes: ['Interface']
},
'UnionTypeDefinition,UnionTypeExtension': {
forbiddenPrefixes: ['Union'],
forbiddenSuffixes: ['Union']
},
'ObjectTypeDefinition,ObjectTypeExtension': {
forbiddenPrefixes: ['Type'],
forbiddenSuffixes: ['Type']
}
}
```

- remove graphql-js' `unique-enum-value-names` rule

- rename `no-case-insensitive-enum-values-duplicates` to `unique-enum-value-names`

> Since this rule reports case-insensitive enum values duplicates too
- `require-nullable-result-in-root` rule changes

Do not check subscriptions
4 changes: 2 additions & 2 deletions examples/multiple-projects-graphql-config/graphql.config.ts
@@ -1,5 +1,5 @@
import { IGraphQLConfig } from 'graphql-config';
import { GraphQLTagPluckOptions } from '@graphql-tools/graphql-tag-pluck';
import type { IGraphQLConfig } from 'graphql-config';
import type { GraphQLTagPluckOptions } from '@graphql-tools/graphql-tag-pluck';

const config: IGraphQLConfig = {
projects: {
Expand Down
5 changes: 1 addition & 4 deletions examples/multiple-projects-graphql-config/package.json
Expand Up @@ -11,9 +11,6 @@
},
"devDependencies": {
"@graphql-eslint/eslint-plugin": "workspace:*",
"cosmiconfig-typescript-loader": "5.0.0",
"eslint": "8.46.0",
"ts-node": "10.9.1",
"typescript": "5.1.6"
"eslint": "8.46.0"
}
}
4 changes: 2 additions & 2 deletions examples/programmatic/eslint.config.js
Expand Up @@ -21,7 +21,7 @@ export default [
},
},
rules: {
'@graphql-eslint/require-id-when-available': ['error', { fieldName: '_id' }],
'@graphql-eslint/require-selections': ['error', { fieldName: '_id' }],
'@graphql-eslint/unique-fragment-name': 'error',
'@graphql-eslint/no-anonymous-operations': 'error',
'@graphql-eslint/naming-convention': [
Expand All @@ -34,7 +34,7 @@ export default [
},
},
],
'@graphql-eslint/no-case-insensitive-enum-values-duplicates': ['error'],
'@graphql-eslint/unique-enum-value-names': 'error',
'@graphql-eslint/require-description': ['error', { FieldDefinition: true }],
},
},
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -16,7 +16,6 @@
"generate:configs": "tsx scripts/generate-configs.ts",
"lint": "eslint --ignore-path .gitignore --cache .",
"lint:prettier": "prettier --cache --check .",
"postinstall": "tsx scripts/patch-graphql.ts",
"prebuild": "rimraf tsconfig.tsbuildinfo",
"prerelease": "NODE_ENV=production pnpm build",
"prettier": "pnpm lint:prettier --write",
Expand Down
184 changes: 93 additions & 91 deletions packages/plugin/CHANGELOG.md
Expand Up @@ -552,29 +552,29 @@ Special thanks to @connorjs

### Before

```json
```json5
{
"@graphql-eslint/avoid-operation-name-prefix": [
"error",
'@graphql-eslint/avoid-operation-name-prefix': [
'error',
{
"keywords": ["Query", "Mutation", "Subscription", "Get"]
keywords: ['Query', 'Mutation', 'Subscription', 'Get']
}
],
"@graphql-eslint/no-operation-name-suffix": "error"
'@graphql-eslint/no-operation-name-suffix': 'error'
}
```

### After

```json
```json5
{
"@graphql-eslint/naming-convention": [
"error",
'@graphql-eslint/naming-convention': [
'error',
{
"OperationDefinition": {
"style": "PascalCase",
"forbiddenPrefixes": ["Query", "Mutation", "Subscription", "Get"],
"forbiddenSuffixes": ["Query", "Mutation", "Subscription"]
OperationDefinition: {
style: 'PascalCase',
forbiddenPrefixes: ['Query', 'Mutation', 'Subscription', 'Get'],
forbiddenSuffixes: ['Query', 'Mutation', 'Subscription']
}
}
]
Expand Down Expand Up @@ -605,44 +605,44 @@ Special thanks to @connorjs

### Before

```json
```json5
{
"@graphql-eslint/naming-convention": [
"error",
'@graphql-eslint/naming-convention': [
'error',
{
"ObjectTypeDefinition": "PascalCase",
"InterfaceTypeDefinition": "PascalCase",
"EnumTypeDefinition": "PascalCase",
"ScalarTypeDefinition": "PascalCase",
"InputObjectTypeDefinition": "PascalCase",
"UnionTypeDefinition": "PascalCase",
"FieldDefinition": "camelCase",
"InputValueDefinition": "camelCase",
"QueryDefinition": {
"forbiddenPrefixes": ["get"]
ObjectTypeDefinition: 'PascalCase',
InterfaceTypeDefinition: 'PascalCase',
EnumTypeDefinition: 'PascalCase',
ScalarTypeDefinition: 'PascalCase',
InputObjectTypeDefinition: 'PascalCase',
UnionTypeDefinition: 'PascalCase',
FieldDefinition: 'camelCase',
InputValueDefinition: 'camelCase',
QueryDefinition: {
forbiddenPrefixes: ['get']
},
"leadingUnderscore": "allow",
"trailingUnderscore": "allow"
leadingUnderscore: 'allow',
trailingUnderscore: 'allow'
}
]
}
```

### After

```json
```json5
{
"@graphql-eslint/naming-convention": [
"error",
'@graphql-eslint/naming-convention': [
'error',
{
"types": "PascalCase",
"FieldDefinition": "camelCase",
"InputValueDefinition": "camelCase",
"FieldDefinition[parent.name.value=Query]": {
"forbiddenPrefixes": ["get"]
types: 'PascalCase',
FieldDefinition: 'camelCase',
InputValueDefinition: 'camelCase',
'FieldDefinition[parent.name.value=Query]': {
forbiddenPrefixes: ['get']
},
"allowLeadingUnderscore": true,
"allowTrailingUnderscore": true
allowLeadingUnderscore: true,
allowTrailingUnderscore: true
}
]
}
Expand All @@ -663,21 +663,21 @@ Special thanks to @connorjs

### Before

```json
```json5
{
"@graphql-eslint/require-description": [
"error",
'@graphql-eslint/require-description': [
'error',
{
"on": [
"ObjectTypeDefinition",
"InterfaceTypeDefinition",
"EnumTypeDefinition",
"InputObjectTypeDefinition",
"UnionTypeDefinition",
"FieldDefinition",
"InputValueDefinition",
"EnumValueDefinition",
"DirectiveDefinition"
on: [
'ObjectTypeDefinition',
'InterfaceTypeDefinition',
'EnumTypeDefinition',
'InputObjectTypeDefinition',
'UnionTypeDefinition',
'FieldDefinition',
'InputValueDefinition',
'EnumValueDefinition',
'DirectiveDefinition'
]
}
]
Expand All @@ -686,16 +686,16 @@ Special thanks to @connorjs

### After

```json
```json5
{
"@graphql-eslint/require-description": [
"error",
'@graphql-eslint/require-description': [
'error',
{
"types": true,
"FieldDefinition": true,
"InputValueDefinition": true,
"EnumValueDefinition": true,
"DirectiveDefinition": true
types: true,
FieldDefinition: true,
InputValueDefinition: true,
EnumValueDefinition: true,
DirectiveDefinition: true
}
]
}
Expand Down Expand Up @@ -886,39 +886,41 @@ Special thanks to @connorjs
As a drop-in replacement for the whole set of rules we had in `validate-against-schema`, you can
use this:

```
"@graphql-eslint/executable-definitions": "error",
"@graphql-eslint/fields-on-correct-type": "error",
"@graphql-eslint/fragments-on-composite-type": "error",
"@graphql-eslint/known-argument-names": "error",
"@graphql-eslint/known-directives": "error",
"@graphql-eslint/known-fragment-names": "error",
"@graphql-eslint/known-type-names": "error",
"@graphql-eslint/lone-anonymous-operation": "error",
"@graphql-eslint/lone-schema-definition": "error",
"@graphql-eslint/no-fragment-cycles": "error",
"@graphql-eslint/no-undefined-variables": "error",
"@graphql-eslint/no-unused-fragments": "error",
"@graphql-eslint/no-unused-variables": "error",
"@graphql-eslint/overlapping-fields-can-be-merged": "error",
"@graphql-eslint/possible-fragment-spread": "error",
"@graphql-eslint/possible-type-extension": "error",
"@graphql-eslint/provided-required-arguments": "error",
"@graphql-eslint/scalar-leafs": "error",
"@graphql-eslint/one-field-subscriptions": "error",
"@graphql-eslint/unique-argument-names": "error",
"@graphql-eslint/unique-directive-names": "error",
"@graphql-eslint/unique-directive-names-per-location": "error",
"@graphql-eslint/unique-enum-value-names": "error",
"@graphql-eslint/unique-field-definition-names": "error",
"@graphql-eslint/unique-input-field-names": "error",
"@graphql-eslint/unique-operation-types": "error",
"@graphql-eslint/unique-type-names": "error",
"@graphql-eslint/unique-variable-names": "error",
"@graphql-eslint/value-literals-of-correct-type": "error",
"@graphql-eslint/variables-are-input-types": "error",
"@graphql-eslint/variables-in-allowed-position": "error"
```
```json5
{
'@graphql-eslint/executable-definitions': 'error',
'@graphql-eslint/fields-on-correct-type': 'error',
'@graphql-eslint/fragments-on-composite-type': 'error',
'@graphql-eslint/known-argument-names': 'error',
'@graphql-eslint/known-directives': 'error',
'@graphql-eslint/known-fragment-names': 'error',
'@graphql-eslint/known-type-names': 'error',
'@graphql-eslint/lone-anonymous-operation': 'error',
'@graphql-eslint/lone-schema-definition': 'error',
'@graphql-eslint/no-fragment-cycles': 'error',
'@graphql-eslint/no-undefined-variables': 'error',
'@graphql-eslint/no-unused-fragments': 'error',
'@graphql-eslint/no-unused-variables': 'error',
'@graphql-eslint/overlapping-fields-can-be-merged': 'error',
'@graphql-eslint/possible-fragment-spread': 'error',
'@graphql-eslint/possible-type-extension': 'error',
'@graphql-eslint/provided-required-arguments': 'error',
'@graphql-eslint/scalar-leafs': 'error',
'@graphql-eslint/one-field-subscriptions': 'error',
'@graphql-eslint/unique-argument-names': 'error',
'@graphql-eslint/unique-directive-names': 'error',
'@graphql-eslint/unique-directive-names-per-location': 'error',
'@graphql-eslint/unique-enum-value-names': 'error',
'@graphql-eslint/unique-field-definition-names': 'error',
'@graphql-eslint/unique-input-field-names': 'error',
'@graphql-eslint/unique-operation-types': 'error',
'@graphql-eslint/unique-type-names': 'error',
'@graphql-eslint/unique-variable-names': 'error',
'@graphql-eslint/value-literals-of-correct-type': 'error',
'@graphql-eslint/variables-are-input-types': 'error',
'@graphql-eslint/variables-in-allowed-position': 'error'
}
```

- 61251e7: Bump dependencies and update minimum Node version to `v12`

Expand Down

0 comments on commit bf475e8

Please sign in to comment.