Skip to content

Commit 709dd09

Browse files
author
Guillaume Chau
committed
fix: disable gql files linting by default
1 parent c1d7214 commit 709dd09

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

docs/guide/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ module.exports = {
5858
enableMocks: true,
5959
// Enable Apollo Engine
6060
enableEngine: true,
61+
// Enable ESLint for `.gql` files
62+
lintGQL: false,
6163

6264
/* Other options (with default values) */
6365

index.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ const SCHEMA_OPTIONS = {
1818

1919
const DEFAULT_GENERATE_OUTPUT = './node_modules/.temp/graphql/schema'
2020

21+
function nullable (value) {
22+
return value == null ? {} : value
23+
}
24+
2125
module.exports = (api, options) => {
26+
const apolloOptions = nullable(nullable(options.pluginOptions).apollo)
2227
const useThreads = process.env.NODE_ENV === 'production' && options.parallel
2328
const cacheDirectory = api.resolve('node_modules/.cache/cache-loader')
2429
const { generateCacheIdentifier } = require('./utils')
@@ -44,19 +49,24 @@ module.exports = (api, options) => {
4449
.end()
4550

4651
if (api.hasPlugin('eslint') && config.module.rules.has('eslint')) {
47-
const id = generateCacheIdentifier(api.resolve('.'))
48-
49-
config.module
50-
.rule('eslint')
51-
.test(/\.(vue|(j|t)sx?|gql|graphql)$/)
52-
.use('eslint-loader')
53-
.tap(options => {
54-
options.extensions.push('.gql', '.graphql')
55-
return {
56-
...options,
57-
cacheIdentifier: options.cacheIdentifier + id,
58-
}
59-
})
52+
if (apolloOptions.lintGQL) {
53+
const id = generateCacheIdentifier(api.resolve('.'))
54+
55+
config.module
56+
.rule('eslint')
57+
.test(/\.(vue|(j|t)sx?|gql|graphql)$/)
58+
.use('eslint-loader')
59+
.tap(options => {
60+
options.extensions.push('.gql', '.graphql')
61+
return {
62+
...options,
63+
cacheIdentifier: options.cacheIdentifier + id,
64+
}
65+
})
66+
} else if (apolloOptions.lintGQL !== false) {
67+
console.log('To enable GQL files in ESLint, set the `pluginOptions.apollo.lintGQL` project option to `true` in `vue.config.js`. Put `false` to hide this message.')
68+
console.log('You also need to install `eslint-plugin-graphql` and enable it in your ESLint configuration.')
69+
}
6070
}
6171

6272
config.resolve

0 commit comments

Comments
 (0)