@graphql-eslint/eslint-plugin 3.13.1-alpha-20221105010933-2b1e7ee → 3.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +266 -0
- package/docs/README.md +76 -0
- package/docs/custom-rules.md +148 -0
- package/docs/deprecated-rules.md +21 -0
- package/docs/parser-options.md +85 -0
- package/docs/parser.md +49 -0
- package/docs/rules/alphabetize.md +178 -0
- package/docs/rules/description-style.md +54 -0
- package/docs/rules/executable-definitions.md +17 -0
- package/docs/rules/fields-on-correct-type.md +17 -0
- package/docs/rules/fragments-on-composite-type.md +17 -0
- package/docs/rules/input-name.md +76 -0
- package/docs/rules/known-argument-names.md +17 -0
- package/docs/rules/known-directives.md +44 -0
- package/docs/rules/known-fragment-names.md +69 -0
- package/docs/rules/known-type-names.md +17 -0
- package/docs/rules/lone-anonymous-operation.md +17 -0
- package/docs/rules/lone-schema-definition.md +17 -0
- package/docs/rules/match-document-filename.md +156 -0
- package/docs/rules/naming-convention.md +300 -0
- package/docs/rules/no-anonymous-operations.md +39 -0
- package/docs/rules/no-case-insensitive-enum-values-duplicates.md +43 -0
- package/docs/rules/no-deprecated.md +85 -0
- package/docs/rules/no-duplicate-fields.md +65 -0
- package/docs/rules/no-fragment-cycles.md +17 -0
- package/docs/rules/no-hashtag-description.md +59 -0
- package/docs/rules/no-root-type.md +53 -0
- package/docs/rules/no-scalar-result-type-on-mutation.md +37 -0
- package/docs/rules/no-typename-prefix.md +39 -0
- package/docs/rules/no-undefined-variables.md +17 -0
- package/docs/rules/no-unreachable-types.md +49 -0
- package/docs/rules/no-unused-fields.md +62 -0
- package/docs/rules/no-unused-fragments.md +17 -0
- package/docs/rules/no-unused-variables.md +17 -0
- package/docs/rules/one-field-subscriptions.md +17 -0
- package/docs/rules/overlapping-fields-can-be-merged.md +17 -0
- package/docs/rules/possible-fragment-spread.md +17 -0
- package/docs/rules/possible-type-extension.md +15 -0
- package/docs/rules/provided-required-arguments.md +17 -0
- package/docs/rules/relay-arguments.md +57 -0
- package/docs/rules/relay-connection-types.md +42 -0
- package/docs/rules/relay-edge-types.md +56 -0
- package/docs/rules/relay-page-info.md +32 -0
- package/docs/rules/require-deprecation-date.md +57 -0
- package/docs/rules/require-deprecation-reason.md +47 -0
- package/docs/rules/require-description.md +115 -0
- package/docs/rules/require-field-of-type-query-in-mutation-result.md +47 -0
- package/docs/rules/require-id-when-available.md +88 -0
- package/docs/rules/scalar-leafs.md +17 -0
- package/docs/rules/selection-set-depth.md +76 -0
- package/docs/rules/strict-id-in-types.md +130 -0
- package/docs/rules/unique-argument-names.md +17 -0
- package/docs/rules/unique-directive-names-per-location.md +17 -0
- package/docs/rules/unique-directive-names.md +17 -0
- package/docs/rules/unique-enum-value-names.md +15 -0
- package/docs/rules/unique-field-definition-names.md +17 -0
- package/docs/rules/unique-fragment-name.md +51 -0
- package/docs/rules/unique-input-field-names.md +17 -0
- package/docs/rules/unique-operation-name.md +55 -0
- package/docs/rules/unique-operation-types.md +17 -0
- package/docs/rules/unique-type-names.md +17 -0
- package/docs/rules/unique-variable-names.md +17 -0
- package/docs/rules/value-literals-of-correct-type.md +17 -0
- package/docs/rules/variables-are-input-types.md +17 -0
- package/docs/rules/variables-in-allowed-position.md +17 -0
- package/index.js +2 -1
- package/index.mjs +2 -1
- package/package.json +1 -1
@@ -0,0 +1,51 @@
|
|
1
|
+
# `unique-fragment-name`
|
2
|
+
|
3
|
+
- Category: `Operations`
|
4
|
+
- Rule name: `@graphql-eslint/unique-fragment-name`
|
5
|
+
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
|
+
- Requires GraphQL Operations: `true` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
7
|
+
|
8
|
+
Enforce unique fragment names across your project.
|
9
|
+
|
10
|
+
## Usage Examples
|
11
|
+
|
12
|
+
### Incorrect
|
13
|
+
|
14
|
+
```graphql
|
15
|
+
# eslint @graphql-eslint/unique-fragment-name: 'error'
|
16
|
+
|
17
|
+
# user.fragment.graphql
|
18
|
+
fragment UserFields on User {
|
19
|
+
id
|
20
|
+
name
|
21
|
+
fullName
|
22
|
+
}
|
23
|
+
|
24
|
+
# user-fields.graphql
|
25
|
+
fragment UserFields on User {
|
26
|
+
id
|
27
|
+
}
|
28
|
+
```
|
29
|
+
|
30
|
+
### Correct
|
31
|
+
|
32
|
+
```graphql
|
33
|
+
# eslint @graphql-eslint/unique-fragment-name: 'error'
|
34
|
+
|
35
|
+
# user.fragment.graphql
|
36
|
+
fragment AllUserFields on User {
|
37
|
+
id
|
38
|
+
name
|
39
|
+
fullName
|
40
|
+
}
|
41
|
+
|
42
|
+
# user-fields.graphql
|
43
|
+
fragment UserFields on User {
|
44
|
+
id
|
45
|
+
}
|
46
|
+
```
|
47
|
+
|
48
|
+
## Resources
|
49
|
+
|
50
|
+
- [Rule source](../../packages/plugin/src/rules/unique-fragment-name.ts)
|
51
|
+
- [Test source](../../packages/plugin/tests/unique-fragment-name.spec.ts)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# `unique-input-field-names`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
5
|
+
- Category: `Operations`
|
6
|
+
- Rule name: `@graphql-eslint/unique-input-field-names`
|
7
|
+
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
|
+
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
9
|
+
|
10
|
+
A GraphQL input object value is only valid if all supplied fields are uniquely named.
|
11
|
+
|
12
|
+
> This rule is a wrapper around a `graphql-js` validation function.
|
13
|
+
|
14
|
+
## Resources
|
15
|
+
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueInputFieldNamesRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueInputFieldNamesRule-test.ts)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# `unique-operation-name`
|
2
|
+
|
3
|
+
- Category: `Operations`
|
4
|
+
- Rule name: `@graphql-eslint/unique-operation-name`
|
5
|
+
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
6
|
+
- Requires GraphQL Operations: `true` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
7
|
+
|
8
|
+
Enforce unique operation names across your project.
|
9
|
+
|
10
|
+
## Usage Examples
|
11
|
+
|
12
|
+
### Incorrect
|
13
|
+
|
14
|
+
```graphql
|
15
|
+
# eslint @graphql-eslint/unique-operation-name: 'error'
|
16
|
+
|
17
|
+
# foo.query.graphql
|
18
|
+
query user {
|
19
|
+
user {
|
20
|
+
id
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
# bar.query.graphql
|
25
|
+
query user {
|
26
|
+
me {
|
27
|
+
id
|
28
|
+
}
|
29
|
+
}
|
30
|
+
```
|
31
|
+
|
32
|
+
### Correct
|
33
|
+
|
34
|
+
```graphql
|
35
|
+
# eslint @graphql-eslint/unique-operation-name: 'error'
|
36
|
+
|
37
|
+
# foo.query.graphql
|
38
|
+
query user {
|
39
|
+
user {
|
40
|
+
id
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
# bar.query.graphql
|
45
|
+
query me {
|
46
|
+
me {
|
47
|
+
id
|
48
|
+
}
|
49
|
+
}
|
50
|
+
```
|
51
|
+
|
52
|
+
## Resources
|
53
|
+
|
54
|
+
- [Rule source](../../packages/plugin/src/rules/unique-operation-name.ts)
|
55
|
+
- [Test source](../../packages/plugin/tests/unique-operation-name.spec.ts)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# `unique-operation-types`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
5
|
+
- Category: `Schema`
|
6
|
+
- Rule name: `@graphql-eslint/unique-operation-types`
|
7
|
+
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
|
+
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
9
|
+
|
10
|
+
A GraphQL document is only valid if it has only one type per operation.
|
11
|
+
|
12
|
+
> This rule is a wrapper around a `graphql-js` validation function.
|
13
|
+
|
14
|
+
## Resources
|
15
|
+
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueOperationTypesRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueOperationTypesRule-test.ts)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# `unique-type-names`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
5
|
+
- Category: `Schema`
|
6
|
+
- Rule name: `@graphql-eslint/unique-type-names`
|
7
|
+
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
|
+
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
9
|
+
|
10
|
+
A GraphQL document is only valid if all defined types have unique names.
|
11
|
+
|
12
|
+
> This rule is a wrapper around a `graphql-js` validation function.
|
13
|
+
|
14
|
+
## Resources
|
15
|
+
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueTypeNamesRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueTypeNamesRule-test.ts)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# `unique-variable-names`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
5
|
+
- Category: `Operations`
|
6
|
+
- Rule name: `@graphql-eslint/unique-variable-names`
|
7
|
+
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
|
+
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
9
|
+
|
10
|
+
A GraphQL operation is only valid if all its variables are uniquely named.
|
11
|
+
|
12
|
+
> This rule is a wrapper around a `graphql-js` validation function.
|
13
|
+
|
14
|
+
## Resources
|
15
|
+
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueVariableNamesRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueVariableNamesRule-test.ts)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# `value-literals-of-correct-type`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
5
|
+
- Category: `Operations`
|
6
|
+
- Rule name: `@graphql-eslint/value-literals-of-correct-type`
|
7
|
+
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
|
+
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
9
|
+
|
10
|
+
A GraphQL document is only valid if all value literals are of the type expected at their position.
|
11
|
+
|
12
|
+
> This rule is a wrapper around a `graphql-js` validation function.
|
13
|
+
|
14
|
+
## Resources
|
15
|
+
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ValuesOfCorrectTypeRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/ValuesOfCorrectTypeRule-test.ts)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# `variables-are-input-types`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
5
|
+
- Category: `Operations`
|
6
|
+
- Rule name: `@graphql-eslint/variables-are-input-types`
|
7
|
+
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
|
+
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
9
|
+
|
10
|
+
A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).
|
11
|
+
|
12
|
+
> This rule is a wrapper around a `graphql-js` validation function.
|
13
|
+
|
14
|
+
## Resources
|
15
|
+
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/VariablesAreInputTypesRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/VariablesAreInputTypesRule-test.ts)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# `variables-in-allowed-position`
|
2
|
+
|
3
|
+
✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file enables this rule.
|
4
|
+
|
5
|
+
- Category: `Operations`
|
6
|
+
- Rule name: `@graphql-eslint/variables-in-allowed-position`
|
7
|
+
- Requires GraphQL Schema: `true` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
|
8
|
+
- Requires GraphQL Operations: `false` [ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
|
9
|
+
|
10
|
+
Variables passed to field arguments conform to type.
|
11
|
+
|
12
|
+
> This rule is a wrapper around a `graphql-js` validation function.
|
13
|
+
|
14
|
+
## Resources
|
15
|
+
|
16
|
+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/VariablesInAllowedPositionRule.ts)
|
17
|
+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/VariablesInAllowedPositionRule-test.ts)
|
package/index.js
CHANGED
@@ -4274,7 +4274,8 @@ class ModuleCache {
|
|
4274
4274
|
}
|
4275
4275
|
const { lastSeen, result } = this.map.get(cacheKey);
|
4276
4276
|
// check freshness
|
4277
|
-
if (process.
|
4277
|
+
if (process.env.NODE /* don't check for ESLint CLI */ ||
|
4278
|
+
process.hrtime(lastSeen)[0] < settings.lifetime) {
|
4278
4279
|
return result;
|
4279
4280
|
}
|
4280
4281
|
}
|
package/index.mjs
CHANGED
@@ -4268,7 +4268,8 @@ class ModuleCache {
|
|
4268
4268
|
}
|
4269
4269
|
const { lastSeen, result } = this.map.get(cacheKey);
|
4270
4270
|
// check freshness
|
4271
|
-
if (process.
|
4271
|
+
if (process.env.NODE /* don't check for ESLint CLI */ ||
|
4272
|
+
process.hrtime(lastSeen)[0] < settings.lifetime) {
|
4272
4273
|
return result;
|
4273
4274
|
}
|
4274
4275
|
}
|