-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eslintrc.cjs
119 lines (117 loc) · 3.27 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
/**
* @type {import('eslint').Linter.LegacyConfig}
*/
module.exports = {
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'@electron-toolkit/eslint-config-ts/recommended',
'@electron-toolkit/eslint-config-prettier',
],
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.web.json'],
},
plugins: ['@typescript-eslint', 'unicorn'],
settings: {
react: {
version: 'detect',
},
},
rules: {
/*
* Forbids importing the un-typed IPC.
* Use the ones in src/ipc instead.
*/
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'electron',
importNames: ['ipcMain', 'ipcRenderer'],
message: '\nUse the imports from @/shared/ipc instead',
},
],
patterns: [
{
group: ['*/private*'],
message:
'\nAvoid using private exports. They usually are related to implementation details.\n' +
'Import only the ones provided by the parent folder',
},
{
group: ['*i18next*'],
message: '\nPlease use the provided @/shared/i18n instead',
},
],
},
],
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
'unicorn/filename-case': ['error', { case: 'kebabCase' }],
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/naming-convention.md
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
},
// destructured variables come from other places so no format is enforced
{
selector: 'variable',
modifiers: ['destructured'],
format: null,
},
// imports also come from other places so no format is enforced
{
selector: 'import',
format: null,
},
// Constants can also be camelCase apart from UPPER_CASE
{
selector: 'variable',
modifiers: ['const'],
format: ['UPPER_CASE', 'camelCase'],
},
// functions defined as constants should have the same format as functions
{
selector: 'variable',
types: ['function'],
format: ['camelCase', 'PascalCase'],
},
// functions can be:
// - regular functions (camelCase)
// - functional components (PascalCase)
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
// type definitions (class, interface, typeAlias, enum, typeParameter)
// should be PascalCase
{
selector: 'typeLike',
format: ['PascalCase'],
},
// each member of an enum (const-like) should be UPPER_CASE
{
selector: 'enumMember',
format: ['UPPER_CASE'],
},
{
// Ignore properties that require quotes
selector: [
'classProperty',
'objectLiteralProperty',
'typeProperty',
'classMethod',
'objectLiteralMethod',
'typeMethod',
'accessor',
'enumMember',
],
format: null,
modifiers: ['requiresQuotes'],
},
],
},
};