eslint-config-axkit 1.2.0 → 1.3.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.
package/README.md CHANGED
@@ -83,14 +83,17 @@ export default [
83
83
 
84
84
  ## Options
85
85
 
86
- | Option | Type | Description |
87
- | --------------- | -------- | -------------------------------------------------------------------------- |
88
- | `gitignorePath` | `string` | Path to `.gitignore` file. Patterns will be added to ESLint's ignore list. |
86
+ | Option | Type | Description |
87
+ | --------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
88
+ | `gitignorePath` | `string` | Path to `.gitignore` file. Patterns will be added to ESLint's ignore list. |
89
+ | `nextjs` | `boolean` | Enable Next.js rules (`eslint-config-next` core-web-vitals + typescript). Requires `eslint-config-next` to be installed. |
90
+ | `storybook` | `boolean` | Enable Storybook rules (`eslint-plugin-storybook` flat/recommended). Requires `eslint-plugin-storybook` to be installed. |
91
+ | `tailwindcss` | `string` | Path to the Tailwind CSS entry point (e.g. `"src/app/globals.css"`). Enables `eslint-plugin-better-tailwindcss` recommended rules enforcing stylistic and correctness rules. Requires `eslint-plugin-better-tailwindcss` to be installed. |
89
92
 
90
93
  ## Requirements
91
94
 
92
95
  - Node.js >= 22.14.0
93
- - ESLint >= 9
96
+ - ESLint >= 10
94
97
 
95
98
  ## License
96
99
 
@@ -8,6 +8,11 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
8
8
  };
9
9
  import { createRequire } from "node:module";
10
10
  import { pathToFileURL } from "node:url";
11
+ const consumerRequire = createRequire(`${process.cwd()}/`);
12
+ async function dynamicImport(resolvedPath) {
13
+ const imported = (await import(__rewriteRelativeImportExtension(pathToFileURL(resolvedPath).href)));
14
+ return imported["default"] ?? imported;
15
+ }
11
16
  /**
12
17
  * Dynamically import an optional dependency from the consumer's project.
13
18
  *
@@ -17,14 +22,12 @@ import { pathToFileURL } from "node:url";
17
22
  * are accessible.
18
23
  */
19
24
  export async function importOptional(name) {
20
- const require = createRequire(`${process.cwd()}/`);
21
25
  let resolvedPath;
22
26
  try {
23
- resolvedPath = require.resolve(name);
27
+ resolvedPath = consumerRequire.resolve(name);
24
28
  }
25
29
  catch {
26
30
  throw new Error(`eslint-config-axkit: "${name}" must be installed to use this option. Run: pnpm add -D ${name}`);
27
31
  }
28
- const imported = (await import(__rewriteRelativeImportExtension(pathToFileURL(resolvedPath).href)));
29
- return imported["default"] ?? imported;
32
+ return dynamicImport(resolvedPath);
30
33
  }
package/dist/index.d.ts CHANGED
@@ -16,6 +16,13 @@ export type Options = {
16
16
  * Requires `eslint-plugin-storybook` to be installed.
17
17
  */
18
18
  storybook?: boolean;
19
+ /**
20
+ * Path to the Tailwind CSS entry point (e.g. `"src/app/globals.css"`).
21
+ * Enables eslint-plugin-better-tailwindcss recommended rules and configures
22
+ * the plugin to resolve project-specific classes, variants, and plugins.
23
+ * Requires `eslint-plugin-better-tailwindcss` to be installed.
24
+ */
25
+ tailwindcss?: string;
19
26
  };
20
27
  /**
21
28
  * Creates a complete ESLint flat config for TypeScript projects.
@@ -30,5 +37,6 @@ export type Options = {
30
37
  * Optional:
31
38
  * - Next.js rules (core-web-vitals + typescript) via `nextjs: true`
32
39
  * - Storybook rules (flat/recommended) via `storybook: true`
40
+ * - Tailwind CSS rules (better-tailwindcss/recommended) via `tailwindcss: "path/to/entry.css"`
33
41
  */
34
42
  export declare function axkit(options?: Options): Promise<Linter.Config[]>;
package/dist/index.js CHANGED
@@ -19,23 +19,17 @@ import { vitestConfig } from "./vitest-config.js";
19
19
  * Optional:
20
20
  * - Next.js rules (core-web-vitals + typescript) via `nextjs: true`
21
21
  * - Storybook rules (flat/recommended) via `storybook: true`
