tailwind-typescript-plugin 1.4.1-beta.3 → 1.4.1-beta.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +155 -0
- package/README.md +369 -71
- package/lib/core/interfaces.d.ts +40 -13
- package/lib/core/interfaces.d.ts.map +1 -1
- package/lib/core/types.d.ts +112 -1
- package/lib/core/types.d.ts.map +1 -1
- package/lib/extractors/BaseExtractor.d.ts +56 -3
- package/lib/extractors/BaseExtractor.d.ts.map +1 -1
- package/lib/extractors/BaseExtractor.js +194 -5
- package/lib/extractors/BaseExtractor.js.map +1 -1
- package/lib/extractors/BaseExtractor.spec.d.ts +2 -0
- package/lib/extractors/BaseExtractor.spec.d.ts.map +1 -0
- package/lib/extractors/BaseExtractor.spec.js +421 -0
- package/lib/extractors/BaseExtractor.spec.js.map +1 -0
- package/lib/extractors/CvaExtractor.js +1 -1
- package/lib/extractors/CvaExtractor.js.map +1 -1
- package/lib/extractors/CvaExtractor.spec.d.ts +2 -0
- package/lib/extractors/CvaExtractor.spec.d.ts.map +1 -0
- package/lib/extractors/CvaExtractor.spec.js +1177 -0
- package/lib/extractors/CvaExtractor.spec.js.map +1 -0
- package/lib/extractors/ExpressionExtractor.d.ts.map +1 -1
- package/lib/extractors/ExpressionExtractor.js +35 -5
- package/lib/extractors/ExpressionExtractor.js.map +1 -1
- package/lib/extractors/ExpressionExtractor.spec.d.ts +2 -0
- package/lib/extractors/ExpressionExtractor.spec.d.ts.map +1 -0
- package/lib/extractors/ExpressionExtractor.spec.js +316 -0
- package/lib/extractors/ExpressionExtractor.spec.js.map +1 -0
- package/lib/extractors/JsxAttributeExtractor.d.ts +7 -1
- package/lib/extractors/JsxAttributeExtractor.d.ts.map +1 -1
- package/lib/extractors/JsxAttributeExtractor.js +21 -8
- package/lib/extractors/JsxAttributeExtractor.js.map +1 -1
- package/lib/extractors/JsxAttributeExtractor.spec.d.ts +2 -0
- package/lib/extractors/JsxAttributeExtractor.spec.d.ts.map +1 -0
- package/lib/extractors/JsxAttributeExtractor.spec.js +430 -0
- package/lib/extractors/JsxAttributeExtractor.spec.js.map +1 -0
- package/lib/extractors/TailwindVariantsExtractor.d.ts.map +1 -1
- package/lib/extractors/TailwindVariantsExtractor.js +1 -5
- package/lib/extractors/TailwindVariantsExtractor.js.map +1 -1
- package/lib/extractors/TailwindVariantsExtractor.spec.d.ts +2 -0
- package/lib/extractors/TailwindVariantsExtractor.spec.d.ts.map +1 -0
- package/lib/extractors/TailwindVariantsExtractor.spec.js +1407 -0
- package/lib/extractors/TailwindVariantsExtractor.spec.js.map +1 -0
- package/lib/extractors/TemplateExpressionExtractor.spec.d.ts +2 -0
- package/lib/extractors/TemplateExpressionExtractor.spec.d.ts.map +1 -0
- package/lib/extractors/TemplateExpressionExtractor.spec.js +240 -0
- package/lib/extractors/TemplateExpressionExtractor.spec.js.map +1 -0
- package/lib/extractors/VariableReferenceExtractor.d.ts.map +1 -1
- package/lib/extractors/VariableReferenceExtractor.js +21 -0
- package/lib/extractors/VariableReferenceExtractor.js.map +1 -1
- package/lib/extractors/VariableReferenceExtractor.spec.d.ts +2 -0
- package/lib/extractors/VariableReferenceExtractor.spec.d.ts.map +1 -0
- package/lib/extractors/VariableReferenceExtractor.spec.js +138 -0
- package/lib/extractors/VariableReferenceExtractor.spec.js.map +1 -0
- package/lib/extractors/VueAttributeExtractor.d.ts +202 -0
- package/lib/extractors/VueAttributeExtractor.d.ts.map +1 -0
- package/lib/extractors/VueAttributeExtractor.js +1691 -0
- package/lib/extractors/VueAttributeExtractor.js.map +1 -0
- package/lib/extractors/VueExpressionExtractor.d.ts +34 -0
- package/lib/extractors/VueExpressionExtractor.d.ts.map +1 -0
- package/lib/extractors/VueExpressionExtractor.js +171 -0
- package/lib/extractors/VueExpressionExtractor.js.map +1 -0
- package/lib/infrastructure/TailwindValidator.css-vars.spec.js +1 -11
- package/lib/infrastructure/TailwindValidator.css-vars.spec.js.map +1 -1
- package/lib/infrastructure/TailwindValidator.d.ts +10 -3
- package/lib/infrastructure/TailwindValidator.d.ts.map +1 -1
- package/lib/infrastructure/TailwindValidator.js +68 -28
- package/lib/infrastructure/TailwindValidator.js.map +1 -1
- package/lib/infrastructure/TailwindValidator.spec.js +50 -17
- package/lib/infrastructure/TailwindValidator.spec.js.map +1 -1
- package/lib/plugin/TailwindTypescriptPlugin.d.ts +22 -1
- package/lib/plugin/TailwindTypescriptPlugin.d.ts.map +1 -1
- package/lib/plugin/TailwindTypescriptPlugin.js +133 -50
- package/lib/plugin/TailwindTypescriptPlugin.js.map +1 -1
- package/lib/services/ClassNameExtractionService.d.ts +27 -6
- package/lib/services/ClassNameExtractionService.d.ts.map +1 -1
- package/lib/services/ClassNameExtractionService.js +80 -17
- package/lib/services/ClassNameExtractionService.js.map +1 -1
- package/lib/services/ClassNameExtractionService.spec.d.ts +2 -0
- package/lib/services/ClassNameExtractionService.spec.d.ts.map +1 -0
- package/lib/services/ClassNameExtractionService.spec.js +215 -0
- package/lib/services/ClassNameExtractionService.spec.js.map +1 -0
- package/lib/services/CodeActionService.spec.js +1 -2
- package/lib/services/CodeActionService.spec.js.map +1 -1
- package/lib/services/CompletionService.d.ts +121 -0
- package/lib/services/CompletionService.d.ts.map +1 -0
- package/lib/services/CompletionService.js +573 -0
- package/lib/services/CompletionService.js.map +1 -0
- package/lib/services/CompletionService.spec.d.ts +2 -0
- package/lib/services/CompletionService.spec.d.ts.map +1 -0
- package/lib/services/CompletionService.spec.js +1182 -0
- package/lib/services/CompletionService.spec.js.map +1 -0
- package/lib/services/ConfigSchemaValidator.d.ts +40 -0
- package/lib/services/ConfigSchemaValidator.d.ts.map +1 -0
- package/lib/services/ConfigSchemaValidator.js +139 -0
- package/lib/services/ConfigSchemaValidator.js.map +1 -0
- package/lib/services/ConfigSchemaValidator.spec.d.ts +2 -0
- package/lib/services/ConfigSchemaValidator.spec.d.ts.map +1 -0
- package/lib/services/ConfigSchemaValidator.spec.js +344 -0
- package/lib/services/ConfigSchemaValidator.spec.js.map +1 -0
- package/lib/services/ConflictClassDetection.spec.js +53 -5
- package/lib/services/ConflictClassDetection.spec.js.map +1 -1
- package/lib/services/DiagnosticService.d.ts +8 -8
- package/lib/services/DiagnosticService.d.ts.map +1 -1
- package/lib/services/DiagnosticService.js +29 -13
- package/lib/services/DiagnosticService.js.map +1 -1
- package/lib/services/DiagnosticService.spec.d.ts +2 -0
- package/lib/services/DiagnosticService.spec.d.ts.map +1 -0
- package/lib/services/DiagnosticService.spec.js +259 -0
- package/lib/services/DiagnosticService.spec.js.map +1 -0
- package/lib/services/DuplicateClassDetection.spec.js +20 -21
- package/lib/services/DuplicateClassDetection.spec.js.map +1 -1
- package/lib/services/FileDiagnosticCache.spec.d.ts +2 -0
- package/lib/services/FileDiagnosticCache.spec.d.ts.map +1 -0
- package/lib/services/FileDiagnosticCache.spec.js +213 -0
- package/lib/services/FileDiagnosticCache.spec.js.map +1 -0
- package/lib/services/PerformanceCache.spec.d.ts +2 -0
- package/lib/services/PerformanceCache.spec.d.ts.map +1 -0
- package/lib/services/PerformanceCache.spec.js +168 -0
- package/lib/services/PerformanceCache.spec.js.map +1 -0
- package/lib/services/PluginConfigService.d.ts +66 -15
- package/lib/services/PluginConfigService.d.ts.map +1 -1
- package/lib/services/PluginConfigService.js +230 -73
- package/lib/services/PluginConfigService.js.map +1 -1
- package/lib/services/PluginConfigService.spec.d.ts +2 -0
- package/lib/services/PluginConfigService.spec.d.ts.map +1 -0
- package/lib/services/PluginConfigService.spec.js +93 -0
- package/lib/services/PluginConfigService.spec.js.map +1 -0
- package/lib/services/ValidationService.d.ts +7 -5
- package/lib/services/ValidationService.d.ts.map +1 -1
- package/lib/services/ValidationService.js +40 -43
- package/lib/services/ValidationService.js.map +1 -1
- package/lib/services/ValidationService.spec.d.ts +2 -0
- package/lib/services/ValidationService.spec.d.ts.map +1 -0
- package/lib/services/ValidationService.spec.js +289 -0
- package/lib/services/ValidationService.spec.js.map +1 -0
- package/lib/utils/FrameworkDetector.d.ts +23 -0
- package/lib/utils/FrameworkDetector.d.ts.map +1 -0
- package/lib/utils/FrameworkDetector.js +47 -0
- package/lib/utils/FrameworkDetector.js.map +1 -0
- package/lib/utils/FrameworkDetector.spec.d.ts +2 -0
- package/lib/utils/FrameworkDetector.spec.d.ts.map +1 -0
- package/lib/utils/FrameworkDetector.spec.js +67 -0
- package/lib/utils/FrameworkDetector.spec.js.map +1 -0
- package/package.json +11 -4
- package/lib/extractors/StringLiteralExtractor.d.ts +0 -12
- package/lib/extractors/StringLiteralExtractor.d.ts.map +0 -1
- package/lib/extractors/StringLiteralExtractor.js +0 -21
- package/lib/extractors/StringLiteralExtractor.js.map +0 -1
- package/lib/services/ClassNameExtractionService.original.d.ts +0 -20
- package/lib/services/ClassNameExtractionService.original.d.ts.map +0 -1
- package/lib/services/ClassNameExtractionService.original.js +0 -48
- package/lib/services/ClassNameExtractionService.original.js.map +0 -1
|
@@ -1,102 +1,259 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PluginConfigService = void 0;
|
|
4
|
+
const ConfigSchemaValidator_1 = require("./ConfigSchemaValidator");
|
|
4
5
|
/**
|
|
5
|
-
* Default
|
|
6
|
+
* Default utilities configuration
|
|
7
|
+
* Key is function name, value is import source ("*" = any source, "off" = disabled)
|
|
6
8
|
*/
|
|
7
|
-
const
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
'classnames',
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
const DEFAULT_UTILITIES = {
|
|
10
|
+
cn: '*', // Custom wrapper pattern (e.g., shadcn), any source
|
|
11
|
+
clsx: 'clsx',
|
|
12
|
+
classnames: 'classnames',
|
|
13
|
+
classNames: 'classnames',
|
|
14
|
+
cx: 'classnames',
|
|
15
|
+
twMerge: 'tailwind-merge'
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Default variants configuration
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_VARIANTS = {
|
|
21
|
+
tailwindVariants: true,
|
|
22
|
+
classVarianceAuthority: true
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Default validation configuration
|
|
26
|
+
*/
|
|
27
|
+
const DEFAULT_VALIDATION = {
|
|
28
|
+
enabled: true,
|
|
29
|
+
severity: 'error',
|
|
30
|
+
allowedClasses: []
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Default lint configuration
|
|
34
|
+
*/
|
|
35
|
+
const DEFAULT_LINT = {
|
|
36
|
+
enabled: true,
|
|
37
|
+
conflictingClasses: {
|
|
38
|
+
enabled: true,
|
|
39
|
+
severity: 'warning'
|
|
40
|
+
},
|
|
41
|
+
repeatedClasses: {
|
|
42
|
+
enabled: true,
|
|
43
|
+
severity: 'warning'
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Default class attributes
|
|
48
|
+
* These are the JSX/HTML attributes that will be treated as class attributes
|
|
49
|
+
*/
|
|
50
|
+
const DEFAULT_CLASS_ATTRIBUTES = ['className', 'class', 'classList'];
|
|
17
51
|
/**
|
|
18
52
|
* Service responsible for managing plugin configuration
|
|
19
53
|
* Follows Single Responsibility Principle
|
|
20
54
|
*/
|
|
21
55
|
class PluginConfigService {
|
|
22
|
-
constructor(config
|
|
23
|
-
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
56
|
+
constructor(config) {
|
|
57
|
+
// Validate configuration schema first
|
|
58
|
+
this.schemaValidator = new ConfigSchemaValidator_1.ConfigSchemaValidator();
|
|
59
|
+
this.configValidationResult = this.schemaValidator.validate(config);
|
|
26
60
|
this.cssFilePath = config.globalCss;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.tailwindVariantsEnabled = true;
|
|
42
|
-
this.classVarianceAuthorityEnabled = true;
|
|
43
|
-
}
|
|
44
|
-
this.logExtractorConfig();
|
|
45
|
-
}
|
|
46
|
-
initializeUtilityFunctions(config) {
|
|
47
|
-
if (config.utilityFunctions && Array.isArray(config.utilityFunctions)) {
|
|
48
|
-
// Merge user-provided functions with defaults (remove duplicates)
|
|
49
|
-
const merged = [...new Set([...DEFAULT_UTILITY_FUNCTIONS, ...config.utilityFunctions])];
|
|
50
|
-
this.logger.log(`Using utility functions (defaults + custom): ${merged.join(', ')}`);
|
|
51
|
-
return merged;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
this.logger.log(`Using default utility functions: ${DEFAULT_UTILITY_FUNCTIONS.join(', ')}`);
|
|
55
|
-
return DEFAULT_UTILITY_FUNCTIONS;
|
|
61
|
+
// Initialize configuration with backwards compatibility
|
|
62
|
+
this.utilitiesConfig = this.initializeUtilities(config);
|
|
63
|
+
this.variantsConfig = this.initializeVariants(config);
|
|
64
|
+
this.validationConfig = this.initializeValidation(config);
|
|
65
|
+
this.lintConfig = this.initializeLint(config);
|
|
66
|
+
this.editorConfig = this.initializeEditor(config);
|
|
67
|
+
this.classAttributes = this.initializeClassAttributes(config);
|
|
68
|
+
// Convert to legacy format for extractors
|
|
69
|
+
this.utilityFunctionsLegacy = this.convertToLegacyFormat(this.utilitiesConfig);
|
|
70
|
+
}
|
|
71
|
+
initializeUtilities(config) {
|
|
72
|
+
if (config.libraries?.utilities) {
|
|
73
|
+
// Merge with defaults (user config overrides defaults)
|
|
74
|
+
return { ...DEFAULT_UTILITIES, ...config.libraries.utilities };
|
|
56
75
|
}
|
|
76
|
+
return { ...DEFAULT_UTILITIES };
|
|
57
77
|
}
|
|
58
|
-
|
|
59
|
-
if (config.
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
initializeVariants(config) {
|
|
79
|
+
if (config.libraries?.variants) {
|
|
80
|
+
const userVariants = config.libraries.variants;
|
|
81
|
+
const hasAnyConfig = userVariants.tailwindVariants !== undefined ||
|
|
82
|
+
userVariants.classVarianceAuthority !== undefined;
|
|
83
|
+
if (hasAnyConfig) {
|
|
84
|
+
// User specified at least one - only enable those explicitly set to true
|
|
85
|
+
return {
|
|
86
|
+
tailwindVariants: userVariants.tailwindVariants === true,
|
|
87
|
+
classVarianceAuthority: userVariants.classVarianceAuthority === true
|
|
88
|
+
};
|
|
89
|
+
}
|
|
62
90
|
}
|
|
63
|
-
|
|
64
|
-
|
|
91
|
+
return { ...DEFAULT_VARIANTS };
|
|
92
|
+
}
|
|
93
|
+
initializeValidation(config) {
|
|
94
|
+
const validation = config.validation || {};
|
|
95
|
+
return {
|
|
96
|
+
enabled: validation.enabled !== false, // default true
|
|
97
|
+
severity: validation.severity || DEFAULT_VALIDATION.severity,
|
|
98
|
+
allowedClasses: validation.allowedClasses || []
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
initializeLint(config) {
|
|
102
|
+
const lint = config.lint || {};
|
|
103
|
+
return {
|
|
104
|
+
enabled: lint.enabled !== false, // default true
|
|
105
|
+
conflictingClasses: {
|
|
106
|
+
enabled: lint.conflictingClasses?.enabled !== false, // default true
|
|
107
|
+
severity: lint.conflictingClasses?.severity || DEFAULT_LINT.conflictingClasses.severity
|
|
108
|
+
},
|
|
109
|
+
repeatedClasses: {
|
|
110
|
+
enabled: lint.repeatedClasses?.enabled !== false, // default true
|
|
111
|
+
severity: lint.repeatedClasses?.severity || DEFAULT_LINT.repeatedClasses.severity
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
initializeEditor(config) {
|
|
116
|
+
const editor = config.editor || {};
|
|
117
|
+
return {
|
|
118
|
+
enabled: editor.enabled !== false, // default true
|
|
119
|
+
autocomplete: {
|
|
120
|
+
enabled: editor.autocomplete?.enabled !== false // default true
|
|
121
|
+
},
|
|
122
|
+
hover: {
|
|
123
|
+
enabled: editor.hover?.enabled !== false // default true
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
initializeClassAttributes(config) {
|
|
128
|
+
const userAttributes = config.classAttributes || [];
|
|
129
|
+
// Merge default attributes with user-provided ones
|
|
130
|
+
// Use Set to avoid duplicates
|
|
131
|
+
return [...new Set([...DEFAULT_CLASS_ATTRIBUTES, ...userAttributes])];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Convert new utilities config to legacy UtilityFunction[] format
|
|
135
|
+
* This is needed for backwards compatibility with extractors
|
|
136
|
+
*/
|
|
137
|
+
convertToLegacyFormat(utilities) {
|
|
138
|
+
const result = [];
|
|
139
|
+
for (const [name, source] of Object.entries(utilities)) {
|
|
140
|
+
if (source === 'off') {
|
|
141
|
+
continue; // Skip disabled utilities
|
|
142
|
+
}
|
|
143
|
+
if (source === '*') {
|
|
144
|
+
result.push(name); // Simple string = any source
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
result.push({ name, from: source });
|
|
148
|
+
}
|
|
65
149
|
}
|
|
150
|
+
return result;
|
|
66
151
|
}
|
|
152
|
+
// ---- Getters for utilities ----
|
|
153
|
+
getUtilitiesConfig() {
|
|
154
|
+
return this.utilitiesConfig;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get utility functions in legacy format (for extractors)
|
|
158
|
+
*/
|
|
67
159
|
getUtilityFunctions() {
|
|
68
|
-
return this.
|
|
160
|
+
return this.utilityFunctionsLegacy;
|
|
161
|
+
}
|
|
162
|
+
// ---- Getters for variants ----
|
|
163
|
+
getVariantsConfig() {
|
|
164
|
+
return this.variantsConfig;
|
|
165
|
+
}
|
|
166
|
+
isTailwindVariantsEnabled() {
|
|
167
|
+
return this.variantsConfig.tailwindVariants === true;
|
|
168
|
+
}
|
|
169
|
+
isClassVarianceAuthorityEnabled() {
|
|
170
|
+
return this.variantsConfig.classVarianceAuthority === true;
|
|
171
|
+
}
|
|
172
|
+
// ---- Getters for validation ----
|
|
173
|
+
getValidationConfig() {
|
|
174
|
+
return this.validationConfig;
|
|
175
|
+
}
|
|
176
|
+
isValidationEnabled() {
|
|
177
|
+
return this.validationConfig.enabled;
|
|
178
|
+
}
|
|
179
|
+
getValidationSeverity() {
|
|
180
|
+
return this.validationConfig.severity;
|
|
181
|
+
}
|
|
182
|
+
getAllowedClasses() {
|
|
183
|
+
return this.validationConfig.allowedClasses;
|
|
184
|
+
}
|
|
185
|
+
// ---- Getters for lint ----
|
|
186
|
+
getLintConfig() {
|
|
187
|
+
return this.lintConfig;
|
|
188
|
+
}
|
|
189
|
+
isLintEnabled() {
|
|
190
|
+
return this.lintConfig.enabled !== false;
|
|
191
|
+
}
|
|
192
|
+
isConflictingClassesEnabled() {
|
|
193
|
+
return this.isLintEnabled() && this.lintConfig.conflictingClasses?.enabled !== false;
|
|
194
|
+
}
|
|
195
|
+
getConflictingClassesSeverity() {
|
|
196
|
+
return this.lintConfig.conflictingClasses?.severity || 'warning';
|
|
197
|
+
}
|
|
198
|
+
isRepeatedClassesEnabled() {
|
|
199
|
+
return this.isLintEnabled() && this.lintConfig.repeatedClasses?.enabled !== false;
|
|
200
|
+
}
|
|
201
|
+
getRepeatedClassesSeverity() {
|
|
202
|
+
return this.lintConfig.repeatedClasses?.severity || 'warning';
|
|
69
203
|
}
|
|
204
|
+
// ---- Getters for editor ----
|
|
205
|
+
getEditorConfig() {
|
|
206
|
+
return this.editorConfig;
|
|
207
|
+
}
|
|
208
|
+
isEditorEnabled() {
|
|
209
|
+
return this.editorConfig.enabled !== false;
|
|
210
|
+
}
|
|
211
|
+
isAutocompleteEnabled() {
|
|
212
|
+
return this.isEditorEnabled() && this.editorConfig.autocomplete?.enabled !== false;
|
|
213
|
+
}
|
|
214
|
+
isHoverEnabled() {
|
|
215
|
+
return this.isEditorEnabled() && this.editorConfig.hover?.enabled !== false;
|
|
216
|
+
}
|
|
217
|
+
// ---- Getters for global settings ----
|
|
70
218
|
getCssFilePath() {
|
|
71
219
|
return this.cssFilePath;
|
|
72
220
|
}
|
|
73
221
|
hasValidCssPath() {
|
|
74
222
|
return this.cssFilePath !== undefined && this.cssFilePath.length > 0;
|
|
75
223
|
}
|
|
76
|
-
|
|
77
|
-
|
|
224
|
+
// ---- Getters for class attributes ----
|
|
225
|
+
/**
|
|
226
|
+
* Get the configured class attributes
|
|
227
|
+
* Returns an array of attribute names that should be treated as class attributes
|
|
228
|
+
* Includes default attributes (className, class, classList) plus user-configured ones
|
|
229
|
+
*/
|
|
230
|
+
getClassAttributes() {
|
|
231
|
+
return this.classAttributes;
|
|
78
232
|
}
|
|
79
|
-
|
|
80
|
-
|
|
233
|
+
// ---- Configuration validation ----
|
|
234
|
+
/**
|
|
235
|
+
* Check if the configuration is valid according to the schema
|
|
236
|
+
*/
|
|
237
|
+
isConfigValid() {
|
|
238
|
+
return this.configValidationResult.valid;
|
|
81
239
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return this.
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
240
|
+
/**
|
|
241
|
+
* Get configuration validation errors
|
|
242
|
+
*/
|
|
243
|
+
getConfigValidationErrors() {
|
|
244
|
+
return this.configValidationResult.errors;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Get formatted validation error messages
|
|
248
|
+
*/
|
|
249
|
+
getFormattedConfigErrors() {
|
|
250
|
+
return this.schemaValidator.formatErrors(this.configValidationResult.errors);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get a summary of all validation errors for logging
|
|
254
|
+
*/
|
|
255
|
+
getConfigErrorSummary() {
|
|
256
|
+
return this.schemaValidator.getErrorSummary(this.configValidationResult.errors);
|
|
100
257
|
}
|
|
101
258
|
}
|
|
102
259
|
exports.PluginConfigService = PluginConfigService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginConfigService.js","sourceRoot":"","sources":["../../src/services/PluginConfigService.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PluginConfigService.js","sourceRoot":"","sources":["../../src/services/PluginConfigService.ts"],"names":[],"mappings":";;;AAUA,mEAIiC;AAEjC;;;GAGG;AACH,MAAM,iBAAiB,GAAoB;IAC1C,EAAE,EAAE,GAAG,EAAE,oDAAoD;IAC7D,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,EAAE,EAAE,YAAY;IAChB,OAAO,EAAE,gBAAgB;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,gBAAgB,GAAmB;IACxC,gBAAgB,EAAE,IAAI;IACtB,sBAAsB,EAAE,IAAI;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,kBAAkB,GAEpB;IACH,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,OAAO;IACjB,cAAc,EAAE,EAAE;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,YAAY,GAAe;IAChC,OAAO,EAAE,IAAI;IACb,kBAAkB,EAAE;QACnB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,SAAS;KACnB;IACD,eAAe,EAAE;QAChB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,SAAS;KACnB;CACD,CAAC;AAEF;;;GAGG;AACH,MAAM,wBAAwB,GAAG,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;AAErE;;;GAGG;AACH,MAAa,mBAAmB;IAkB/B,YAAY,MAAqB;QAChC,sCAAsC;QACtC,IAAI,CAAC,eAAe,GAAG,IAAI,6CAAqB,EAAE,CAAC;QACnD,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;Q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I,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,KAAK,KAAK,CAAC;IACpF,CAAC;IAED,cAAc;QACb,OAAO,IAAI,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,CAAC;IAC7E,CAAC;IAED,wCAAwC;IAExC,cAAc;QACb,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED,eAAe;QACd,OAAO,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;IACtE,CAAC;IAED,yCAAyC;IAEzC;;;;OAIG;IACH,kBAAkB;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;IAED,qCAAqC;IAErC;;OAEG;IACH,aAAa;QACZ,OAAO,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,yBAAyB;QACxB,OAAO,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,wBAAwB;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC9E,CAAC;IAED;;OAEG;IACH,qBAAqB;QACpB,OAAO,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACjF,CAAC;CACD;AArRD,kDAqRC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginConfigService.spec.d.ts","sourceRoot":"","sources":["../../src/services/PluginConfigService.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const PluginConfigService_1 = require("./PluginConfigService");
|
|
4
|
+
describe('PluginConfigService', () => {
|
|
5
|
+
describe('classAttributes', () => {
|
|
6
|
+
it('should return default class attributes when not configured', () => {
|
|
7
|
+
const service = new PluginConfigService_1.PluginConfigService({});
|
|
8
|
+
const classAttributes = service.getClassAttributes();
|
|
9
|
+
expect(classAttributes).toContain('className');
|
|
10
|
+
expect(classAttributes).toContain('class');
|
|
11
|
+
expect(classAttributes).toContain('classList');
|
|
12
|
+
expect(classAttributes).toHaveLength(3);
|
|
13
|
+
});
|
|
14
|
+
it('should merge user attributes with defaults', () => {
|
|
15
|
+
const service = new PluginConfigService_1.PluginConfigService({
|
|
16
|
+
classAttributes: ['colorStyles', 'textStyles']
|
|
17
|
+
});
|
|
18
|
+
const classAttributes = service.getClassAttributes();
|
|
19
|
+
expect(classAttributes).toContain('className');
|
|
20
|
+
expect(classAttributes).toContain('class');
|
|
21
|
+
expect(classAttributes).toContain('classList');
|
|
22
|
+
expect(classAttributes).toContain('colorStyles');
|
|
23
|
+
expect(classAttributes).toContain('textStyles');
|
|
24
|
+
expect(classAttributes).toHaveLength(5);
|
|
25
|
+
});
|
|
26
|
+
it('should deduplicate attributes when user provides defaults', () => {
|
|
27
|
+
const service = new PluginConfigService_1.PluginConfigService({
|
|
28
|
+
classAttributes: ['className', 'colorStyles', 'class']
|
|
29
|
+
});
|
|
30
|
+
const classAttributes = service.getClassAttributes();
|
|
31
|
+
// Should not have duplicates
|
|
32
|
+
const uniqueAttributes = [...new Set(classAttributes)];
|
|
33
|
+
expect(classAttributes).toHaveLength(uniqueAttributes.length);
|
|
34
|
+
// Should contain all expected attributes
|
|
35
|
+
expect(classAttributes).toContain('className');
|
|
36
|
+
expect(classAttributes).toContain('class');
|
|
37
|
+
expect(classAttributes).toContain('classList');
|
|
38
|
+
expect(classAttributes).toContain('colorStyles');
|
|
39
|
+
});
|
|
40
|
+
it('should handle empty user attributes array', () => {
|
|
41
|
+
const service = new PluginConfigService_1.PluginConfigService({
|
|
42
|
+
classAttributes: []
|
|
43
|
+
});
|
|
44
|
+
const classAttributes = service.getClassAttributes();
|
|
45
|
+
expect(classAttributes).toContain('className');
|
|
46
|
+
expect(classAttributes).toContain('class');
|
|
47
|
+
expect(classAttributes).toContain('classList');
|
|
48
|
+
expect(classAttributes).toHaveLength(3);
|
|
49
|
+
});
|
|
50
|
+
it('should preserve order with defaults first', () => {
|
|
51
|
+
const service = new PluginConfigService_1.PluginConfigService({
|
|
52
|
+
classAttributes: ['colorStyles']
|
|
53
|
+
});
|
|
54
|
+
const classAttributes = service.getClassAttributes();
|
|
55
|
+
// Default attributes should come first
|
|
56
|
+
expect(classAttributes[0]).toBe('className');
|
|
57
|
+
expect(classAttributes[1]).toBe('class');
|
|
58
|
+
expect(classAttributes[2]).toBe('classList');
|
|
59
|
+
expect(classAttributes[3]).toBe('colorStyles');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('other configurations', () => {
|
|
63
|
+
it('should initialize with default utilities', () => {
|
|
64
|
+
const service = new PluginConfigService_1.PluginConfigService({});
|
|
65
|
+
const utilities = service.getUtilityFunctions();
|
|
66
|
+
expect(utilities).toContainEqual('cn');
|
|
67
|
+
expect(utilities).toContainEqual({ name: 'clsx', from: 'clsx' });
|
|
68
|
+
});
|
|
69
|
+
it('should enable variants by default', () => {
|
|
70
|
+
const service = new PluginConfigService_1.PluginConfigService({});
|
|
71
|
+
expect(service.isTailwindVariantsEnabled()).toBe(true);
|
|
72
|
+
expect(service.isClassVarianceAuthorityEnabled()).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
it('should enable validation by default', () => {
|
|
75
|
+
const service = new PluginConfigService_1.PluginConfigService({});
|
|
76
|
+
expect(service.isValidationEnabled()).toBe(true);
|
|
77
|
+
expect(service.getValidationSeverity()).toBe('error');
|
|
78
|
+
});
|
|
79
|
+
it('should enable lint by default', () => {
|
|
80
|
+
const service = new PluginConfigService_1.PluginConfigService({});
|
|
81
|
+
expect(service.isLintEnabled()).toBe(true);
|
|
82
|
+
expect(service.isConflictingClassesEnabled()).toBe(true);
|
|
83
|
+
expect(service.isRepeatedClassesEnabled()).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
it('should enable editor features by default', () => {
|
|
86
|
+
const service = new PluginConfigService_1.PluginConfigService({});
|
|
87
|
+
expect(service.isEditorEnabled()).toBe(true);
|
|
88
|
+
expect(service.isAutocompleteEnabled()).toBe(true);
|
|
89
|
+
expect(service.isHoverEnabled()).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=PluginConfigService.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginConfigService.spec.js","sourceRoot":"","sources":["../../src/services/PluginConfigService.spec.ts"],"names":[],"mappings":";;AAAA,+DAA4D;AAE5D,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACpC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;YACrE,MAAM,OAAO,GAAG,IAAI,yCAAmB,CAAC,EAAE,CAAC,CAAC;YAE5C,MAAM,eAAe,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;YAErD,MAAM,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAC/C,MAAM,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAC3C,MAAM,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAC/C,MAAM,CAAC,eAAe,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;YACrD,MAAM,OAAO,GAAG,IAAI,yCAAmB,CAAC;gBACvC,eAAe,EAAE,CAAC,aAAa,EAAE,YAAY,CAAC;aAC9C,CAAC,CAAC;YAEH,MAAM,eAAe,GAAG,OAAO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AAE,GAAG,EAAE;YACnD,MAAM,OAAO,GAAG,IAAI,yCAAmB,CAAC,EAAE,CAAC,CAAC;YAE5C,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7C,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnD,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
2
|
import { IClassNameValidator } from '../core/interfaces';
|
|
3
|
+
import { UtilityFunction } from '../core/types';
|
|
3
4
|
import { ICssProvider } from '../infrastructure/TailwindConflictDetector';
|
|
4
|
-
import { Logger } from '../utils/Logger';
|
|
5
5
|
import { ClassNameExtractionService } from './ClassNameExtractionService';
|
|
6
6
|
import { DiagnosticService } from './DiagnosticService';
|
|
7
|
+
import { PluginConfigService } from './PluginConfigService';
|
|
7
8
|
/**
|
|
8
9
|
* Service responsible for validating class names and creating diagnostics
|
|
9
10
|
* Orchestrates the validation workflow
|
|
@@ -12,21 +13,22 @@ export declare class ValidationService {
|
|
|
12
13
|
private readonly extractionService;
|
|
13
14
|
private readonly diagnosticService;
|
|
14
15
|
private readonly validator;
|
|
15
|
-
private readonly
|
|
16
|
+
private readonly configService;
|
|
16
17
|
private readonly conflictDetector;
|
|
17
|
-
constructor(extractionService: ClassNameExtractionService, diagnosticService: DiagnosticService, validator: IClassNameValidator,
|
|
18
|
+
constructor(extractionService: ClassNameExtractionService, diagnosticService: DiagnosticService, validator: IClassNameValidator, configService: PluginConfigService, cssProvider?: ICssProvider);
|
|
18
19
|
/**
|
|
19
20
|
* Validate a source file and return diagnostics
|
|
20
21
|
* PERFORMANCE OPTIMIZED: Minimal logging overhead
|
|
21
22
|
*/
|
|
22
|
-
validateFile(typescript: typeof ts, sourceFile: ts.SourceFile, utilityFunctions:
|
|
23
|
+
validateFile(typescript: typeof ts, sourceFile: ts.SourceFile, utilityFunctions: UtilityFunction[], typeChecker?: ts.TypeChecker): ts.Diagnostic[];
|
|
23
24
|
/**
|
|
24
25
|
* Filter out valid classes and return only invalid ones
|
|
25
26
|
* PERFORMANCE OPTIMIZED: No logging in hot path
|
|
26
27
|
*/
|
|
27
28
|
private filterInvalidClasses;
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
30
|
+
* Find duplicate and extractable classes within the same attribute
|
|
31
|
+
* Returns true duplicates and extractable classes (same class in both ternary branches)
|
|
30
32
|
*/
|
|
31
33
|
private findDuplicateClasses;
|
|
32
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationService.d.ts","sourceRoot":"","sources":["../../src/services/ValidationService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ValidationService.d.ts","sourceRoot":"","sources":["../../src/services/ValidationService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAiB,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,YAAY,EAA4B,MAAM,4CAA4C,CAAC;AACpG,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;GAGG;AACH,qBAAa,iBAAiB;IAI5B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAN/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA2B;gBAG1C,iBAAiB,EAAE,0BAA0B,EAC7C,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,mBAAmB,EAC9B,aAAa,EAAE,mBAAmB,EACnD,WAAW,CAAC,EAAE,YAAY;IAQ3B;;;OAGG;IACH,YAAY,CACX,UAAU,EAAE,OAAO,EAAE,EACrB,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,gBAAgB,EAAE,eAAe,EAAE,EACnC,WAAW,CAAC,EAAE,EAAE,CAAC,WAAW,GAC1B,EAAE,CAAC,UAAU,EAAE;IA6ElB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;CAiG5B"}
|
|
@@ -7,11 +7,11 @@ const TailwindConflictDetector_1 = require("../infrastructure/TailwindConflictDe
|
|
|
7
7
|
* Orchestrates the validation workflow
|
|
8
8
|
*/
|
|
9
9
|
class ValidationService {
|
|
10
|
-
constructor(extractionService, diagnosticService, validator,
|
|
10
|
+
constructor(extractionService, diagnosticService, validator, configService, cssProvider) {
|
|
11
11
|
this.extractionService = extractionService;
|
|
12
12
|
this.diagnosticService = diagnosticService;
|
|
13
13
|
this.validator = validator;
|
|
14
|
-
this.
|
|
14
|
+
this.configService = configService;
|
|
15
15
|
this.conflictDetector = new TailwindConflictDetector_1.TailwindConflictDetector();
|
|
16
16
|
if (cssProvider) {
|
|
17
17
|
this.conflictDetector.setCssProvider(cssProvider);
|
|
@@ -23,50 +23,48 @@ class ValidationService {
|
|
|
23
23
|
*/
|
|
24
24
|
validateFile(typescript, sourceFile, utilityFunctions, typeChecker) {
|
|
25
25
|
if (!this.validator.isInitialized()) {
|
|
26
|
-
this.logger.log(`[ValidationService] Validator not initialized yet for ${sourceFile.fileName}`);
|
|
27
26
|
return [];
|
|
28
27
|
}
|
|
29
|
-
// PERFORMANCE: Only log if enabled
|
|
30
|
-
if (this.logger.isEnabled()) {
|
|
31
|
-
this.logger.log(`[ValidationService] Processing file: ${sourceFile.fileName}`);
|
|
32
|
-
}
|
|
33
28
|
// Extract all class names from the file
|
|
34
|
-
const classNames = this.extractionService.extractFromSourceFile(typescript, sourceFile, utilityFunctions, typeChecker);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
const classNames = this.extractionService.extractFromSourceFile(typescript, sourceFile, utilityFunctions, typeChecker, this.configService.getClassAttributes());
|
|
30
|
+
const diagnostics = [];
|
|
31
|
+
// Validation diagnostics (invalid class detection)
|
|
32
|
+
if (this.configService.isValidationEnabled()) {
|
|
33
|
+
const severity = this.configService.getValidationSeverity();
|
|
34
|
+
if (severity !== 'off') {
|
|
35
|
+
const invalidClasses = this.filterInvalidClasses(classNames);
|
|
36
|
+
if (invalidClasses.length > 0) {
|
|
37
|
+
diagnostics.push(...this.diagnosticService.createDiagnostics(invalidClasses, sourceFile, severity));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (totalIssues > 0) {
|
|
52
|
-
this.logger.log(`[ValidationService] Returning ${invalidClasses.length} invalid + ${trueDuplicates.length} duplicate + ${extractableClasses.length} extractable + ${conflicts.length} conflict diagnostics`);
|
|
41
|
+
// Lint diagnostics (only if lint is enabled globally)
|
|
42
|
+
if (this.configService.isLintEnabled()) {
|
|
43
|
+
// Detect duplicate and extractable classes
|
|
44
|
+
const { trueDuplicates, extractableClasses } = this.findDuplicateClasses(classNames);
|
|
45
|
+
// Repeated classes
|
|
46
|
+
if (this.configService.isRepeatedClassesEnabled()) {
|
|
47
|
+
const severity = this.configService.getRepeatedClassesSeverity();
|
|
48
|
+
if (severity !== 'off') {
|
|
49
|
+
if (trueDuplicates.length > 0) {
|
|
50
|
+
diagnostics.push(...this.diagnosticService.createDuplicateDiagnostics(trueDuplicates, sourceFile, severity));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
// Extractable classes (always enabled when lint is enabled, no config option)
|
|
55
|
+
if (extractableClasses.length > 0) {
|
|
56
|
+
diagnostics.push(...this.diagnosticService.createExtractableClassDiagnostics(extractableClasses, sourceFile));
|
|
57
|
+
}
|
|
58
|
+
// Conflicting classes
|
|
59
|
+
if (this.configService.isConflictingClassesEnabled()) {
|
|
60
|
+
const severity = this.configService.getConflictingClassesSeverity();
|
|
61
|
+
if (severity !== 'off') {
|
|
62
|
+
const conflicts = this.conflictDetector.findConflicts(classNames);
|
|
63
|
+
if (conflicts.length > 0) {
|
|
64
|
+
diagnostics.push(...this.diagnosticService.createConflictDiagnostics(conflicts, sourceFile, severity));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
56
67
|
}
|
|
57
|
-
}
|
|
58
|
-
const diagnostics = [];
|
|
59
|
-
if (invalidClasses.length > 0) {
|
|
60
|
-
diagnostics.push(...this.diagnosticService.createDiagnostics(invalidClasses, sourceFile));
|
|
61
|
-
}
|
|
62
|
-
if (trueDuplicates.length > 0) {
|
|
63
|
-
diagnostics.push(...this.diagnosticService.createDuplicateDiagnostics(trueDuplicates, sourceFile));
|
|
64
|
-
}
|
|
65
|
-
if (extractableClasses.length > 0) {
|
|
66
|
-
diagnostics.push(...this.diagnosticService.createExtractableClassDiagnostics(extractableClasses, sourceFile));
|
|
67
|
-
}
|
|
68
|
-
if (conflicts.length > 0) {
|
|
69
|
-
diagnostics.push(...this.diagnosticService.createConflictDiagnostics(conflicts, sourceFile));
|
|
70
68
|
}
|
|
71
69
|
return diagnostics;
|
|
72
70
|
}
|
|
@@ -75,12 +73,11 @@ class ValidationService {
|
|
|
75
73
|
* PERFORMANCE OPTIMIZED: No logging in hot path
|
|
76
74
|
*/
|
|
77
75
|
filterInvalidClasses(classNames) {
|
|
78
|
-
// PERFORMANCE: Skip logging each class validation (hot path)
|
|
79
|
-
// This method is called for every class in every file
|
|
80
76
|
return classNames.filter(classInfo => !this.validator.isValidClass(classInfo.className));
|
|
81
77
|
}
|
|
82
78
|
/**
|
|
83
|
-
*
|
|
79
|
+
* Find duplicate and extractable classes within the same attribute
|
|
80
|
+
* Returns true duplicates and extractable classes (same class in both ternary branches)
|
|
84
81
|
*/
|
|
85
82
|
findDuplicateClasses(classNames) {
|
|
86
83
|
const trueDuplicates = [];
|