@maz-ui/eslint-config 5.0.0 → 5.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.
Files changed (3) hide show
  1. package/README.md +16 -8
  2. package/dist/index.mjs +118 -44
  3. package/package.json +11 -6
package/README.md CHANGED
@@ -125,7 +125,10 @@ When `tailwindcss` is on, the rule is enabled with defaults. You can tune it eit
125
125
  defineConfig({
126
126
  tailwindcss: 'recommended',
127
127
  rules: {
128
- 'maz/tailwind-no-arbitrary-px': ['error', { baseFontSize: 10, unit: 'em' }],
128
+ 'maz/tailwind-no-arbitrary-px': [
129
+ 'error',
130
+ { baseFontSize: 10, unit: 'em' }
131
+ ],
129
132
  },
130
133
  })
131
134
  ```
@@ -173,13 +176,18 @@ If you don't want the full Tailwind preset (or just prefer wiring rules yourself
173
176
  ```js
174
177
  import { mazPlugin } from '@maz-ui/eslint-config'
175
178
 
176
- export default [{
177
- files: ['**/*.{ts,tsx,vue}'],
178
- plugins: { maz: mazPlugin },
179
- rules: {
180
- 'maz/tailwind-no-arbitrary-px': ['error', { baseFontSize: 16 }],
181
- },
182
- }]
179
+ export default [
180
+ {
181
+ files: ['**/*.{ts,tsx,vue}'],
182
+ plugins: { maz: mazPlugin },
183
+ rules: {
184
+ 'maz/tailwind-no-arbitrary-px': [
185
+ 'error',
186
+ { baseFontSize: 16 }
187
+ ],
188
+ },
189
+ }
190
+ ]
183
191
  ```
184
192
 
185
193
  ## Advanced
package/dist/index.mjs CHANGED
@@ -9,7 +9,9 @@ import betterTailwindcss from 'eslint-plugin-better-tailwindcss';
9
9
  function baseRules(isProduction) {
10
10
  return {
11
11
  // Console warnings in development, errors in production
12
- "no-console": [isProduction ? "error" : "warn"],
12
+ "no-console": [
13
+ isProduction ? "error" : "warn"
14
+ ],
13
15
  // Code quality
14
16
  "prefer-regex-literals": "off",
15
17
  "require-await": "error",
@@ -18,14 +20,26 @@ function baseRules(isProduction) {
18
20
  // Disable overly strict rules
19
21
  "no-unused-vars": "off",
20
22
  // Handled by TypeScript
21
- "ts/no-unused-vars": ["error", {
22
- argsIgnorePattern: "^_",
23
- varsIgnorePattern: "^_"
24
- }],
23
+ "ts/no-unused-vars": [
24
+ "error",
25
+ {
26
+ argsIgnorePattern: "^_",
27
+ varsIgnorePattern: "^_"
28
+ }
29
+ ],
25
30
  // Allow reasonable complexity
26
- "complexity": ["error", { max: 20 }],
27
- "max-depth": ["error", { max: 4 }],
28
- "max-nested-callbacks": ["error", { max: 3 }],
31
+ "complexity": [
32
+ "error",
33
+ { max: 20 }
34
+ ],
35
+ "max-depth": [
36
+ "error",
37
+ { max: 4 }
38
+ ],
39
+ "max-nested-callbacks": [
40
+ "error",
41
+ { max: 3 }
42
+ ],
29
43
  // ESLint 10 recommended rules (not yet in @eslint/js v9)
30
44
  "no-unassigned-vars": "error",
31
45
  "no-useless-assignment": "error",
@@ -177,7 +191,10 @@ const rule = {
177
191
  additionalProperties: false,
178
192
  properties: {
179
193
  baseFontSize: { type: "number", minimum: 1 },
180
- unit: { type: "string", enum: ["rem", "em"] }
194
+ unit: {
195
+ type: "string",
196
+ enum: ["rem", "em"]
197
+ }
181
198
  }
182
199
  }
183
200
  ],
@@ -218,7 +235,9 @@ const rule = {
218
235
  const parserServices = context.sourceCode.parserServices;
219
236
  if (parserServices.defineTemplateBodyVisitor) {
220
237
  return parserServices.defineTemplateBodyVisitor(
221
- { VLiteral: (node) => check(node) },
238
+ {
239
+ VLiteral: (node) => check(node)
240
+ },
222
241
  jsVisitor
223
242
  );
224
243
  }
@@ -240,10 +259,17 @@ const mazPlugin = {
240
259
  const TAILWINDCSS_FILES = ["**/*.{js,jsx,cjs,mjs,ts,mts,cts,tsx,vue,html,svelte,astro,astrojs,css,scss}"];
241
260
  const TAILWINDCSS_DEFAULT_FILES = TAILWINDCSS_FILES;
242
261
  function resolveNoArbitraryPx(setting) {
243
- if (setting === false)
244
- return { severity: "off", options: { baseFontSize: 16, unit: "rem" } };
262
+ if (setting === false) {
263
+ return {
264
+ severity: "off",
265
+ options: { baseFontSize: 16, unit: "rem" }
266
+ };
267
+ }
245
268
  if (setting === void 0 || setting === true) {
246
- return { severity: "error", options: { baseFontSize: 16, unit: "rem" } };
269
+ return {
270
+ severity: "error",
271
+ options: { baseFontSize: 16, unit: "rem" }
272
+ };
247
273
  }
248
274
  return {
249
275
  severity: setting.severity ?? "error",
@@ -267,24 +293,26 @@ function tailwindcssConfigs(preset, settings) {
267
293
  if (settings.tsconfig)
268
294
  tailwindSettings.tsconfig = settings.tsconfig;
269
295
  const noArbitraryPx = resolveNoArbitraryPx(settings.noArbitraryPx);
270
- return [{
271
- ...presetConfig,
272
- files: TAILWINDCSS_FILES,
273
- plugins: {
274
- ...presetConfig.plugins,
275
- maz: mazPlugin
276
- },
277
- settings: {
278
- "better-tailwindcss": tailwindSettings
279
- },
280
- rules: {
281
- ...presetConfig.rules,
282
- "better-tailwindcss/no-unknown-classes": "off",
283
- "better-tailwindcss/enforce-consistent-line-wrapping": "off",
284
- "better-tailwindcss/no-concatenated-classes": "off",
285
- "maz/tailwind-no-arbitrary-px": [noArbitraryPx.severity, noArbitraryPx.options]
296
+ return [
297
+ {
298
+ ...presetConfig,
299
+ files: TAILWINDCSS_FILES,
300
+ plugins: {
301
+ ...presetConfig.plugins,
302
+ maz: mazPlugin
303
+ },
304
+ settings: {
305
+ "better-tailwindcss": tailwindSettings
306
+ },
307
+ rules: {
308
+ ...presetConfig.rules,
309
+ "better-tailwindcss/no-unknown-classes": "off",
310
+ "better-tailwindcss/enforce-consistent-line-wrapping": "off",
311
+ "better-tailwindcss/no-concatenated-classes": "off",
312
+ "maz/tailwind-no-arbitrary-px": [noArbitraryPx.severity, noArbitraryPx.options]
313
+ }
286
314
  }
287
- }];
315
+ ];
288
316
  }
289
317
 
290
318
  const testRules = {
@@ -334,18 +362,32 @@ function resolveVue(option) {
334
362
  return { value: true, source: "explicit" };
335
363
  if (option === false)
336
364
  return { value: false, source: "explicit" };
337
- return { value: hasDependency(getPackageJson(), "vue", "nuxt"), source: "auto-detected" };
365
+ return {
366
+ value: hasDependency(getPackageJson(), "vue", "nuxt"),
367
+ source: "auto-detected"
368
+ };
338
369
  }
339
370
  function resolveTailwindcss(option) {
340
371
  if (option === void 0)
341
372
  return { value: false, source: "default" };
342
373
  if (option === false)
343
374
  return { value: false, source: "explicit" };
344
- if (option === true)
345
- return { value: { preset: "recommended", settings: {} }, source: "explicit" };
346
- if (typeof option === "string")
347
- return { value: { preset: option, settings: {} }, source: "explicit" };
348
- return { value: { preset: option.preset ?? "recommended", settings: option }, source: "explicit" };
375
+ if (option === true) {
376
+ return {
377
+ value: { preset: "recommended", settings: {} },
378
+ source: "explicit"
379
+ };
380
+ }
381
+ if (typeof option === "string") {
382
+ return {
383
+ value: { preset: option, settings: {} },
384
+ source: "explicit"
385
+ };
386
+ }
387
+ return {
388
+ value: { preset: option.preset ?? "recommended", settings: option },
389
+ source: "explicit"
390
+ };
349
391
  }
350
392
  function resolveOptions(opts, env) {
351
393
  const vue = resolveVue(opts.vue);
@@ -373,13 +415,28 @@ function formatSourceTag(source) {
373
415
  function formatResolutionBox(r) {
374
416
  const tailwindLabel = r.tailwindcss === false ? "off" : r.tailwindcss.preset;
375
417
  const rows = [
376
- ["typescript", String(r.typescript)],
418
+ [
419
+ "typescript",
420
+ String(r.typescript)
421
+ ],
377
422
  ["vue", `${r.vue}${formatSourceTag(r.vueSource)}`],
378
- ["vueAccessibility", String(r.vueAccessibility)],
379
- ["sonarjs", String(r.sonarjs)],
423
+ [
424
+ "vueAccessibility",
425
+ String(r.vueAccessibility)
426
+ ],
427
+ [
428
+ "sonarjs",
429
+ String(r.sonarjs)
430
+ ],
380
431
  ["tailwindcss", `${tailwindLabel}${formatSourceTag(r.tailwindcssSource)}`],
381
- ["formatters", String(r.formatters)],
382
- ["unicorn", String(r.unicorn)],
432
+ [
433
+ "formatters",
434
+ String(r.formatters)
435
+ ],
436
+ [
437
+ "unicorn",
438
+ String(r.unicorn)
439
+ ],
383
440
  ["env", r.env]
384
441
  ];
385
442
  const labelWidth = Math.max(...rows.map(([k]) => k.length));
@@ -389,7 +446,14 @@ function defineConfig(options = {}, ...userConfigs) {
389
446
  const log = createLogger();
390
447
  const defaultLogLevel = process.stdout.isTTY ? "default" : "silent";
391
448
  log.setLevel(options.logLevel ?? defaultLogLevel);
392
- const opts = { ...defaultOptions, ...options, ignores: [...GLOBAL_IGNORES, ...options.ignores || []] };
449
+ const opts = {
450
+ ...defaultOptions,
451
+ ...options,
452
+ ignores: [
453
+ ...GLOBAL_IGNORES,
454
+ ...options.ignores || []
455
+ ]
456
+ };
393
457
  const env = opts.env || process.env.NODE_ENV || "production";
394
458
  const resolved = resolveOptions(opts, env);
395
459
  log.box({
@@ -420,7 +484,12 @@ function defineConfig(options = {}, ...userConfigs) {
420
484
  }
421
485
  });
422
486
  additionalConfigs.push({
423
- files: ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.js", "**/*.test.js"],
487
+ files: [
488
+ "**/*.spec.ts",
489
+ "**/*.test.ts",
490
+ "**/*.spec.js",
491
+ "**/*.test.js"
492
+ ],
424
493
  rules: sonarjsTestRules
425
494
  });
426
495
  log.debug(`${TAG} SonarJS: applied recommended preset + ${Object.keys(sonarjsRules).length} extra rules + test-file relaxations`);
@@ -460,7 +529,12 @@ function defineConfig(options = {}, ...userConfigs) {
460
529
  log.debug(`${TAG} Tailwind: loaded "${resolved.tailwindcss.preset}" preset${settingsHint}`);
461
530
  }
462
531
  additionalConfigs.push({
463
- files: ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.js", "**/*.test.js"],
532
+ files: [
533
+ "**/*.spec.ts",
534
+ "**/*.test.ts",
535
+ "**/*.spec.js",
536
+ "**/*.test.js"
537
+ ],
464
538
  rules: testRules
465
539
  });
466
540
  log.debug(`${TAG} Tests: relaxed rules applied to *.spec.{ts,js} / *.test.{ts,js}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maz-ui/eslint-config",
