Skip to content

Commit f35aaf7

Browse files
authored
run tests for examples with legacy eslint configs (#2504)
* add new docs * more * more * add * more * more * more * more * more * fix generate docs prettier, incorrectly formatted _meta.ts * add baseUrl * update eslint patch * fix snapshots * fix lint * move * more * more * more * more * more * prettier * more * more * more * prettier * more * prettier * more * more * more * prettier * fix for generate-configs * test legacy configs examples * more * more * prettier * more * more * more * run tests for examples with legacy configs * lint * polish introduction * add banner * fill usages * more * more * more * polish configs * more * new link * more * more * more * more * more * new link * more * more
1 parent 89ec798 commit f35aaf7

Some content is hidden

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

44 files changed

+1698
-270
lines changed

examples/code-file/.eslintrc.cjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Legacy config example, should be run with `ESLINT_USE_FLAT_CONFIG=false` environment variable in ESLint 9
3+
*/
4+
5+
module.exports = {
6+
root: true,
7+
// ❗️ It's very important that you don't have any rules configured at the top-level config,
8+
// and to move all configurations into the overrides section. Since JavaScript rules
9+
// can't run on GraphQL files and vice versa, if you have rules configured at the top level,
10+
// they will try to also execute for all overrides, as ESLint's configs cascade
11+
overrides: [
12+
{
13+
files: ['*.js'],
14+
processor: '@graphql-eslint/graphql',
15+
extends: ['eslint:recommended'],
16+
env: {
17+
es6: true,
18+
},
19+
rules: {
20+
'no-console': 'error',
21+
},
22+
},
23+
{
24+
files: ['*.graphql'],
25+
parser: '@graphql-eslint/eslint-plugin',
26+
plugins: ['@graphql-eslint'],
27+
rules: {
28+
'@graphql-eslint/no-anonymous-operations': 'error',
29+
'@graphql-eslint/naming-convention': [
30+
'error',
31+
{
32+
OperationDefinition: {
33+
style: 'PascalCase',
34+
forbiddenPrefixes: ['Query', 'Mutation', 'Subscription', 'Get'],
35+
forbiddenSuffixes: ['Query', 'Mutation', 'Subscription'],
36+
},
37+
},
38+
],
39+
},
40+
},
41+
],
42+
};

examples/code-file/eslint.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ export default [
1616
parser: graphqlPlugin.parser,
1717
},
1818
plugins: {
19-
'@graphql-eslint': {
20-
rules: graphqlPlugin.rules,
21-
},
19+
'@graphql-eslint': graphqlPlugin,
2220
},
2321
rules: {
2422
'@graphql-eslint/no-anonymous-operations': 'error',

examples/graphql-config/.eslintrc.cjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Legacy config example, should be run with `ESLINT_USE_FLAT_CONFIG=false` environment variable in ESLint 9
3+
*/
4+
5+
module.exports = {
6+
root: true,
7+
// ❗️ It's very important that you don't have any rules configured at the top-level config,
8+
// and to move all configurations into the overrides section. Since JavaScript rules
9+
// can't run on GraphQL files and vice versa, if you have rules configured at the top level,
10+
// they will try to also execute for all overrides, as ESLint's configs cascade
11+
overrides: [
12+
{
13+
files: ['*.js'],
14+
extends: ['eslint:recommended'],
15+
},
16+
{
17+
files: ['*.graphql'],
18+
parser: '@graphql-eslint/eslint-plugin',
19+
plugins: ['@graphql-eslint'],
20+
rules: {
21+
'@graphql-eslint/no-anonymous-operations': 'error',
22+
'@graphql-eslint/no-duplicate-fields': 'error',
23+
},
24+
},
25+
],
26+
};

examples/graphql-config/eslint.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ export default [
1212
parser: graphqlPlugin.parser,
1313
},
1414
plugins: {
15-
'@graphql-eslint': {
16-
rules: graphqlPlugin.rules,
17-
},
15+
'@graphql-eslint': graphqlPlugin,
1816
},
1917
rules: {
2018
'@graphql-eslint/no-anonymous-operations': 'error',

examples/monorepo/.eslintrc.cjs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Legacy config example, should be run with `ESLINT_USE_FLAT_CONFIG=false` environment variable in ESLint 9
3+
*/
4+
5+
module.exports = {
6+
root: true,
7+
// ❗️ It's very important that you don't have any rules configured at the top-level config,
8+
// and to move all configurations into the overrides section. Since JavaScript rules
9+
// can't run on GraphQL files and vice versa, if you have rules configured at the top level,
10+
// they will try to also execute for all overrides, as ESLint's configs cascade
11+
overrides: [
12+
{
13+
files: '*.tsx',
14+
extends: 'eslint:recommended',
15+
env: {
16+
es2022: true,
17+
},
18+
},
19+
{
20+
files: 'client/**/*.tsx',
21+
parserOptions: {
22+
sourceType: 'module',
23+
ecmaFeatures: {
24+
jsx: true,
25+
},
26+
},
27+
},
28+
{
29+
// Setup GraphQL Parser
30+
files: '*.{graphql,gql}',
31+
parser: '@graphql-eslint/eslint-plugin',
32+
plugins: ['@graphql-eslint'],
33+
},
34+
{
35+
// Setup processor for operations/fragments definitions on code-files
36+
files: 'client/**/*.tsx',
37+
processor: '@graphql-eslint/graphql',
38+
},
39+
{
40+
// Setup recommended config for schema files
41+
files: 'server/**/*.gql',
42+
extends: 'plugin:@graphql-eslint/schema-recommended',
43+
rules: {
44+
// Override graphql-eslint rules for schema files
45+
},
46+
},
47+
{
48+
// Setup recommended config for operations files
49+
files: 'client/**/*.{graphql,gql}',
50+
extends: 'plugin:@graphql-eslint/operations-recommended',
51+
rules: {
52+
// Override graphql-eslint rules for operations files
53+
},
54+
},
55+
],
56+
};

examples/monorepo/eslint.config.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import js from '@eslint/js';
22
import graphqlPlugin from '@graphql-eslint/eslint-plugin';
33

4-
const SCHEMA_PATH = 'server/**/*.gql';
5-
64
export default [
75
{
86
files: ['**/*.{js,tsx}'],
@@ -27,14 +25,12 @@ export default [
2725
parser: graphqlPlugin.parser,
2826
},
2927
plugins: {
30-
'@graphql-eslint': {
31-
rules: graphqlPlugin.rules,
32-
},
28+
'@graphql-eslint': graphqlPlugin,
3329
},
3430
},
3531
{
3632
// Setup recommended config for schema files
37-
files: [SCHEMA_PATH],
33+
files: ['server/**/*.gql'],
3834
rules: graphqlPlugin.configs['flat/schema-recommended'].rules,
3935
},
4036
{
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Legacy config example, should be run with `ESLINT_USE_FLAT_CONFIG=false` environment variable in ESLint 9
3+
*/
4+
5+
module.exports = {
6+
root: true,
7+
// ❗️ It's very important that you don't have any rules configured at the top-level config,
8+
// and to move all configurations into the overrides section. Since JavaScript rules
9+
// can't run on GraphQL files and vice versa, if you have rules configured at the top level,
10+
// they will try to also execute for all overrides, as ESLint's configs cascade
11+
overrides: [
12+
{
13+
files: ['*.js'],
14+
processor: '@graphql-eslint/graphql',
15+
extends: ['eslint:recommended'],
16+
parserOptions: {
17+
sourceType: 'module',
18+
},
19+
env: {
20+
es6: true,
21+
},
22+
},
23+
{
24+
files: ['schema.*.graphql'],
25+
extends: ['plugin:@graphql-eslint/schema-recommended'],
26+
rules: {
27+
'@graphql-eslint/require-description': 'off',
28+
},
29+
},
30+
{
31+
files: ['*.js/*.graphql'],
32+
extends: ['plugin:@graphql-eslint/operations-recommended'],
33+
},
34+
],
35+
};

examples/multiple-projects-graphql-config/eslint.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ export default [
1414
parser: graphqlPlugin.parser,
1515
},
1616
plugins: {
17-
'@graphql-eslint': {
18-
rules: graphqlPlugin.rules,
19-
},
17+
'@graphql-eslint': graphqlPlugin,
2018
},
2119
},
2220
{

examples/prettier/.eslintrc.cjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Legacy config example, should be run with `ESLINT_USE_FLAT_CONFIG=false` environment variable in ESLint 9
3+
*/
4+
5+
module.exports = {
6+
root: true,
7+
overrides: [
8+
{
9+
files: ['*.js'],
10+
processor: '@graphql-eslint/graphql',
11+
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
12+
env: {
13+
es6: true,
14+
},
15+
},
16+
{
17+
files: ['*.graphql'],
18+
parser: '@graphql-eslint/eslint-plugin',
19+
plugins: ['@graphql-eslint'],
20+
rules: {
21+
'prettier/prettier': 'error',
22+
},
23+
},
24+
],
25+
};

examples/prettier/eslint.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ export default [
2424
parser: graphqlPlugin.parser,
2525
},
2626
plugins: {
27-
'@graphql-eslint': {
28-
rules: graphqlPlugin.rules,
29-
},
27+
'@graphql-eslint': graphqlPlugin,
3028
},
3129
rules: {
3230
'prettier/prettier': 'error',

0 commit comments

Comments
 (0)