forked from graphql-hive/console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.cjs
153 lines (150 loc) · 5.24 KB
/
.eslintrc.cjs
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
150
151
152
153
/* eslint-env node */
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
const { builtinModules } = require('module');
module.exports = {
reportUnusedDisableDirectives: true,
ignorePatterns: [
'scripts',
'rules',
'out',
'public',
'packages/web/app/src/graphql/index.ts',
'packages/libraries/cli/src/sdk.ts',
'packages/services/storage/src/db/types.ts',
'babel.config.cjs',
'jest.config.js',
],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.eslint.json', './deployment/tsconfig.json'],
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import', 'hive'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
rules: {
'no-process-env': 'error',
'no-restricted-globals': ['error', 'stop'],
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', ignoreRestSiblings: true }],
'no-empty': ['error', { allowEmptyCatch: true }],
'import/no-absolute-path': 'error',
'import/no-self-import': 'error',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['packages/services/storage/tools/*.js', 'packages/services/**'],
optionalDependencies: false,
},
],
'import/first': 'error',
'hive/enforce-deps-in-dev': [
'error',
{
scopes: ['@hive', '@graphql-hive'],
ignored: ['packages/libraries/**', 'packages/web/**'],
},
],
'@typescript-eslint/no-floating-promises': 'error',
// 🚨 The following rules needs to be fixed and was temporarily disabled to avoid printing warning
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
},
overrides: [
{
files: ['packages/web/**', 'packages/services/*-worker/**'],
rules: {
// because this folder is excluded in tsconfig.json
'@typescript-eslint/no-floating-promises': 'off',
},
parserOptions: {
// Fixes Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser
createDefaultProgram: true,
},
},
{
// TODO: replace with packages/web/**
files: ['packages/web/app/src/components/v2/**', 'packages/web/app/pages/\\[orgId\\]/**'],
extends: [
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:tailwindcss/recommended',
'plugin:jsx-a11y/recommended',
'plugin:@next/next/recommended',
],
plugins: ['simple-import-sort'],
settings: {
tailwindcss: {
config: 'packages/app/tailwind.config.js',
whitelist: [
'drag-none',
'placeholder-gray-500',
'fill-none',
'wrapper',
'line-clamp-1',
'line-clamp-2',
'line-clamp-3',
'-z-1',
],
},
react: {
version: 'detect',
},
},
rules: {
// conflicts with official prettier-plugin-tailwindcss and tailwind v3
'tailwindcss/classnames-order': 'off',
// set more strict to highlight in editor
'tailwindcss/no-custom-classname': 'error',
'tailwindcss/enforces-shorthand': 'error',
'tailwindcss/migration-from-tailwind-2': 'error',
// in React@17, import React is no longer required
'react/react-in-jsx-scope': 'off',
'react/display-name': 'off',
'react/prop-types': 'off',
'react/no-unescaped-entities': 'off',
'react/jsx-curly-brace-presence': 'error',
'react/no-unknown-property': 'off',
'jsx-a11y/anchor-is-valid': ['off', { components: ['Link', 'NextLink'] }],
'jsx-a11y/alt-text': ['warn', { elements: ['img'], img: ['Image', 'NextImage'] }],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'no-type-imports' }],
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': [
'error',
{
groups: [
[
// Node.js builtins
`^(node:)?(${builtinModules
.filter(mod => !mod.startsWith('_') && !mod.includes('/'))
.join('|')})(/.*|$)`,
'^react(-dom)?$',
'^next(/.*|$)',
'^graphql(/.*|$)',
// Side effect imports.
'^\\u0000',
// Packages.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
'^@?\\w',
],
[
// Absolute imports and other imports such as Vue-style `@/foo`.
// Anything not matched in another group.
'^',
// Relative imports.
// Anything that starts with a dot.
'^\\.',
// Style imports.
'^.+\\.css$',
],
],
},
],
},
},
],
};