@tb-dev/eslint-config 4.3.0 → 4.4.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.cjs CHANGED
@@ -6,6 +6,7 @@ const globals = require('globals');
6
6
  var Glob = /* @__PURE__ */ ((Glob2) => {
7
7
  Glob2["All"] = "**/*.?([cm])[jt]s?(x)";
8
8
  Glob2["Javascript"] = "**/*.?([cm])js?(x)";
9
+ Glob2["Json"] = "**/*.json?([c5])";
9
10
  Glob2["Typescript"] = "**/*.?([cm])ts?(x)";
10
11
  Glob2["Vitest"] = "**/*.{test,spec}.[jt]s";
11
12
  Glob2["Vue"] = "**/*.vue";
@@ -36,6 +37,7 @@ function getIgnores() {
36
37
  const stylisticRules = {
37
38
  "stylistic/array-bracket-newline": ["error", "consistent"],
38
39
  "stylistic/array-bracket-spacing": ["error", "never"],
40
+ "stylistic/array-element-newline": ["error", "consistent"],
39
41
  "stylistic/arrow-parens": ["error", "always"],
40
42
  "stylistic/arrow-spacing": "error",
41
43
  "stylistic/block-spacing": "error",
@@ -360,7 +362,7 @@ async function vue(options) {
360
362
  math: "always"
361
363
  }],
362
364
  "vue/max-attributes-per-line": ["error", {
363
- singleline: 1,
365
+ singleline: Number.MAX_SAFE_INTEGER,
364
366
  multiline: 1
365
367
  }],
366
368
  "vue/multiline-html-element-content-newline": ["error", {
@@ -381,6 +383,7 @@ async function vue(options) {
381
383
  const vueStylistic = [
382
384
  "vue/array-bracket-newline",
383
385
  "vue/array-bracket-spacing",
386
+ "vue/array-element-newline",
384
387
  "vue/key-spacing",
385
388
  "vue/keyword-spacing",
386
389
  "vue/max-len",
@@ -404,9 +407,7 @@ async function vue(options) {
404
407
  }, {}));
405
408
  }
406
409
  return [
407
- {
408
- plugins: { vue: vuePlugin }
409
- },
410
+ { plugins: { vue: vuePlugin } },
410
411
  {
411
412
  files: [Glob.Vue],
412
413
  languageOptions: {
@@ -429,6 +430,59 @@ async function vue(options) {
429
430
  ];
430
431
  }
431
432
 
433
+ async function jsonc(options) {
434
+ const { overrides, jsonc: enabled } = options;
435
+ if (!enabled) return [];
436
+ const [jsoncPlugin, jsoncParser] = await Promise.all([
437
+ interopDefault(import('eslint-plugin-jsonc')),
438
+ interopDefault(import('jsonc-eslint-parser'))
439
+ ]);
440
+ const rules = {
441
+ "jsonc/no-bigint-literals": "error",
442
+ "jsonc/no-binary-expression": "error",
443
+ "jsonc/no-binary-numeric-literals": "error",
444
+ "jsonc/no-infinity": "error",
445
+ "jsonc/no-nan": "error",
446
+ "jsonc/no-number-props": "error",
447
+ "jsonc/no-undefined-value": "error",
448
+ "jsonc/valid-json-number": "error",
449
+ ...overrides?.jsonc
450
+ };
451
+ if (options.stylistic) {
452
+ Object.assign(rules, {
453
+ "jsonc/comma-dangle": ["error", "never"],
454
+ "jsonc/quotes": ["error", "double", { avoidEscape: false }],
455
+ "jsonc/space-unary-ops": "error"
456
+ });
457
+ const jsoncStylistic = [
458
+ "jsonc/array-bracket-newline",
459
+ "jsonc/array-bracket-spacing",
460
+ "jsonc/array-element-newline",
461
+ "jsonc/comma-style",
462
+ "jsonc/indent",
463
+ "jsonc/key-spacing",
464
+ "jsonc/object-curly-newline",
465
+ "jsonc/object-curly-spacing",
466
+ "jsonc/object-property-newline"
467
+ ];
468
+ Object.assign(rules, jsoncStylistic.reduce((acc, rule) => {
469
+ const name = rule.replace("jsonc/", "stylistic/");
470
+ if (Object.hasOwn(stylisticRules, name)) {
471
+ acc[rule] = stylisticRules[name];
472
+ }
473
+ return acc;
474
+ }, {}));
475
+ }
476
+ return [
477
+ { plugins: { jsonc: jsoncPlugin } },
478
+ {
479
+ files: [Glob.Json],
480
+ languageOptions: { parser: jsoncParser }
481
+ },
482
+ { rules }
483
+ ];
484
+ }
485
+
432
486
  async function vitest(options) {
433
487
  const { overrides, vitest: enabled } = options;
434
488
  if (!enabled) return {};
@@ -524,6 +578,22 @@ async function unicorn(options) {
524
578
  };
525
579
  }
526
580
 
581
+ async function tailwind(options) {
582
+ const { overrides, tailwind: enabled } = options;
583
+ if (!enabled) return {};
584
+ const plugin = await interopDefault(import('eslint-plugin-tailwindcss'));
585
+ const rules = {
586
+ "tailwindcss/classnames-order": "error",
587
+ "tailwindcss/enforces-shorthand": "error",
588
+ "tailwindcss/no-contradicting-classname": "error",
589
+ ...overrides?.tailwind
590
+ };
591
+ return {
592
+ plugins: { tailwindcss: plugin },
593
+ rules
594
+ };
595
+ }
596
+
527
597
  function javascript(options) {
528
598
  const { overrides } = options;
529
599
  const files = [Glob.All];
@@ -970,10 +1040,12 @@ async function defineConfig(options) {
970
1040
  javascript(options),
971
1041
  typescript(options),
972
1042
  ...await vue(options),
1043
+ ...await jsonc(options),
1044
+ stylistic(options),
973
1045
  perfectionist(options),
974
1046
  unicorn(options),
975
- stylistic(options),
976
1047
  vitest(options),
1048
+ tailwind(options),
977
1049
  ignores
978
1050
  ]);
979
1051
  return objects;
package/dist/index.d.ts CHANGED
@@ -15,10 +15,14 @@ declare interface ConfigObject {
15
15
  }
16
16
 
17
17
  declare interface ConfigOptions {
18
+ /** @default false */
19
+ jsonc?: boolean;
18
20
  /** @default true */
19
21
  perfectionist?: boolean;
20
22
  /** @default false */
21
23
  stylistic?: boolean;
24
+ /** @default false */
25
+ tailwind?: boolean;
22
26
  /** @default true */
23
27
  unicorn?: boolean;
24
28
  /** @default false */
@@ -30,8 +34,10 @@ declare interface ConfigOptions {
30
34
  ignores?: Ignores['ignores'];
31
35
  overrides?: {
32
36
  javascript?: Rules;
37
+ jsonc?: Rules;
33
38
  perfectionist?: Rules;
34
39
  stylistic?: Rules;
40
+ tailwind?: Rules;
35
41
  typescript?: Rules;
36
42
  unicorn?: Rules;
37
43
  vitest?: Rules;
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import globals from 'globals';
4
4
  var Glob = /* @__PURE__ */ ((Glob2) => {
5
5
  Glob2["All"] = "**/*.?([cm])[jt]s?(x)";
6
6
  Glob2["Javascript"] = "**/*.?([cm])js?(x)";
7
+ Glob2["Json"] = "**/*.json?([c5])";
7
8
  Glob2["Typescript"] = "**/*.?([cm])ts?(x)";
8
9
  Glob2["Vitest"] = "**/*.{test,spec}.[jt]s";
9
10
  Glob2["Vue"] = "**/*.vue";
@@ -34,6 +35,7 @@ function getIgnores() {
34
35
  const stylisticRules = {
35
36
  "stylistic/array-bracket-newline": ["error", "consistent"],
36
37
  "stylistic/array-bracket-spacing": ["error", "never"],
38
+ "stylistic/array-element-newline": ["error", "consistent"],
37
39
  "stylistic/arrow-parens": ["error", "always"],
38
40
  "stylistic/arrow-spacing": "error",
39
41
  "stylistic/block-spacing": "error",
@@ -358,7 +360,7 @@ async function vue(options) {
358
360
  math: "always"
359
361
  }],
360
362
  "vue/max-attributes-per-line": ["error", {
361
- singleline: 1,
363
+ singleline: Number.MAX_SAFE_INTEGER,
362
364
  multiline: 1
363
365
  }],
364
366
  "vue/multiline-html-element-content-newline": ["error", {
@@ -379,6 +381,7 @@ async function vue(options) {
379
381
  const vueStylistic = [
380
382
  "vue/array-bracket-newline",
381
383
  "vue/array-bracket-spacing",
384
+ "vue/array-element-newline",
382
385
  "vue/key-spacing",
383
386
  "vue/keyword-spacing",
384
387
  "vue/max-len",
@@ -402,9 +405,7 @@ async function vue(options) {
402
405
  }, {}));
403
406
  }
404
407
  return [
405
- {
406
- plugins: { vue: vuePlugin }
407
- },
408
+ { plugins: { vue: vuePlugin } },
408
409
  {
409
410
  files: [Glob.Vue],
410
411
  languageOptions: {
@@ -427,6 +428,59 @@ async function vue(options) {
427
428
  ];
428
429
  }
429
430
 
431
+ async function jsonc(options) {
432
+ const { overrides, jsonc: enabled } = options;
433
+ if (!enabled) return [];
434
+ const [jsoncPlugin, jsoncParser] = await Promise.all([
435
+ interopDefault(import('eslint-plugin-jsonc')),
436
+ interopDefault(import('jsonc-eslint-parser'))
437
+ ]);
438
+ const rules = {
439
+ "jsonc/no-bigint-literals": "error",
440
+ "jsonc/no-binary-expression": "error",
441
+ "jsonc/no-binary-numeric-literals": "error",
442
+ "jsonc/no-infinity": "error",
443
+ "jsonc/no-nan": "error",
444
+ "jsonc/no-number-props": "error",
445
+ "jsonc/no-undefined-value": "error",
446
+ "jsonc/valid-json-number": "error",
447
+ ...overrides?.jsonc
448
+ };
449
+ if (options.stylistic) {
450
+ Object.assign(rules, {
451
+ "jsonc/comma-dangle": ["error", "never"],
452
+ "jsonc/quotes": ["error", "double", { avoidEscape: false }],
453
+ "jsonc/space-unary-ops": "error"
454
+ });
455
+ const jsoncStylistic = [
456
+ "jsonc/array-bracket-newline",
457
+ "jsonc/array-bracket-spacing",
458
+ "jsonc/array-element-newline",
459
+ "jsonc/comma-style",
460
+ "jsonc/indent",
461
+ "jsonc/key-spacing",
462
+ "jsonc/object-curly-newline",
463
+ "jsonc/object-curly-spacing",
464
+ "jsonc/object-property-newline"
465
+ ];
466
+ Object.assign(rules, jsoncStylistic.reduce((acc, rule) => {
467
+ const name = rule.replace("jsonc/", "stylistic/");
468
+ if (Object.hasOwn(stylisticRules, name)) {
469
+ acc[rule] = stylisticRules[name];
470
+ }
471
+ return acc;
472
+ }, {}));
473
+ }
474
+ return [
475
+ { plugins: { jsonc: jsoncPlugin } },
476
+ {
477
+ files: [Glob.Json],
478
+ languageOptions: { parser: jsoncParser }
479
+ },
480
+ { rules }
481
+ ];
482
+ }
483
+
430
484
  async function vitest(options) {
431
485
  const { overrides, vitest: enabled } = options;
432
486
  if (!enabled) return {};
@@ -522,6 +576,22 @@ async function unicorn(options) {
522
576
  };
523
577
  }
524
578
 
579
+ async function tailwind(options) {
580
+ const { overrides, tailwind: enabled } = options;
581
+ if (!enabled) return {};
582
+ const plugin = await interopDefault(import('eslint-plugin-tailwindcss'));
583
+ const rules = {
584
+ "tailwindcss/classnames-order": "error",
585
+ "tailwindcss/enforces-shorthand": "error",
586
+ "tailwindcss/no-contradicting-classname": "error",
587
+ ...overrides?.tailwind
588
+ };
589
+ return {
590
+ plugins: { tailwindcss: plugin },
591
+ rules
592
+ };
593
+ }
594
+
525
595
  function javascript(options) {
526
596
  const { overrides } = options;
527
597
  const files = [Glob.All];
@@ -968,10 +1038,12 @@ async function defineConfig(options) {
968
1038
  javascript(options),
969
1039
  typescript(options),
970
1040
  ...await vue(options),
1041
+ ...await jsonc(options),
1042
+ stylistic(options),
971
1043
  perfectionist(options),
972
1044
  unicorn(options),
973
- stylistic(options),
974
1045
  vitest(options),
1046
+ tailwind(options),
975
1047
  ignores
976
1048
  ]);
977
1049
  return objects;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/eslint-config",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "description": "ESLint config",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,7 +27,9 @@
27
27
  "@stylistic/eslint-plugin": "^2.3.0",
28
28
  "@typescript-eslint/eslint-plugin": "^7.17.0",
29
29
  "@typescript-eslint/parser": "^7.17.0",
30
+ "eslint-plugin-jsonc": "^2.16.0",
30
31
  "eslint-plugin-perfectionist": "^3.0.0",
32
+ "eslint-plugin-tailwindcss": "^3.17.4",
31
33
  "eslint-plugin-unicorn": "^54.0.0",
32
34
  "eslint-plugin-vitest": "^0.5.4",
33
35
  "eslint-plugin-vue": "^9.27.0",