forked from zammad/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
193 lines (172 loc) · 6.06 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
const path = require('path')
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
plugins: ['@typescript-eslint', 'vue', 'prettier', 'zammad'],
extends: [
'airbnb-base',
'plugin:vue/vue3-recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'@vue/prettier',
'@vue/typescript/recommended',
'prettier',
],
rules: {
'zammad/zammad-copyright': 'error',
'zammad/zammad-detect-translatable-string': 'error',
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// Loosen AirBnB's strict rules a bit to allow 'for .. of'
'no-restricted-syntax': [
'error',
'ForInStatement',
// "ForOfStatement", // We want to allow this
'LabeledStatement',
'WithStatement',
],
'no-param-reassign': 'off',
'func-style': ['error', 'expression'],
'no-restricted-imports': 'off',
// Disable the following rule, because it's not relevant for the tool chain and test envoirment.
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'tailwind.config.js',
'vite.config.ts',
'app/frontend/build/**',
'app/frontend/**/*.spec.*',
'app/frontend/**/__tests__/**/*',
'app/frontend/tests/**/*',
'app/frontend/**/*.stories.ts',
'.storybook/**/*',
'app/frontend/cypress/**/*',
],
},
],
// Adding typescript file types, because airbnb doesn't allow this by default.
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
mjs: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'import/prefer-default-export': 'off',
// TODO: Add import rule to not allow that "app/**/modules/**" can import from each other and also add a rule that apps/** can not import from other apps.
/* We strongly recommend that you do not use the no-undef lint rule on TypeScript projects. The checks it provides are already provided by TypeScript without the need for configuration - TypeScript just does this significantly better (Source: https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors). */
'no-undef': 'off',
// We need to use the extended 'no-shadow' rule from typescript:
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/no-explicit-any': ['error', { ignoreRestArgs: true }],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'enumMember',
format: ['StrictPascalCase'],
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
],
'vue/component-tags-order': [
'error',
{
order: ['script', 'template', 'style'],
},
],
'vue/script-setup-uses-vars': 'error',
// Don't require a default value for the props.
'vue/require-default-prop': 'off',
// Don't require multi word component names.
'vue/multi-word-component-names': 'off',
// Enforce v-bind directive usage in short form as error instead of warning
'vue/v-bind-style': ['error', 'shorthand'],
// Enforce v-on directive usage in short form as error instead of warning
'vue/v-on-style': ['error', 'shorthand'],
// Enforce v-slot directive usage in short form as error instead of warning
'vue/v-slot-style': ['error', 'shorthand'],
},
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['.storybook/config/*'],
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
{
files: [
'app/frontend/tests/**',
'app/frontend/**/__tests__/**',
'app/frontend/**/*.spec.*',
'app/frontend/stories/**',
'app/frontend/cypress/**',
'app/frontend/**/*.stories.ts',
'.eslint-plugin-zammad/**',
'.eslintrc.js',
],
rules: {
'zammad/zammad-detect-translatable-string': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'import/first': 'off',
},
},
],
settings: {
'import/resolver': {
alias: {
map: [
['@', path.resolve(__dirname, './app/frontend')],
['@mobile', path.resolve(__dirname, './app/frontend/apps/mobile')],
['@shared', path.resolve(__dirname, './app/frontend/shared')],
['@tests', path.resolve(__dirname, './app/frontend/tests')],
['@stories', path.resolve(__dirname, './app/frontend/stories')],
['@cy', path.resolve(__dirname, './.cypress')],
[
'vitest',
path.resolve(__dirname, 'node_modules/vitest/dist/index.mjs'),
],
],
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
},
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
paths: [path.resolve(__dirname, '.storybook/node_modules/')],
},
},
// Adding typescript file types, because airbnb doesn't allow this by default.
'import/extensions': ['.js', '.jsx', '.ts', '.tsx', '.vue'],
},
globals: {
defineProps: 'readonly',
defineEmits: 'readonly',
defineExpose: 'readonly',
withDefaults: 'readonly',
},
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser', // the typescript-parser for eslint, instead of tslint
sourceType: 'module', // allow the use of imports statements
ecmaVersion: 2020, // allow the parsing of modern ecmascript
},
}