22
+ * - Tailwind CSS rules (better-tailwindcss/recommended) via `tailwindcss: "path/to/entry.css"`
22
23
  */
23
24
  export async function axkit(options = {}) {
24
- const { gitignorePath, nextjs, storybook } = options;
25
+ const { gitignorePath, nextjs, storybook, tailwindcss } = options;
25
26
  const configs = [];
26
27
  // ── Gitignore ──────────────────────────────────────────────────────
27
28
  if (gitignorePath) {
28
29
  configs.push(includeIgnoreFile(gitignorePath, "Copy patterns from .gitignore"));
29
30
  }
30
31
  // ── Next.js (before base so axkit's strict rules override) ─────────
31
- //
32
- // When nextjs is enabled, we must use the consumer's typescript-eslint
33
- // instance (resolved from CWD) rather than our own bundled copy.
34
- // eslint-config-next registers the @typescript-eslint plugin, and ESLint
35
- // forbids redefining a plugin with a different object identity.
36
- let tseslintModule = tseslint;
37
32
  if (nextjs) {
38
- tseslintModule = (await importOptional("typescript-eslint"));
39
33
  const [nextVitals, nextTs] = await Promise.all([
40
34
  importOptional("eslint-config-next/core-web-vitals"),
41
35
  importOptional("eslint-config-next/typescript"),
@@ -43,7 +37,7 @@ export async function axkit(options = {}) {
43
37
  configs.push(...nextVitals, ...nextTs);
44
38
  }
45
39
  // ── Core configs ───────────────────────────────────────────────────
46
- configs.push(js.configs.recommended, ...tseslintModule.configs.strictTypeChecked, baseConfig, eslintPluginUnicorn.configs.recommended,
40
+ configs.push(js.configs.recommended, ...tseslint.configs.strictTypeChecked, baseConfig, eslintPluginUnicorn.configs.recommended,
47
41
  // Unicorn rules that are off by default
48
42
  {
49
43
  name: "axkit/unicorn-extras",
@@ -58,13 +52,26 @@ export async function axkit(options = {}) {
58
52
  }, {
59
53
  name: "axkit/config-files",
60
54
  files: ["*.config.{js,ts,mjs,mts}"],
61
- ...tseslintModule.configs.disableTypeChecked,
55
+ ...tseslint.configs.disableTypeChecked,
62
56
  }, vitestConfig);
63
57
  // ── Storybook (after base, before Prettier) ────────────────────────
64
58
  if (storybook) {
65
59
  const storybookPlugin = (await importOptional("eslint-plugin-storybook"));
66
60
  configs.push(...storybookPlugin.configs["flat/recommended"]);
67
61
  }
62
+ // ── Tailwind CSS (before Prettier) ─────────────────────────────────
63
+ if (tailwindcss) {
64
+ const tailwindPlugin = (await importOptional("eslint-plugin-better-tailwindcss"));
65
+ const tailwindConfig = tailwindPlugin.configs.recommended;
66
+ configs.push(...(Array.isArray(tailwindConfig) ? tailwindConfig : [tailwindConfig]), {
67
+ name: "axkit/tailwindcss-entry-point",
68
+ settings: {
69
+ "better-tailwindcss": {
70
+ entryPoint: tailwindcss,
71
+ },
72
+ },
73
+ });
74
+ }
68
75
  // ── Prettier compatibility (must be last) ──────────────────────────
69
76
  configs.push(eslintConfigPrettier);
70
77
  return configs;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "eslint-config-axkit",
3
3
  "author": "Łukasz Jerciński",
4
4
  "license": "MIT",
5
- "version": "1.2.0",
5
+ "version": "1.3.0",
6
6
  "description": "Reusable ESLint flat config for TypeScript + Node.js projects with strict type checking, Prettier, Unicorn, and Vitest",
7
7
  "repository": {
8
8
  "type": "git",
@@ -60,12 +60,16 @@
60
60
  "peerDependencies": {
61
61
  "eslint": ">=10",
62
62
  "eslint-config-next": ">=16",
63
+ "eslint-plugin-better-tailwindcss": ">=4",
63
64
  "eslint-plugin-storybook": ">=10"
64
65
  },
65
66
  "peerDependenciesMeta": {
66
67
  "eslint-config-next": {
67
68
  "optional": true
68
69
  },
70
+ "eslint-plugin-better-tailwindcss": {
71
+ "optional": true
72
+ },
69
73
  "eslint-plugin-storybook": {
70
74
  "optional": true
71
75
  }