-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy path.eslintrc.cjs
More file actions
102 lines (102 loc) · 3.86 KB
/
.eslintrc.cjs
File metadata and controls
102 lines (102 loc) · 3.86 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// https://medium.com/weekly-webtips/how-to-sort-imports-like-a-pro-in-typescript-4ee8afd7258a
module.exports = {
env: {
node: true
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'rollup',
'prettier'
],
overrides: [
{
files: ['*.ts', '*.tsx'],
parserOptions: {
project: ['./tsconfig.json']
}
},
{
files: ['**/*.test.ts', '**/test/**/*.ts', 'vitest.config.ts'],
rules: {
'import/no-extraneous-dependencies': 'off', // Test deps (vitest, etc.) are devDependencies
'sort-keys': 'off' // Test objects are ordered for readability, not alphabetically
}
}
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2023,
project: true,
sourceType: 'module'
},
plugins: [
'@stylistic/eslint-plugin-js',
'@typescript-eslint',
'import',
'prettier',
'unused-imports'
],
rules: {
'@typescript-eslint/naming-convention': [
'error',
{ selector: 'default', format: ['camelCase'] },
// Variables: allow snake_case for HA API destructuring, UPPER_CASE/PascalCase for constants
{ selector: 'variable', format: ['camelCase', 'snake_case', 'UPPER_CASE', 'PascalCase'], leadingUnderscore: 'allow' },
// Parameters: allow snake_case (HA API), PascalCase (mixin Base param)
{ selector: 'parameter', format: ['camelCase', 'snake_case', 'PascalCase'], leadingUnderscore: 'allow' },
// Functions: allow PascalCase for mixin factory functions
{ selector: 'function', format: ['camelCase', 'PascalCase'] },
// Methods: allow leading underscore (Lit private method convention)
{ selector: 'method', format: ['camelCase'], leadingUnderscore: 'allow' },
{ selector: 'property', format: null }, // HA API uses snake_case properties
{ selector: 'typeLike', format: ['PascalCase'] },
{ selector: 'enumMember', format: ['PascalCase', 'UPPER_CASE'] },
{ selector: 'import', format: null } // Allow any import naming
],
'@typescript-eslint/no-unused-vars': 'off', // Handled by unused-imports plugin
camelcase: 'off', // Disabled in favor of @typescript-eslint/naming-convention
'class-methods-use-this': 'off', // Lit lifecycle methods don't use this
'import/no-unresolved': 'error',
'import/order': [
'error',
{
alphabetize: {
caseInsensitive: true,
order: 'asc'
},
groups: [
'builtin',
'external',
'internal',
['sibling', 'parent'],
'index',
'unknown'
],
'newlines-between': 'always'
}
],
'no-undefined': 'off', // Allow undefined (used in HA property patterns)
'sort-imports': [
'error',
{
allowSeparatedGroups: true,
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single']
}
],
'unused-imports/no-unused-imports': 'error'
},
settings: {
'import/resolver': {
typescript: {
project: './tsconfig.json'
}
}
}
};