-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.eslintrc.cjs
123 lines (118 loc) · 3.67 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
/* eslint-env node */
'use strict'
const { defineConfig } = require('@sixxgate/lint')
const { memo } = require('radash')
module.exports = defineConfig(({ useVue, useNode, useTypeScript }) => {
useVue({ version: '3.4', style: 'sass' })
useNode()
useTypeScript()
/** @type {() => Partial<import('eslint').Linter.RulesRecord>} */
const useCommonJsDocRules = memo(() => ({
// Don't require all sections to be filled out.
'jsdoc/require-returns': 'off',
'jsdoc/require-yields': 'off',
// Requires too much configuration to worry about.
'jsdoc/tag-lines': 'off',
// Don't require DocComments.
'jsdoc/require-jsdoc': 'off'
}))
/** @type {() => Partial<import('eslint').Linter.RulesRecord>} */
const useJsDocRules = memo(() => ({
...useCommonJsDocRules(),
// Only require the parameters if we want them.
'jsdoc/require-param': ['error', { ignoreWhenAllParamsMissing: true }]
}))
/** @type {() => Partial<import('eslint').Linter.RulesRecord>} */
const useTsDocRules = memo(() => ({
...useCommonJsDocRules(),
// Only require the parameters if we want them.
'jsdoc/require-param': [
'error',
{
ignoreWhenAllParamsMissing: true,
// Has issues with TSDoc
checkDestructuredRoots: false
}
],
// Has issues with JSDOc.
'jsdoc/check-param-names': ['error', { checkDestructured: false }],
// TSDoc itself.
'tsdoc/syntax': 'error'
}))
return {
root: true,
env: { es2023: true },
plugins: ['eslint-plugin-tsdoc'],
reportUnusedDisableDirectives: true,
overrides: [
// CommonJS JavaScript
{
files: ['*.cjs'],
extends: ['plugin:jsdoc/recommended-error'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
...useJsDocRules()
},
parserOptions: {
project: './tsconfig.config.json'
}
},
// Main and preload
{
files: ['src/core/**/*.ts', 'src/main/**/*.ts', 'src/main/**/*.js', 'src/preload/**/*.ts'],
parserOptions: {
project: './tsconfig.node.json'
}
},
// Main and preload TypeScript
{
files: ['src/core/**/*.ts', 'src/main/**/*.ts', 'src/preload/**/*.ts'],
extends: ['plugin:jsdoc/recommended-typescript-error'],
rules: { ...useTsDocRules() }
},
// Main and preload JavaScript
{
files: ['src/main/**/*.js'],
extends: ['plugin:jsdoc/recommended-error'],
rules: { ...useJsDocRules() }
},
// Renderer
{
files: ['src/renderer/**/*.ts', 'src/renderer/**/*.tsx', 'src/renderer/**/*.js', 'src/renderer/**/*.vue'],
parserOptions: {
project: './tsconfig.web.json'
}
},
// Renderer TypeScript
{
files: ['src/renderer/**/*.ts', 'src/renderer/**/*.tsx', 'src/renderer/**/*.vue'],
extends: ['plugin:jsdoc/recommended-typescript-error'],
rules: { ...useTsDocRules() }
},
// Renderer JavaScript
{
files: ['src/renderer/**/*.js'],
extends: ['plugin:jsdoc/recommended-error'],
rules: { ...useJsDocRules() }
},
// Vite configuration
{
files: ['electron.vite.config.ts', 'vite.config.ts'],
extends: ['plugin:jsdoc/recommended-typescript-error'],
rules: { ...useTsDocRules() },
parserOptions: {
project: './tsconfig.config.json'
}
},
// Tests
{
files: ['src/tests/**/*.ts'],
extends: ['plugin:jsdoc/recommended-typescript-error'],
rules: { ...useTsDocRules() },
parserOptions: {
project: './tsconfig.test.json'
}
}
]
}
})