@fabdeh/eslint-config 0.5.0 → 0.6.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/dist/index.d.mts CHANGED
@@ -2,6 +2,7 @@ import { ConfigArray, ConfigWithExtends } from 'typescript-eslint';
2
2
  import { StylisticCustomizeOptions } from '@stylistic/eslint-plugin';
3
3
  import { TSESLint } from '@typescript-eslint/utils';
4
4
  import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
5
+ import { Attributes, Callees, Variables, Tags } from 'eslint-plugin-better-tailwindcss/api/types';
5
6
 
6
7
  /**
7
8
  * Vendor types from Prettier so we don't rely on the dependency.
@@ -313,12 +314,55 @@ interface RegExpOptions {
313
314
  */
314
315
  level?: 'error' | 'warn';
315
316
  }
316
- interface TailwindcssParserPerGlobOptions {
317
+ /**
318
+ * Interface for better-tailwindcss specific options.
319
+ */
320
+ interface TailwindCssOptions {
317
321
  /**
318
322
  * Provides a specific ESLint parser per glob pattern.
319
- * This is only needed if you want to lint tailwindcss without using Angular and TypeScript.
320
323
  */
321
324
  parsers?: Record<string, TSESLint.FlatConfig.Parser>;
325
+ /**
326
+ * Use all better-tailwindcss rules or only recommended ones.
327
+ *
328
+ * @default false
329
+ */
330
+ enableAllRules?: boolean;
331
+ /**
332
+ * The path to the entry file of the CSS-based tailwind config (eg: `src/global.css`). If not specified, the plugin will fall back to the default configuration.
333
+ * The tailwind config is used to determine the sorting order.
334
+ */
335
+ entryPoint?: string;
336
+ /**
337
+ * The path to the `tailwind.config.js` file. If not specified, the plugin will try to find it automatically or falls back to the default configuration.
338
+ * The tailwind config is used to determine the sorting order.
339
+ */
340
+ tailwindConfig?: string;
341
+ /**
342
+ * The name of the attribute that contains the tailwind classes.
343
+ *
344
+ * @default Name for `"class"` and strings Matcher for `"class", "className"`.
345
+ */
346
+ attributes?: Attributes;
347
+ /**
348
+ * List of function names which arguments should also get linted.
349
+ *
350
+ * @default Matchers for `"cc", "clb", "clsx", "cn", "cnb", "ctl", "cva", "cx", "dcnb", "objstr", "tv", "twJoin", "twMerge"`.
351
+ */
352
+ callees?: Callees;
353
+ /**
354
+ * List of variable names whose initializer should also get linted.
355
+ *
356
+ * @default strings Matcher for `"className", "classNames", "classes", "style", "styles"`.
357
+ */
358
+ variables?: Variables;
359
+ /**
360
+ * List of template literal tag names whose content should get linted.
361
+ * When using the `tags` option, it is recommended to use the strings Matcher for your tag names. This will ensure that nested expressions get linted correctly.
362
+ *
363
+ * @default None
364
+ */
365
+ tags?: Tags;
322
366
  }
323
367
  /**
324
368
  * Options for creating an ESLint configuration.
@@ -394,7 +438,7 @@ interface CreateConfigOptions {
394
438
  *
395
439
  * @default false
396
440
  */
397
- tailwindcss?: boolean | (FilesOptions & OverridesOptions) | (OverridesOptions & TailwindcssParserPerGlobOptions);
441
+ tailwindcss?: boolean | (FilesOptions & OverridesOptions & TailwindCssOptions);
398
442
  /**
399
443
  * Enable JSONC support.
400
444
  *
@@ -624,18 +668,19 @@ declare const STYLISTIC_CONFIG_DEFAULT: StylisticConfig;
624
668
  declare function stylistic(options?: StylisticOptions): Promise<ConfigArray>;
625
669
 
626
670
  /**
627
- * Generates an ESLint configuration array for Tailwind CSS.
671
+ * Generates an ESLint configuration array for Tailwind CSS using better-tailwindcss plugin.
628
672
  *
629
673
  * @param [options] - Optional overrides for the configuration.
630
674
  * @returns A promise that resolves to the ESLint configuration array.
631
675
  * @example
632
676
  * const config = await tailwindcss({
677
+ * enableAllRules: true,
633
678
  * overrides: {
634
- * 'tailwindcss/classnames-order': 'warn',
679
+ * 'better-tailwindcss/recommended': 'warn',
635
680
  * },
636
681
  * });
637
682
  */
638
- declare function tailwindcss(options?: (FilesOptions & OverridesOptions) | (OverridesOptions & TailwindcssParserPerGlobOptions)): Promise<ConfigArray>;
683
+ declare function tailwindcss(options?: (FilesOptions & OverridesOptions & TailwindCssOptions)): Promise<ConfigArray>;
639
684
 
640
685
  /**
641
686
  * Generates an ESLint configuration for TOML files.
@@ -805,4 +850,4 @@ type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
805
850
  declare function resolveSubOptions<K extends keyof CreateConfigOptions>(options: CreateConfigOptions, key: K): ResolvedOptions<CreateConfigOptions[K]>;
806
851
 
807
852
  export { GLOB_HTML, GLOB_JS, GLOB_SRC, GLOB_TESTS, GLOB_TS, STYLISTIC_CONFIG_DEFAULT, angular, comments, defineConfig, ensurePackages, findNearestPackageJsonName, getTsConfigFileName, getWorkspaceRoot, ignores, imports, interopDefault, isPackageInScope, javascript, jsdoc, jsonc, markdown, ngrx, perfectionist, regexp, resolveSubOptions, sortPackageJson, sortTsConfig, stylistic, tailwindcss, toml, typescript, unicorn, vitest, yaml };
808
- export type { AngularOptions, Awaitable, CreateConfigOptions, FilesOptions, FormattersOptions, NgrxOperators, NgrxOptions, OverridesOptions, RegExpOptions, ResolvedOptions, StylisticConfig, StylisticOptions, TailwindcssParserPerGlobOptions, TestingOptions, TypeScriptErasableSyntaxOnlyOptions, TypeScriptParserOptions, UnicornOptions };
853
+ export type { AngularOptions, Awaitable, CreateConfigOptions, FilesOptions, FormattersOptions, NgrxOperators, NgrxOptions, OverridesOptions, RegExpOptions, ResolvedOptions, StylisticConfig, StylisticOptions, TailwindCssOptions, TestingOptions, TypeScriptErasableSyntaxOnlyOptions, TypeScriptParserOptions, UnicornOptions };
package/dist/index.mjs CHANGED
@@ -139,10 +139,11 @@ async function findNearestPackageJsonName(directoryPath = resolve()) {
139
139
  }
140
140
  }
141
141
  function resolveSubOptions(options, key) {
142
- if (typeof options[key] === "boolean") {
143
- return {};
142
+ const option = options[key];
143
+ if (typeof option === "boolean") {
144
+ throw new TypeError(`Option ${String(key)} should not be boolean.`);
144
145
  }
145
- return options[key] ?? {};
146
+ return option ?? {};
146
147
  }
147
148
 
148
149
  async function angular(options = {}) {
@@ -1231,42 +1232,43 @@ async function stylistic(options = {}) {
1231
1232
  });
1232
1233
  }
1233
1234
 
1234
- function isTailwindcssParserPerGlobOptions(options) {
1235
- return "parsers" in options && options.parsers !== void 0;
1236
- }
1237
1235
  async function tailwindcss(options = {}) {
1238
- await ensurePackages(["eslint-plugin-tailwindcss"]);
1239
- const tailwindcssPlugin = await interopDefault(import('eslint-plugin-tailwindcss'));
1236
+ await ensurePackages(["eslint-plugin-better-tailwindcss"]);
1237
+ const betterTailwindcssPlugin = await interopDefault(import('eslint-plugin-better-tailwindcss'));
1238
+ const { files: filesGlob, overrides, enableAllRules, parsers, ...settings } = options;
1240
1239
  let files;
1241
1240
  let parserConfigs;
1242
- const { overrides = {} } = options;
1243
- if (isTailwindcssParserPerGlobOptions(options)) {
1244
- const parsers = options.parsers ?? {};
1241
+ if (parsers) {
1245
1242
  files = { files: [...new Set(Object.keys(parsers))] };
1246
1243
  parserConfigs = Object.entries(parsers).map(([glob, parser], index) => ({
1247
1244
  name: `fabdeh/tailwindcss/parser-${index + 1}`,
1248
- file: [glob],
1245
+ files: [glob],
1249
1246
  languageOptions: {
1250
1247
  parser
1251
1248
  }
1252
1249
  }));
1253
1250
  } else {
1254
- files = { files: options.files ?? [GLOB_SRC, GLOB_HTML] };
1251
+ files = { files: filesGlob ?? [GLOB_SRC, GLOB_HTML] };
1255
1252
  parserConfigs = [];
1256
1253
  }
1257
1254
  return tseslint.config(
1258
1255
  ...parserConfigs,
1259
1256
  {
1260
- name: "fabdeh/tailwindcss/rules",
1261
- plugins: { tailwindcss: tailwindcssPlugin },
1257
+ name: "@fabdeh/tailwindcss/rules",
1262
1258
  ...files,
1259
+ plugins: {
1260
+ "better-tailwindcss": betterTailwindcssPlugin
1261
+ },
1262
+ settings: {
1263
+ "better-tailwindcss": settings
1264
+ },
1263
1265
  rules: {
1264
- "tailwindcss/classnames-order": "error",
1265
- "tailwindcss/enforces-negative-arbitrary-values": "error",
1266
- "tailwindcss/enforces-shorthand": "error",
1267
- "tailwindcss/no-contradicting-classname": "error",
1268
- "tailwindcss/no-unnecessary-arbitrary-value": "error",
1269
- ...overrides
1266
+ ...betterTailwindcssPlugin.configs.recommended.rules,
1267
+ ...enableAllRules ? {
1268
+ "better-tailwindcss/enforce-consistent-variable-syntax": "warn",
1269
+ "better-tailwindcss/no-conflicting-classes": "error",
1270
+ "better-tailwindcss/no-restricted-classes": "error"
1271
+ } : {}
1270
1272
  }
1271
1273
  }
1272
1274
  );
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@fabdeh/eslint-config",
3
3
  "type": "module",
4
- "version": "0.5.0",
5
- "packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39",
4
+ "version": "0.6.0",
5
+ "packageManager": "pnpm@10.12.1+sha512.f0dda8580f0ee9481c5c79a1d927b9164f2c478e90992ad268bbb2465a736984391d6333d2c327913578b2804af33474ca554ba29c04a8b13060a717675ae3ac",
6
6
  "description": "My personal eslint config preset",
7
7
  "author": {
8
8
  "name": "Fabien Dehopré",
@@ -55,22 +55,22 @@
55
55
  "peerDependencies": {
56
56
  "@prettier/plugin-xml": "^3.4.1",
57
57
  "eslint": "^9.21.0",
58
+ "eslint-plugin-better-tailwindcss": "^3.4.1",
58
59
  "eslint-plugin-erasable-syntax-only": "^0.3.0",
59
60
  "eslint-plugin-format": "^1.0.1",
60
- "eslint-plugin-tailwindcss": "^3.18.0",
61
61
  "prettier-plugin-slidev": "^1.0.5"
62
62
  },
63
63
  "peerDependenciesMeta": {
64
64
  "@prettier/plugin-xml": {
65
65
  "optional": true
66
66
  },
67
- "eslint-plugin-erasable-syntax-only": {
67
+ "eslint-plugin-better-tailwindcss": {
68
68
  "optional": true
69
69
  },
70
- "eslint-plugin-format": {
70
+ "eslint-plugin-erasable-syntax-only": {
71
71
  "optional": true
72
72
  },
73
- "eslint-plugin-tailwindcss": {
73
+ "eslint-plugin-format": {
74
74
  "optional": true
75
75
  },
76
76
  "prettier-plugin-slidev": {
@@ -85,22 +85,22 @@
85
85
  "@eslint/markdown": "^6.5.0",
86
86
  "@ngrx/eslint-plugin": "^19.2.1",
87
87
  "@stylistic/eslint-plugin": "^4.4.1",
88
- "@typescript-eslint/eslint-plugin": "^8.33.1",
89
- "@typescript-eslint/parser": "^8.33.1",
90
- "@typescript-eslint/utils": "^8.33.1",
91
- "@vitest/eslint-plugin": "^1.2.1",
88
+ "@typescript-eslint/eslint-plugin": "^8.34.0",
89
+ "@typescript-eslint/parser": "^8.34.0",
90
+ "@typescript-eslint/utils": "^8.34.0",
91
+ "@vitest/eslint-plugin": "^1.2.2",
92
92
  "angular-eslint": "^20.0.0",
93
93
  "eslint-config-flat-gitignore": "^2.1.0",
94
94
  "eslint-flat-config-utils": "^2.1.0",
95
95
  "eslint-merge-processors": "^2.0.0",
96
96
  "eslint-plugin-import-x": "^4.15.1",
97
97
  "eslint-plugin-jest-dom": "^5.5.0",
98
- "eslint-plugin-jsdoc": "^50.7.1",
98
+ "eslint-plugin-jsdoc": "^50.8.0",
99
99
  "eslint-plugin-jsonc": "^2.20.1",
100
100
  "eslint-plugin-perfectionist": "^4.14.0",
101
101
  "eslint-plugin-prefer-arrow-functions": "^3.6.2",
102
- "eslint-plugin-regexp": "^2.8.0",
103
- "eslint-plugin-testing-library": "^7.4.0",
102
+ "eslint-plugin-regexp": "^2.9.0",
103
+ "eslint-plugin-testing-library": "^7.5.2",
104
104
  "eslint-plugin-toml": "^0.12.0",
105
105
  "eslint-plugin-unicorn": "^59.0.1",
106
106
  "eslint-plugin-unused-imports": "^4.1.4",
@@ -109,11 +109,11 @@
109
109
  "jsonc-eslint-parser": "^2.4.0",
110
110
  "local-pkg": "^1.1.1",
111
111
  "toml-eslint-parser": "^0.10.0",
112
- "typescript-eslint": "^8.33.1",
112
+ "typescript-eslint": "^8.34.0",
113
113
  "yaml-eslint-parser": "^1.3.0"
114
114
  },
115
115
  "devDependencies": {
116
- "@angular/core": "^20.0.2",
116
+ "@angular/core": "^20.0.3",
117
117
  "@commitlint/cli": "^19.8.1",
118
118
  "@commitlint/config-conventional": "^19.8.1",
119
119
  "@commitlint/cz-commitlint": "^19.8.1",
@@ -126,14 +126,14 @@
126
126
  "@testing-library/angular": "^17.4.0",
127
127
  "@testing-library/jest-dom": "^6.6.3",
128
128
  "@types/fs-extra": "^11.0.4",
129
- "@types/node": "^22.15.30",
129
+ "@types/node": "^22.15.31",
130
130
  "bumpp": "^10.1.1",
131
131
  "changelogithub": "^13.15.0",
132
132
  "commitizen": "^4.3.1",
133
133
  "eslint": "^9.28.0",
134
+ "eslint-plugin-better-tailwindcss": "^3.4.0",
134
135
  "eslint-plugin-erasable-syntax-only": "^0.3.1",
135
136
  "eslint-plugin-format": "^1.0.1",
136
- "eslint-plugin-tailwindcss": "^3.18.0",
137
137
  "execa": "^9.6.0",
138
138
  "fast-glob": "^3.3.3",
139
139
  "fs-extra": "^11.3.0",
@@ -143,10 +143,10 @@
143
143
  "nano-staged": "^0.8.0",
144
144
  "prettier-plugin-slidev": "^1.0.5",
145
145
  "simple-git-hooks": "^2.13.0",
146
- "tailwindcss": "^3.4.17",
146
+ "tailwindcss": "^4.1.10",
147
147
  "typescript": "^5.8.3",
148
148
  "unbuild": "^3.5.0",
149
- "vitest": "^3.2.2"
149
+ "vitest": "^3.2.3"
150
150
  },
151
151
  "pnpm": {
152
152
  "overrides": {