-
-
Notifications
You must be signed in to change notification settings - Fork 267
/
.eslintrc.js
93 lines (91 loc) · 2.54 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const baseConfig = {
extends: ['opencollective'],
processor: '@graphql-eslint/graphql',
env: { mocha: true },
plugins: ['mocha'],
rules: {
// console logs are OK in Node
'no-console': 'off',
'mocha/no-exclusive-tests': 'error',
// use es6 module imports and exports
'import/no-commonjs': 'error',
// not useful or desired
'import/no-named-as-default-member': 'off',
// common warnings in the codebase
'n/no-process-exit': 'off',
'node/shebang': 'off',
'no-useless-escape': 'off',
'prefer-rest-params': 'off',
// relaxing because we have many errors
'require-atomic-updates': 'off',
// enforce strictly camelcase
camelcase: 'error',
// disallow unsupported Node.js built-in APIs on the specified version
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-unsupported-features/node-builtins.md
'n/no-unsupported-features/node-builtins': 'off',
},
};
const graphqlConfig = {
parser: '@graphql-eslint/eslint-plugin',
plugins: ['@graphql-eslint'],
settings: {
// Ignore .d.ts files for import (they just define the types)
'import/ignore': ['.d.ts$'],
},
rules: {
'@graphql-eslint/no-deprecated': 'warn',
'@graphql-eslint/fields-on-correct-type': 'error',
'@graphql-eslint/no-duplicate-fields': 'error',
'@graphql-eslint/naming-convention': [
'error',
{
VariableDefinition: 'camelCase',
OperationDefinition: {
style: 'PascalCase',
forbiddenPrefixes: ['get', 'fetch'],
forbiddenSuffixes: ['Query', 'Mutation', 'Fragment'],
},
},
],
},
};
// eslint-disable-next-line import/no-commonjs
module.exports = {
root: true,
ignorePatterns: ['./server/graphql/*.graphql'],
overrides: [
{
files: ['*.js', '*.ts'],
...baseConfig,
},
{
files: ['*.graphql'],
...graphqlConfig,
},
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
files: ['server/graphql/v2/**/*.+(js|ts)'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/v1/types'],
message: 'GraphQL V1 types should not be used with V2.',
},
],
},
],
},
},
],
};