eslint-plugin-tailwind-canonical-classes 1.3.1 → 1.3.3

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.
@@ -148,11 +148,35 @@ const rule = {
148
148
  return {};
149
149
  }
150
150
  let cssPath;
151
+ let resolvedViaWalkUp = false;
151
152
  if (path.isAbsolute(options.cssPath)) {
152
153
  cssPath = path.normalize(options.cssPath);
153
154
  }
154
155
  else {
155
156
  cssPath = path.normalize(path.resolve(cwd, options.cssPath));
157
+ // In monorepos, `context.cwd` may point to the repository root rather
158
+ // than the project directory, causing a relative `cssPath` to resolve to
159
+ // the wrong location. When that happens, walk up from the file being
160
+ // linted until we find a directory that contains the CSS file.
161
+ if (!fs.existsSync(cssPath)) {
162
+ resolvedViaWalkUp = true;
163
+ const filename = context.filename ?? context.getFilename?.();
164
+ if (filename) {
165
+ let dir = path.dirname(filename);
166
+ const root = path.parse(dir).root;
167
+ while (dir !== root) {
168
+ const candidate = path.normalize(path.resolve(dir, options.cssPath));
169
+ if (fs.existsSync(candidate)) {
170
+ cssPath = candidate;
171
+ break;
172
+ }
173
+ const parent = path.dirname(dir);
174
+ if (parent === dir)
175
+ break;
176
+ dir = parent;
177
+ }
178
+ }
179
+ }
156
180
  }
157
181
  const rootFontSize = options.rootFontSize ?? 16;
158
182
  const calleeFunctions = options.calleeFunctions ?? [
@@ -163,6 +187,12 @@ const rule = {
163
187
  'cva',
164
188
  ];
165
189
  if (!fs.existsSync(cssPath)) {
190
+ // When the walk-up was attempted and still found nothing, the linted file
191
+ // likely lives in an unrelated project inside the monorepo — silently
192
+ // disable the rule instead of reporting an error on every file.
193
+ if (resolvedViaWalkUp) {
194
+ return {};
195
+ }
166
196
  context.report({
167
197
  node: sourceCode.ast,
168
198
  messageId: 'cssNotFound',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-tailwind-canonical-classes",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "ESLint plugin to enforce canonical Tailwind CSS class names using Tailwind CSS v4's canonicalization API",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",