Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
87 lines (84 loc) · 2.33 KB
/
Copy patheslint.config.js
File metadata and controls
87 lines (84 loc) · 2.33 KB
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
import metarhia from 'eslint-config-metarhia';
const files = [
'frontend/**/*.{js,jsx,cjs}',
'*.config.js',
'.dependency-cruiser.cjs',
'eslint.config.js',
];
const jsxReferences = {
meta: { schema: [] },
create: (context) => ({
JSXOpeningElement: (node) => {
let name = node.name;
const isMember = name.type === 'JSXMemberExpression';
while (name.type === 'JSXMemberExpression') name = name.object;
if (
name.type === 'JSXIdentifier' &&
(isMember || /^[A-Z]/u.test(name.name))
) {
context.sourceCode.markVariableAsUsed(name.name, node);
}
},
}),
};
export default [
...metarhia.map((config) => ({ ...config, files })),
{
files: ['**/*.{js,jsx}'],
languageOptions: {
sourceType: 'module',
parserOptions: { ecmaFeatures: { jsx: true } },
},
},
{
files: ['frontend/renderer/**/*.{js,jsx}'],
languageOptions: {
globals: {
window: 'readonly',
document: 'readonly',
navigator: 'readonly',
HTMLElement: 'readonly',
localStorage: 'readonly',
ResizeObserver: 'readonly',
requestAnimationFrame: 'readonly',
cancelAnimationFrame: 'readonly',
getComputedStyle: 'readonly',
},
},
plugins: { jsx: { rules: { references: jsxReferences } } },
rules: {
'jsx/references': 'error',
// Effects may return a cleanup function or an explicit undefined.
'consistent-return': ['error', { treatUndefinedAsUnspecified: false }],
},
},
{
files,
rules: {
camelcase: ['error', { properties: 'never' }],
'func-style': ['error', 'expression'],
'no-restricted-syntax': [
'error',
{
selector:
'FunctionExpression[generator=false]' +
':not(MethodDefinition > FunctionExpression)' +
':not(Property[method=true] > FunctionExpression)' +
':not(AssignmentExpression[left.type=MemberExpression]' +
' > FunctionExpression)',
message: 'Use an arrow function for a context-free function.',
},
],
'no-extra-parens': 'off',
'max-len': [
'error',
{
code: 80,
ignoreUrls: true,
ignoreRegExpLiterals: true,
ignorePattern: '^\\s*(?:import\\s|test\\()',
},
],
},
},
];