-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: update ESLint to flat config (#22)
- Loading branch information
Showing
10 changed files
with
174 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"schema": "./test/schema/**/*.graphql", | ||
"documents": "./test/operations/**/*.graphql" | ||
"schema": "./test/schema/**/*.{gql,graphql}", | ||
"documents": "./test/operations/**/*.{gql,graphql}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CHANGELOG.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import cheminfo from 'eslint-config-cheminfo'; | ||
|
||
import graphql from './index.js'; | ||
|
||
export default [...cheminfo, ...graphql]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,104 @@ | ||
module.exports = { | ||
overrides: [ | ||
{ | ||
files: ['*.graphql', '*.gql'], | ||
parser: '@graphql-eslint/eslint-plugin', | ||
plugins: ['@graphql-eslint'], | ||
rules: { | ||
'@graphql-eslint/alphabetize': 0, | ||
// Enforce all comments to be block comments | ||
'@graphql-eslint/description-style': 0, | ||
'@graphql-eslint/executable-definitions': 0, | ||
'@graphql-eslint/fields-on-correct-type': 2, | ||
'@graphql-eslint/fragments-on-composite-type': 2, | ||
// This rule is deactivated because it is not compatible with | ||
// naming input types PascalCase but mutations camelCase | ||
// https://github.com/dotansimha/graphql-eslint/blob/a2b71f6be17ff57614f57b3648ae2256cc834ea9/docs/rules/input-name.md | ||
'@graphql-eslint/input-name': 0, | ||
'@graphql-eslint/known-argument-names': 2, | ||
'@graphql-eslint/known-directives': 2, | ||
'@graphql-eslint/known-fragment-names': 2, | ||
'@graphql-eslint/known-type-names': 2, | ||
'@graphql-eslint/lone-anonymous-operation': 2, | ||
'@graphql-eslint/lone-schema-definition': 2, | ||
'@graphql-eslint/match-document-filename': 0, | ||
'@graphql-eslint/naming-convention': [ | ||
'error', | ||
{ | ||
ObjectTypeDefinition: 'PascalCase', | ||
FieldDefinition: 'camelCase', | ||
InputObjectTypeDefinition: 'PascalCase', | ||
InputValueDefinition: 'camelCase', | ||
EnumTypeDefinition: 'PascalCase', | ||
EnumValueDefinition: 'UPPER_CASE', | ||
InterfaceTypeDefinition: 'PascalCase', | ||
UnionTypeDefinition: 'PascalCase', | ||
ScalarTypeDefinition: 'PascalCase', | ||
OperationDefinition: 'PascalCase', | ||
Argument: 'camelCase', | ||
FragmentDefinition: 'camelCase', | ||
allowLeadingUnderscore: true, | ||
allowTrailingUnderscore: false, | ||
}, | ||
], | ||
import * as graphqlEslint from '@graphql-eslint/eslint-plugin'; | ||
|
||
'@graphql-eslint/no-anonymous-operations': 2, | ||
'@graphql-eslint/no-case-insensitive-enum-values-duplicates': 2, | ||
'@graphql-eslint/no-deprecated': 1, | ||
'@graphql-eslint/no-duplicate-fields': 2, | ||
'@graphql-eslint/no-hashtag-description': 2, | ||
'@graphql-eslint/no-fragment-cycles': 2, | ||
'@graphql-eslint/no-root-type': 0, | ||
// What errors does this rule prevent? | ||
'@graphql-eslint/no-scalar-result-type-on-mutation': 0, | ||
'@graphql-eslint/no-typename-prefix': 2, | ||
'@graphql-eslint/no-undefined-variables': 2, | ||
'@graphql-eslint/no-unreachable-types': 2, | ||
'@graphql-eslint/no-unused-fields': 1, | ||
'@graphql-eslint/no-unused-fragments': 2, | ||
'@graphql-eslint/no-unused-variables': 2, | ||
export default [ | ||
{ | ||
files: ['**/*.{gql,graphql}'], | ||
plugins: { | ||
'@graphql-eslint': graphqlEslint, | ||
}, | ||
languageOptions: { | ||
parser: graphqlEslint, | ||
}, | ||
rules: { | ||
'@graphql-eslint/alphabetize': 'off', | ||
// Enforce all comments to be block comments | ||
'@graphql-eslint/description-style': 'off', | ||
'@graphql-eslint/executable-definitions': 'off', | ||
'@graphql-eslint/fields-on-correct-type': 'error', | ||
'@graphql-eslint/fragments-on-composite-type': 'error', | ||
// This rule is deactivated because it is not compatible with | ||
// naming input types PascalCase but mutations camelCase | ||
// https://github.com/dotansimha/graphql-eslint/blob/a2b71f6be17ff57614f57b3648ae2256cc834ea9/docs/rules/input-name.md | ||
'@graphql-eslint/input-name': 'off', | ||
'@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/match-document-filename': 'off', | ||
'@graphql-eslint/naming-convention': [ | ||
'error', | ||
{ | ||
ObjectTypeDefinition: 'PascalCase', | ||
FieldDefinition: 'camelCase', | ||
InputObjectTypeDefinition: 'PascalCase', | ||
InputValueDefinition: 'camelCase', | ||
EnumTypeDefinition: 'PascalCase', | ||
EnumValueDefinition: 'UPPER_CASE', | ||
InterfaceTypeDefinition: 'PascalCase', | ||
UnionTypeDefinition: 'PascalCase', | ||
ScalarTypeDefinition: 'PascalCase', | ||
OperationDefinition: 'PascalCase', | ||
Argument: 'camelCase', | ||
FragmentDefinition: 'camelCase', | ||
allowLeadingUnderscore: true, | ||
allowTrailingUnderscore: false, | ||
}, | ||
], | ||
|
||
'@graphql-eslint/no-anonymous-operations': 'error', | ||
'@graphql-eslint/no-case-insensitive-enum-values-duplicates': 'error', | ||
'@graphql-eslint/no-deprecated': 'warn', | ||
'@graphql-eslint/no-duplicate-fields': 'error', | ||
'@graphql-eslint/no-hashtag-description': 'error', | ||
'@graphql-eslint/no-fragment-cycles': 'error', | ||
'@graphql-eslint/no-root-type': 'off', | ||
// What errors does this rule prevent? | ||
'@graphql-eslint/no-scalar-result-type-on-mutation': 'off', | ||
'@graphql-eslint/no-typename-prefix': 'error', | ||
'@graphql-eslint/no-undefined-variables': 'error', | ||
'@graphql-eslint/no-unreachable-types': 'error', | ||
'@graphql-eslint/no-unused-fields': 'warn', | ||
'@graphql-eslint/no-unused-fragments': 'error', | ||
'@graphql-eslint/no-unused-variables': 'error', | ||
|
||
'@graphql-eslint/overlapping-fields-can-be-merged': 2, | ||
'@graphql-eslint/possible-fragment-spread': 2, | ||
'@graphql-eslint/possible-type-extension': 2, | ||
'@graphql-eslint/provided-required-arguments': 2, | ||
'@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/relay-arguments': 0, | ||
'@graphql-eslint/relay-connection-types ': 0, | ||
'@graphql-eslint/relay-edge-types': 0, | ||
'@graphql-eslint/relay-page-info': 0, | ||
'@graphql-eslint/relay-arguments': 'off', | ||
'@graphql-eslint/relay-connection-types ': 'off', | ||
'@graphql-eslint/relay-edge-types': 'off', | ||
'@graphql-eslint/relay-page-info': 'off', | ||
|
||
'@graphql-eslint/require-deprecation-date': 0, | ||
'@graphql-eslint/require-deprecation-reason': 2, | ||
'@graphql-eslint/require-description': 0, | ||
'@graphql-eslint/require-field-of-type-query-in-mutation-result': 0, | ||
'@graphql-eslint/require-id-when-available': 2, | ||
'@graphql-eslint/require-deprecation-date': 'off', | ||
'@graphql-eslint/require-deprecation-reason': 'error', | ||
'@graphql-eslint/require-description': 'off', | ||
'@graphql-eslint/require-field-of-type-query-in-mutation-result': 'off', | ||
'@graphql-eslint/require-id-when-available': 'error', | ||
|
||
'@graphql-eslint/scalar-leafs': 2, | ||
'@graphql-eslint/selection-set-depth': 0, | ||
'@graphql-eslint/strict-id-in-types': 0, | ||
'@graphql-eslint/scalar-leafs': 'error', | ||
'@graphql-eslint/selection-set-depth': 'off', | ||
'@graphql-eslint/strict-id-in-types': 'off', | ||
|
||
'@graphql-eslint/unique-argument-names': 2, | ||
'@graphql-eslint/unique-directive-names': 2, | ||
'@graphql-eslint/unique-directive-names-per-location': 2, | ||
'@graphql-eslint/unique-enum-value-names': 2, | ||
'@graphql-eslint/unique-field-definition-names': 2, | ||
'@graphql-eslint/unique-fragment-name': 2, | ||
'@graphql-eslint/unique-input-field-names': 2, | ||
'@graphql-eslint/unique-operation-name': 2, | ||
'@graphql-eslint/unique-operation-types': 2, | ||
'@graphql-eslint/unique-type-names': 2, | ||
'@graphql-eslint/unique-variable-names': 2, | ||
'@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-fragment-name': 'error', | ||
'@graphql-eslint/unique-input-field-names': 'error', | ||
'@graphql-eslint/unique-operation-name': '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': 2, | ||
'@graphql-eslint/variables-are-input-types': 2, | ||
'@graphql-eslint/variables-in-allowed-position': 2, | ||
strict: 0, | ||
}, | ||
'@graphql-eslint/value-literals-of-correct-type': 'error', | ||
'@graphql-eslint/variables-are-input-types': 'error', | ||
'@graphql-eslint/variables-in-allowed-position': 'error', | ||
strict: 'off', | ||
}, | ||
], | ||
}; | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import assert from 'node:assert'; | ||
|
||
import { loadESLint } from 'eslint'; | ||
|
||
const ESLint = await loadESLint({ useFlatConfig: true }); | ||
const eslint = new ESLint(); | ||
const formatter = await eslint.loadFormatter('stylish'); | ||
|
||
const result = await eslint.lintFiles(['test/**/*.{gql,graphql}']); | ||
|
||
assert.strictEqual(result.length, 3, '3 graphql files should be linted'); | ||
|
||
const errorCount = result.reduce( | ||
(prev, current) => prev + current.errorCount, | ||
0, | ||
); | ||
assert.strictEqual( | ||
errorCount, | ||
0, | ||
`graphql files should not have any errors: ${formatter.format(result)}`, | ||
); |
This file was deleted.
Oops, something went wrong.