@infernodesign/eslint-config 1.17.0 → 1.17.2
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/dist/cli.js +1 -1
- package/dist/index.js +17 -10
- package/package.json +1 -1
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -2374,13 +2374,13 @@ const defaultEntryPointCandidates = [
|
|
|
2374
2374
|
];
|
|
2375
2375
|
async function tailwindcss(options = {}) {
|
|
2376
2376
|
const { files = [GLOB_SRC], overrides = {} } = options;
|
|
2377
|
-
await ensurePackages(["eslint-plugin-better-tailwindcss"]);
|
|
2378
2377
|
if (!isPackageExists("tailwindcss")) return [];
|
|
2378
|
+
await ensurePackages(["eslint-plugin-better-tailwindcss"]);
|
|
2379
2379
|
const tsconfigPath = options?.tsconfigPath !== void 0 ? toArray(options.tsconfigPath) : void 0;
|
|
2380
2380
|
const resolvedTsconfigPath = tsconfigPath?.[0] ? path.resolve(process.cwd(), tsconfigPath[0]) : void 0;
|
|
2381
2381
|
const isTypeAware = !!resolvedTsconfigPath;
|
|
2382
|
-
const
|
|
2383
|
-
const isUsingEntryPoint = !!
|
|
2382
|
+
const resolvedEntryPointPath = resolveTailwindEntryPoint(options.entryPoint);
|
|
2383
|
+
const isUsingEntryPoint = !!resolvedEntryPointPath;
|
|
2384
2384
|
const [pluginTailwindCSS, parserTs] = await Promise.all([interopDefault(import("eslint-plugin-better-tailwindcss")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
2385
2385
|
return [{
|
|
2386
2386
|
languageOptions: {
|
|
@@ -2397,7 +2397,7 @@ async function tailwindcss(options = {}) {
|
|
|
2397
2397
|
name: "config/tailwindcss/setup",
|
|
2398
2398
|
plugins: { "tailwindcss": pluginTailwindCSS },
|
|
2399
2399
|
settings: { tailwindcss: {
|
|
2400
|
-
...isUsingEntryPoint ? { entryPoint:
|
|
2400
|
+
...isUsingEntryPoint ? { entryPoint: resolvedEntryPointPath } : {},
|
|
2401
2401
|
detectComponentClasses: options.detectComponentClasses ?? false,
|
|
2402
2402
|
...isTypeAware ? { tsconfig: resolvedTsconfigPath } : {}
|
|
2403
2403
|
} }
|
|
@@ -2406,9 +2406,8 @@ async function tailwindcss(options = {}) {
|
|
|
2406
2406
|
name: "config/tailwindcss/rules",
|
|
2407
2407
|
rules: {
|
|
2408
2408
|
...pluginTailwindCSS.configs["recommended-error"]?.rules,
|
|
2409
|
-
...pluginTailwindCSS.configs["stylistic-error"]?.rules,
|
|
2410
2409
|
"tailwindcss/enforce-consistent-line-wrapping": "off",
|
|
2411
|
-
"tailwindcss/no-
|
|
2410
|
+
...isUsingEntryPoint ? { "tailwindcss/no-unknown-classes": ["error", { entryPoint: resolvedEntryPointPath }] } : { "tailwindcss/no-unknown-classes": "off" },
|
|
2412
2411
|
...overrides
|
|
2413
2412
|
}
|
|
2414
2413
|
}];
|
|
@@ -2474,8 +2473,13 @@ function findGlobalCssEntryPoint() {
|
|
|
2474
2473
|
if (entry.isFile() && (entry.name === "global.css" || entry.name === "globals.css")) candidates.push(nextPath);
|
|
2475
2474
|
}
|
|
2476
2475
|
}
|
|
2477
|
-
if (!candidates.length)
|
|
2478
|
-
|
|
2476
|
+
if (!candidates.length) {
|
|
2477
|
+
console.warn(`[${PACKAGE_NAME}] No global CSS entry point found in "${process.cwd()}".`);
|
|
2478
|
+
return;
|
|
2479
|
+
}
|
|
2480
|
+
const resolvedEntryPoint = candidates.sort((a, b) => rankEntryPointPath(a) - rankEntryPointPath(b) || a.length - b.length || a.localeCompare(b))[0];
|
|
2481
|
+
console.log(`[${PACKAGE_NAME}] Resolved global CSS entryPoint: "${resolvedEntryPoint}".`);
|
|
2482
|
+
return resolvedEntryPoint;
|
|
2479
2483
|
}
|
|
2480
2484
|
/**
|
|
2481
2485
|
* Rank the entry point path.
|
|
@@ -2501,8 +2505,11 @@ function rankEntryPointPath(filePath) {
|
|
|
2501
2505
|
function resolveTailwindEntryPoint(entryPoint) {
|
|
2502
2506
|
if (entryPoint) {
|
|
2503
2507
|
const resolvedEntryPoint = findFileRecursiveFromCwd(entryPoint);
|
|
2504
|
-
if (resolvedEntryPoint)
|
|
2505
|
-
|
|
2508
|
+
if (resolvedEntryPoint) {
|
|
2509
|
+
console.log(`[${PACKAGE_NAME}] Resolved Tailwind CSS entryPoint: "${resolvedEntryPoint}".`);
|
|
2510
|
+
return resolvedEntryPoint;
|
|
2511
|
+
}
|
|
2512
|
+
console.warn(`[${PACKAGE_NAME}] Tailwind CSS entryPoint "${entryPoint}" was not found from "${process.cwd()}".`);
|
|
2506
2513
|
}
|
|
2507
2514
|
return findGlobalCssEntryPoint();
|
|
2508
2515
|
}
|
package/package.json
CHANGED