-
-
Notifications
You must be signed in to change notification settings - Fork 273
/
eslint.config.mjs
149 lines (139 loc) · 3.41 KB
/
eslint.config.mjs
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import { fixupPluginRules } from '@eslint/compat';
import * as graphqlEslint from '@graphql-eslint/eslint-plugin';
import openCollectiveConfig from 'eslint-config-opencollective/eslint.config.cjs';
import mocha from 'eslint-plugin-mocha';
import globals from 'globals';
export default [
...openCollectiveConfig,
// Global ignores
{
ignores: [
'./server/graphql/*.graphql',
'**/node_modules/',
'**/seeders/',
'migrations/archives',
'**/dist/',
'**/coverage/',
'**/.nyc_output',
'**/.vscode',
'**/.history',
'config/collective-spam-bayes.json',
],
},
{
files: ['**/*.{js,ts}'],
settings: {
'import/resolver': {
// You will also need to install and configure the TypeScript resolver
// See also https://github.com/import-js/eslint-import-resolver-typescript#configuration
typescript: true,
node: true,
},
},
languageOptions: {
globals: {
...globals.mocha,
},
},
rules: {
'no-console': 'off',
'import/no-commonjs': 'error',
'import/no-named-as-default-member': 'off',
'n/no-process-exit': 'off', // Applied only for CRON
'node/shebang': 'off',
'no-useless-escape': 'off',
'prefer-rest-params': 'off',
'require-atomic-updates': 'off',
camelcase: 'error',
'n/no-unsupported-features/node-builtins': 'off',
},
},
// Disable some rules for migrations
{
files: ['migrations/**/*.{js,ts}'],
rules: {
'import/no-commonjs': 'off',
},
},
// New TS rules
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
},
},
// Tests
{
files: ['test/**/*'],
plugins: {
mocha,
},
languageOptions: {
globals: {
...globals.mocha,
},
},
rules: {
'n/no-unpublished-import': 'off',
'n/no-missing-import': 'off', // We should configure it, but it's not working for now
'@typescript-eslint/no-unused-expressions': 'off', // Doesn't play well with chai
'mocha/no-exclusive-tests': 'error',
},
},
// Mocks
{
files: ['test/mocks/**/*', 'test/nocks/**/*'],
rules: {
camelcase: 'off',
},
},
// CRON jobs
{
files: ['cron/**/*.js'],
rules: {
'n/no-process-exit': 'off',
},
},
{
files: ['**/*.graphql'],
plugins: { '@graphql-eslint': fixupPluginRules(graphqlEslint) },
languageOptions: {
parser: { ...graphqlEslint, meta: { name: '@graphql-eslint' } },
},
settings: {
'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'],
},
},
],
},
},
{
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.',
},
],
},
],
},
},
];