Skip to content

Commit da608d7

Browse files
authored
fix require is not defined in flat configs for Vue/Svelte projects (#2466)
* yoyo * use alpha * use `assert` instead `with`
1 parent 5d0b322 commit da608d7

File tree

13 files changed

+142
-112
lines changed

13 files changed

+142
-112
lines changed

.changeset/curly-socks-boil.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': patch
3+
---
4+
5+
fix `require is not defined` in flat configs for Vue/Svelte projects

examples/monorepo/eslint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export default [
1414
processor: graphql.processors.graphql,
1515
languageOptions: {
1616
parserOptions: {
17-
sourceType: 'module',
1817
ecmaFeatures: {
1918
jsx: true,
2019
},

examples/multiple-projects-graphql-config/.eslintrc.cjs

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import js from '@eslint/js';
2+
import * as graphql from '@graphql-eslint/eslint-plugin';
3+
4+
export default [
5+
{
6+
files: ['**/*.js'],
7+
processor: graphql.processors.graphql,
8+
rules: js.configs.recommended.rules,
9+
},
10+
{
11+
// Setup GraphQL Parser
12+
files: ['**/*.graphql'],
13+
plugins: {
14+
'@graphql-eslint': { rules: graphql.rules },
15+
},
16+
languageOptions: {
17+
parser: graphql.parser,
18+
},
19+
},
20+
{
21+
files: ['schema.*.graphql'],
22+
rules: {
23+
...graphql.flatConfigs['schema-recommended'].rules,
24+
'@graphql-eslint/require-description': 'off',
25+
},
26+
},
27+
{
28+
files: ['**/*.js/*.graphql'],
29+
rules: graphql.flatConfigs['operations-recommended'].rules,
30+
},
31+
];

examples/multiple-projects-graphql-config/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "@graphql-eslint/example-multiple-projects-graphql-config",
33
"version": "0.0.0",
4+
"type": "module",
45
"author": "Dimitri POSTOLOV",
56
"private": true,
67
"scripts": {
7-
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint --cache ."
8+
"lint": "eslint --cache ."
89
},
910
"dependencies": {
1011
"graphql": "16.9.0"

examples/svelte-code-file/.eslintrc.cjs

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

examples/svelte-code-file/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Dimitri POSTOLOV",
66
"private": true,
77
"scripts": {
8-
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint --cache ."
8+
"lint": "eslint --cache ."
99
},
1010
"dependencies": {
1111
"graphql": "16.9.0"

examples/vue-code-file/.eslintrc.cjs

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

0 commit comments

Comments
 (0)