Skip to content

Commit 2e4dfa0

Browse files
authored
support new ESLint flat config system, export flatConfigs (#1335)
* refactor examples to use flat configs * fix imports * addCreateRequireBanner * new configs * basic * monorepo * code-file * graphql-config * graphql-config-code-file * fix * prettier plugin * ready to go * support new ESLint flat config system, export `flatConfigs` * prettify * console.log at the end
1 parent e375d48 commit 2e4dfa0

File tree

79 files changed

+514
-470
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+514
-470
lines changed

.changeset/afraid-foxes-hide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': minor
3+
---
4+
5+
support new ESLint flat config system, export `flatConfigs`

.eslintrc.cjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,14 @@ module.exports = {
6161
{
6262
files: ['scripts/**'],
6363
rules: {
64-
'no-console': 'off'
65-
}
66-
}
64+
'no-console': 'off',
65+
},
66+
},
67+
{
68+
files: ['packages/plugin/src/**'],
69+
rules: {
70+
'import/extensions': ['error', 'ignorePackages'],
71+
},
72+
},
6773
],
6874
};

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ packages/plugin/tests/__snapshots__/
33
examples/prettier/invalid.graphql
44
examples/prettier/invalid.js
55
pnpm-lock.yaml
6+
.bob/

examples/basic/.eslintrc.cjs

Lines changed: 0 additions & 39 deletions
This file was deleted.

examples/basic/eslint.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import * as graphqlESLint from '@graphql-eslint/eslint-plugin';
2+
3+
export default [
4+
'eslint:recommended',
5+
{
6+
files: ['**/*.graphql'],
7+
plugins: {
8+
'@graphql-eslint': graphqlESLint,
9+
},
10+
languageOptions: {
11+
parser: graphqlESLint,
12+
parserOptions: {
13+
schema: 'schema.graphql',
14+
operations: ['query.graphql', 'fragment.graphql', 'fragment2.graphql'],
15+
},
16+
},
17+
rules: {
18+
'@graphql-eslint/require-id-when-available': ['error', { fieldName: '_id' }],
19+
'@graphql-eslint/unique-fragment-name': 'error',
20+
'@graphql-eslint/no-anonymous-operations': 'error',
21+
'@graphql-eslint/naming-convention': [
22+
'error',
23+
{
24+
OperationDefinition: {
25+
style: 'PascalCase',
26+
forbiddenPrefixes: ['Query', 'Mutation', 'Subscription', 'Get'],
27+
forbiddenSuffixes: ['Query', 'Mutation', 'Subscription'],
28+
},
29+
},
30+
],
31+
'@graphql-eslint/no-case-insensitive-enum-values-duplicates': ['error'],
32+
'@graphql-eslint/require-description': ['error', { FieldDefinition: true }],
33+
},
34+
},
35+
];

examples/basic/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@graphql-eslint/example-basic",
33
"version": "0.0.0",
4+
"type": "module",
45
"repository": "https://github.com/B2o5T/graphql-eslint",
56
"author": "Dotan Simha <[email protected]>",
67
"private": true,

examples/code-file/.eslintrc.cjs

Lines changed: 0 additions & 41 deletions
This file was deleted.

examples/code-file/eslint.config.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as graphqlESLint from '@graphql-eslint/eslint-plugin';
2+
3+
export default [
4+
'eslint:recommended',
5+
{
6+
files: ['**/*.js'],
7+
processor: graphqlESLint.processors.graphql,
8+
rules: {
9+
'no-console': 'error',
10+
},
11+
},
12+
{
13+
files: ['**/*.graphql'],
14+
plugins: {
15+
'@graphql-eslint': graphqlESLint,
16+
},
17+
languageOptions: {
18+
parser: graphqlESLint,
19+
parserOptions: {
20+
schema: 'schema.graphql',
21+
},
22+
},
23+
rules: {
24+
'@graphql-eslint/no-anonymous-operations': 'error',
25+
'@graphql-eslint/naming-convention': [
26+
'error',
27+
{
28+
OperationDefinition: {
29+
style: 'PascalCase',
30+
forbiddenPrefixes: ['Query', 'Mutation', 'Subscription', 'Get'],
31+
forbiddenSuffixes: ['Query', 'Mutation', 'Subscription'],
32+
},
33+
},
34+
],
35+
},
36+
},
37+
];

examples/code-file/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@graphql-eslint/example-code-file",
33
"version": "0.0.0",
4+
"type": "module",
45
"repository": "https://github.com/B2o5T/graphql-eslint",
56
"author": "Dotan Simha <[email protected]>",
67
"private": true,

examples/graphql-config-code-file/.eslintrc.cjs

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)