tailwind-canonical 0.8.0 → 0.9.0

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.
@@ -1,7 +1,7 @@
1
- import { readdirSync, statSync } from 'node:fs';
1
+ import { existsSync, lstatSync, readdirSync, statSync, } from 'node:fs';
2
2
  import { glob } from 'node:fs/promises';
3
- import { join } from 'node:path';
4
- import { DEFAULT_EXTENSIONS, DEFAULT_IGNORE, globToRegex, isGlob, } from '../core/scanner.js';
3
+ import { isAbsolute, join, matchesGlob, resolve } from 'node:path';
4
+ import { DEFAULT_EXTENSIONS, DEFAULT_IGNORE, isGlob, } from '../core/scanner.js';
5
5
  export function scanFiles(target, options = {}) {
6
6
  const ignore = options.ignore ?? DEFAULT_IGNORE;
7
7
  const extensions = options.extensions ?? DEFAULT_EXTENSIONS;
@@ -21,7 +21,8 @@ export function scanFiles(target, options = {}) {
21
21
  if (entry.isDirectory()) {
22
22
  walk(full);
23
23
  }
24
- else if (extensions.some((ext) => entry.name.endsWith(ext))) {
24
+ else if (entry.isFile() &&
25
+ extensions.some((ext) => entry.name.endsWith(ext))) {
25
26
  files.push(full);
26
27
  }
27
28
  }
@@ -42,10 +43,10 @@ export async function resolveTargets(patterns, options = {}) {
42
43
  const ignore = options.ignore ?? DEFAULT_IGNORE;
43
44
  const extensions = options.extensions ?? DEFAULT_EXTENSIONS;
44
45
  const positive = [];
45
- const negativeRegexes = [];
46
+ const negativePatterns = [];
46
47
  for (const p of patterns) {
47
48
  if (p.startsWith('!')) {
48
- negativeRegexes.push(globToRegex(p.slice(1)));
49
+ negativePatterns.push(p.slice(1).replace(/\\/g, '/'));
49
50
  }
50
51
  else {
51
52
  positive.push(p);
@@ -53,14 +54,15 @@ export async function resolveTargets(patterns, options = {}) {
53
54
  }
54
55
  const files = new Set();
55
56
  for (const pattern of positive) {
56
- if (isGlob(pattern)) {
57
+ if (isGlob(pattern) && !existsSync(pattern)) {
57
58
  for await (const f of glob(pattern, {
58
59
  exclude: (entry) => entry
59
60
  .replace(/\\/g, '/')
60
61
  .split('/')
61
62
  .some((s) => ignore.includes(s)),
62
63
  })) {
63
- if (extensions.some((ext) => f.endsWith(ext))) {
64
+ if (extensions.some((ext) => f.endsWith(ext)) &&
65
+ lstatSync(f).isFile()) {
64
66
  files.add(f);
65
67
  }
66
68
  }
@@ -71,10 +73,24 @@ export async function resolveTargets(patterns, options = {}) {
71
73
  }
72
74
  }
73
75
  }
74
- if (negativeRegexes.length > 0) {
76
+ if (negativePatterns.length > 0) {
77
+ const exclusions = negativePatterns.map((pattern) => ({
78
+ pattern,
79
+ literal: existsSync(pattern)
80
+ ? resolve(pattern).replace(/\\/g, '/')
81
+ : undefined,
82
+ }));
75
83
  for (const f of [...files]) {
76
84
  const normalized = f.replace(/\\/g, '/');
77
- if (negativeRegexes.some((re) => re.test(normalized))) {
85
+ if (exclusions.some(({ pattern, literal }) => {
86
+ if (literal) {
87
+ const full = resolve(f).replace(/\\/g, '/');
88
+ return (full === literal ||
89
+ full.startsWith(literal.endsWith('/') ? literal : `${literal}/`));
90
+ }
91
+ return (matchesGlob(normalized, pattern) ||
92
+ (!isAbsolute(pattern) && matchesGlob(normalized, `**/${pattern}`)));
93
+ })) {
78
94
  files.delete(f);
79
95
  }
80
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-canonical",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Lint and auto-fix Tailwind CSS arbitrary values that have canonical equivalents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -64,8 +64,8 @@
64
64
  "typescript": "^7.0.2"
65
65
  },
66
66
  "peerDependencies": {
67
- "eslint": ">=8.0.0",
68
- "tailwind-merge": ">=2.0.0"
67
+ "eslint": ">=8.57.1 <11",
68
+ "tailwind-merge": ">=2.0.0 <4"
69
69
  },
70
70
  "peerDependenciesMeta": {
71
71
  "eslint": {
@@ -80,8 +80,10 @@
80
80
  "dev": "tsc --watch",
81
81
  "test": "node --import=tsx/esm --test \"src/**/*.test.ts\"",
82
82
  "typecheck": "tsc --noEmit",
83
- "lint": "biome check src/",
84
- "lint:fix": "biome check --write src/",
85
- "knip": "knip"
83
+ "lint": "biome check src/ scripts/",
84
+ "lint:fix": "biome check --write src/ scripts/",
85
+ "knip": "knip",
86
+ "benchmark": "pnpm build && node scripts/benchmark.mjs",
87
+ "test:compat": "node scripts/compatibility.mjs"
86
88
  }
87
89
  }