tailwind-lint 0.5.1 → 0.6.1
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/README.md +5 -3
- package/dist/cli.cjs +1 -1
- package/dist/{linter-B1HK1nl2.cjs → linter-DVb9soAi.cjs} +31 -7
- package/dist/linter.cjs +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -48,9 +48,11 @@ tailwind-lint --verbose
|
|
|
48
48
|
### How Auto-Discovery Works
|
|
49
49
|
|
|
50
50
|
**Tailwind CSS v4:**
|
|
51
|
-
- Finds CSS config files: `app.css`, `
|
|
51
|
+
- Finds CSS config files in common locations: `app.css`, `index.css`, `tailwind.css`, `global.css`, etc.
|
|
52
|
+
- Searches in project root and subdirectories: `./`, `./src/`, `./src/styles/`, `./app/`, etc.
|
|
52
53
|
- Uses file patterns from `@source` directives if present
|
|
53
|
-
- Falls back to default pattern: `./**/*.{js,jsx,ts,tsx,html}`
|
|
54
|
+
- Falls back to default pattern: `./**/*.{js,jsx,ts,tsx,html,vue,svelte,astro,mdx}`
|
|
55
|
+
- **Note:** When CSS config is in a subdirectory (e.g., `src/styles/global.css`), files are discovered from the project root
|
|
54
56
|
|
|
55
57
|
**Tailwind CSS v3:**
|
|
56
58
|
- Finds JavaScript config files: `tailwind.config.js`, `tailwind.config.cjs`, `tailwind.config.mjs`, `tailwind.config.ts`
|
|
@@ -126,7 +128,7 @@ Files are written atomically with multiple iterations to ensure all fixes are ap
|
|
|
126
128
|
## Features
|
|
127
129
|
|
|
128
130
|
**Core (v3 & v4):**
|
|
129
|
-
- CSS Conflicts - Detects when multiple classes apply the same CSS properties
|
|
131
|
+
- CSS Conflicts - Detects when multiple classes apply the same CSS properties (e.g., `block flex`, `text-left text-center`) - **Note:** Works reliably in v4, limited support in v3 - no autofix
|
|
130
132
|
- Invalid @apply Usage - Validates if a class can be used with `@apply`
|
|
131
133
|
- Invalid @screen References - Detects references to non-existent breakpoints
|
|
132
134
|
- Invalid Config Paths - Validates references in `config()` and `theme()` functions
|
package/dist/cli.cjs
CHANGED
|
@@ -36,6 +36,8 @@ let vscode_languageserver_textdocument = require("vscode-languageserver-textdocu
|
|
|
36
36
|
let node_module = require("node:module");
|
|
37
37
|
let node_fs = require("node:fs");
|
|
38
38
|
node_fs = __toESM(node_fs);
|
|
39
|
+
let postcss = require("postcss");
|
|
40
|
+
postcss = __toESM(postcss);
|
|
39
41
|
|
|
40
42
|
//#region src/constants.ts
|
|
41
43
|
const DEFAULT_IGNORE_PATTERNS = [
|
|
@@ -51,7 +53,7 @@ const DEFAULT_IGNORE_PATTERNS = [
|
|
|
51
53
|
"**/.cache/**",
|
|
52
54
|
"**/.DS_Store/**"
|
|
53
55
|
];
|
|
54
|
-
const DEFAULT_FILE_PATTERN = "./**/*.{js,jsx,ts,tsx,html}";
|
|
56
|
+
const DEFAULT_FILE_PATTERN = "./**/*.{js,jsx,ts,tsx,html,vue,svelte,astro,mdx}";
|
|
55
57
|
const V3_CONFIG_PATHS = [
|
|
56
58
|
"tailwind.config.js",
|
|
57
59
|
"tailwind.config.cjs",
|
|
@@ -216,6 +218,7 @@ function createEditorState(cwd) {
|
|
|
216
218
|
const settings = {
|
|
217
219
|
editor: { tabSize: DEFAULT_TAB_SIZE },
|
|
218
220
|
tailwindCSS: {
|
|
221
|
+
validate: true,
|
|
219
222
|
inspectPort: null,
|
|
220
223
|
emmetCompletions: false,
|
|
221
224
|
includeLanguages: {},
|
|
@@ -235,7 +238,6 @@ function createEditorState(cwd) {
|
|
|
235
238
|
hovers: true,
|
|
236
239
|
codeLens: false,
|
|
237
240
|
suggestions: true,
|
|
238
|
-
validate: true,
|
|
239
241
|
colorDecorators: true,
|
|
240
242
|
rootFontSize: DEFAULT_ROOT_FONT_SIZE,
|
|
241
243
|
showPixelEquivalents: true,
|
|
@@ -332,6 +334,19 @@ async function loadV3ClassMetadata(state, cwd, verbose = false) {
|
|
|
332
334
|
} };
|
|
333
335
|
}
|
|
334
336
|
extractConfigMetadata(state);
|
|
337
|
+
if (!state.classNames) state.classNames = {
|
|
338
|
+
context: {},
|
|
339
|
+
classNames: {}
|
|
340
|
+
};
|
|
341
|
+
if (state.modules?.jit?.createContext && state.config) try {
|
|
342
|
+
state.jitContext = state.modules.jit.createContext.module(state.config);
|
|
343
|
+
if (verbose) console.log(chalk.default.dim(" ✓ Created JIT context"));
|
|
344
|
+
} catch (contextError) {
|
|
345
|
+
if (verbose) {
|
|
346
|
+
const message = contextError instanceof Error ? contextError.message : String(contextError);
|
|
347
|
+
console.log(chalk.default.yellow(` ⚠ Warning: Could not create JIT context: ${message}`));
|
|
348
|
+
}
|
|
349
|
+
}
|
|
335
350
|
} catch (error) {
|
|
336
351
|
if (error instanceof Error) throw new AdapterLoadError("v3", error);
|
|
337
352
|
throw new Error(`Failed to load v3 class metadata: ${String(error)}`);
|
|
@@ -426,11 +441,15 @@ async function loadV4DesignSystem(state, cwd, configPath, verbose = false) {
|
|
|
426
441
|
Object.assign(designSystem, {
|
|
427
442
|
dependencies: () => /* @__PURE__ */ new Set(),
|
|
428
443
|
compile(classes) {
|
|
429
|
-
|
|
430
|
-
if (
|
|
431
|
-
|
|
432
|
-
|
|
444
|
+
if (designSystem.candidatesToCss) return designSystem.candidatesToCss(classes).map((result) => {
|
|
445
|
+
if (typeof result === "string" && result.length > 0) try {
|
|
446
|
+
return postcss.default.parse(result);
|
|
447
|
+
} catch {
|
|
448
|
+
return postcss.default.root();
|
|
449
|
+
}
|
|
450
|
+
return postcss.default.root();
|
|
433
451
|
});
|
|
452
|
+
return classes.map(() => postcss.default.root());
|
|
434
453
|
}
|
|
435
454
|
});
|
|
436
455
|
state.designSystem = designSystem;
|
|
@@ -564,6 +583,7 @@ async function validateDocument(state, filePath, content) {
|
|
|
564
583
|
} catch (error) {
|
|
565
584
|
const message = error instanceof Error ? error.message : String(error);
|
|
566
585
|
if (message.includes("Cannot read") || message.includes("undefined")) {
|
|
586
|
+
if (process.env.DEBUG) console.error(`Debug: Language service error for ${filePath}:`, error);
|
|
567
587
|
console.warn(`Warning: Language service crashed while validating ${filePath}. Skipping this file.`);
|
|
568
588
|
return [];
|
|
569
589
|
}
|
|
@@ -591,8 +611,12 @@ async function discoverFilesFromConfig(cwd, configPath) {
|
|
|
591
611
|
if (patterns.length === 0) throw new Error("No content patterns found in Tailwind config.\nEnsure your config has a content array with file patterns.");
|
|
592
612
|
return expandPatterns(cwd, patterns);
|
|
593
613
|
}
|
|
614
|
+
const configDir = node_path.dirname(configFilePath);
|
|
594
615
|
const sourcePatterns = extractSourcePatterns(readFileSync(configFilePath));
|
|
595
|
-
if (sourcePatterns.length > 0) return expandPatterns(cwd, sourcePatterns)
|
|
616
|
+
if (sourcePatterns.length > 0) return expandPatterns(cwd, sourcePatterns.map((pattern) => {
|
|
617
|
+
const absolutePattern = node_path.resolve(configDir, pattern);
|
|
618
|
+
return node_path.relative(cwd, absolutePattern);
|
|
619
|
+
}));
|
|
596
620
|
return expandPatterns(cwd, [DEFAULT_FILE_PATTERN]);
|
|
597
621
|
}
|
|
598
622
|
function extractContentPatterns(config) {
|
package/dist/linter.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwind-lint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "A command-line tool that uses the Tailwind CSS IntelliSense plugin to show linting suggestions for your Tailwind CSS classes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tailwindcss",
|
|
@@ -43,11 +43,12 @@
|
|
|
43
43
|
"chalk": "^5.6.2",
|
|
44
44
|
"commander": "^14.0.2",
|
|
45
45
|
"fast-glob": "^3.3.3",
|
|
46
|
+
"postcss": "^8.5.6",
|
|
46
47
|
"vscode-languageserver-textdocument": "^1.0.12"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@biomejs/biome": "^2.3.
|
|
50
|
-
"@types/node": "^25.0
|
|
50
|
+
"@biomejs/biome": "^2.3.13",
|
|
51
|
+
"@types/node": "^25.1.0",
|
|
51
52
|
"tsdown": "^0.20.1",
|
|
52
53
|
"typescript": "^5.9.3",
|
|
53
54
|
"vitest": "^4.0.18"
|