3
3
  "type": "module",
4
- "version": "5.0.0",
4
+ "version": "5.3.0",
5
5
  "description": "ESLint configuration for JavaScript/TypeScript projects",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",
@@ -37,23 +37,28 @@
37
37
  "dist"
38
38
  ],
39
39
  "engines": {
40
- "node": ">=22.12.0"
40
+ "node": "^22.23.4 || ^24.22.1 || >=26.12.1"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "eslint": "^9.10.0 || ^10.0.0"
44
44
  },
45
45
  "dependencies": {
46
- "@antfu/eslint-config": "^9.5.1",
46
+ "@antfu/eslint-config": "^10.0.0",
47
47
  "consola": "^3.4.2",
48
48
  "eslint-plugin-better-tailwindcss": "^4.10.0",
49
49
  "eslint-plugin-format": "^2.0.1",
50
50
  "eslint-plugin-sonarjs": "^4.2.2",
51
- "eslint-plugin-vuejs-accessibility": "^2.6.2"
51
+ "eslint-plugin-vuejs-accessibility": "^2.6.3"
52
52
  },
53
53
  "devDependencies": {
54
- "@typescript-eslint/rule-tester": "^8.72.0",
55
- "eslint": "^10.13.0",
54
+ "@types/node": "^26.6.6",
55
+ "@typescript-eslint/rule-tester": "^8.72.1",
56
+ "@vitest/coverage-v8": "^5.1.0",
57
+ "cross-env": "^10.1.0",
58
+ "eslint": "^10.14.0",
59
+ "typescript": "^6.0.3",
56
60
  "unbuild": "^3.6.1",
61
+ "vitest": "5.1.0",
57
62
  "vue-eslint-parser": "^10.4.1"
58
63
  },
59
64
  "lint-staged": {