@vinicunca/eslint-config 2.0.11 → 2.0.12

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.js CHANGED
@@ -1,57 +1,3 @@
1
- // src/base.ts
2
- import { isPackageExists } from "local-pkg";
3
- import process3 from "process";
4
-
5
- // src/flags.ts
6
- var ERROR = "error";
7
- var OFF = "off";
8
- var WARN = "warn";
9
- var CONSISTENT = "consistent";
10
- var NEVER = "never";
11
- var ALWAYS = "always";
12
-
13
- // src/plugins.ts
14
- import { default as default2 } from "@stylistic/eslint-plugin";
15
- import { default as default3 } from "@typescript-eslint/eslint-plugin";
16
- import * as parserTs from "@typescript-eslint/parser";
17
- import { default as default4 } from "@vinicunca/eslint-plugin-vinicunca";
18
- import { default as default5 } from "eslint-plugin-eslint-comments";
19
- import * as pluginImport from "eslint-plugin-i";
20
- import { default as default6 } from "eslint-plugin-jsdoc";
21
- import * as pluginJsonc from "eslint-plugin-jsonc";
22
- import { default as default7 } from "eslint-plugin-markdown";
23
- import { default as default8 } from "eslint-plugin-n";
24
- import { default as default9 } from "eslint-plugin-no-only-tests";
25
- import { default as default10 } from "eslint-plugin-perfectionist";
26
- import { default as default11 } from "eslint-plugin-react";
27
- import { default as default12 } from "eslint-plugin-react-hooks";
28
- import { default as default13 } from "eslint-plugin-unicorn";
29
- import { default as default14 } from "eslint-plugin-unused-imports";
30
- import { default as default15 } from "eslint-plugin-vitest";
31
- import { default as default16 } from "eslint-plugin-vue";
32
- import * as pluginYaml from "eslint-plugin-yml";
33
- import { default as default17 } from "jsonc-eslint-parser";
34
- import { default as default18 } from "vue-eslint-parser";
35
- import { default as default19 } from "yaml-eslint-parser";
36
-
37
- // src/configs/comments.ts
38
- function comments() {
39
- return [
40
- {
41
- name: "vinicunca:eslint-comments",
42
- plugins: {
43
- "eslint-comments": default5
44
- },
45
- rules: {
46
- "eslint-comments/no-aggregating-enable": ERROR,
47
- "eslint-comments/no-duplicate-disable": ERROR,
48
- "eslint-comments/no-unlimited-disable": ERROR,
49
- "eslint-comments/no-unused-enable": ERROR
50
- }
51
- }
52
- ];
53
- }
54
-
55
1
  // ../node_modules/.pnpm/@vinicunca+perkakas@0.0.11/node_modules/@vinicunca/perkakas/dist/index.js
56
2
  function purry(fn, args, lazy) {
57
3
  const diff = fn.length - args.length;
@@ -72,6 +18,9 @@ function purry(fn, args, lazy) {
72
18
  function isArray(data) {
73
19
  return Array.isArray(data);
74
20
  }
21
+ function isBoolean(data) {
22
+ return typeof data === "boolean";
23
+ }
75
24
  function isDefined(data) {
76
25
  return typeof data !== "undefined" && data !== null;
77
26
  }
@@ -1026,6 +975,45 @@ function toPairs(object) {
1026
975
  toPairs2.strict = strict;
1027
976
  })(toPairs || (toPairs = {}));
1028
977
 
978
+ // src/base.ts
979
+ import { isPackageExists } from "local-pkg";
980
+ import process3 from "process";
981
+
982
+ // src/flags.ts
983
+ var ERROR = "error";
984
+ var OFF = "off";
985
+ var WARN = "warn";
986
+ var CONSISTENT = "consistent";
987
+ var NEVER = "never";
988
+ var ALWAYS = "always";
989
+
990
+ // src/plugins.ts
991
+ import { default as default2 } from "@vinicunca/eslint-plugin-vinicunca";
992
+ import { default as default3 } from "eslint-plugin-eslint-comments";
993
+ import * as pluginImport from "eslint-plugin-i";
994
+ import { default as default4 } from "eslint-plugin-n";
995
+ import { default as default5 } from "eslint-plugin-perfectionist";
996
+ import { default as default6 } from "eslint-plugin-unicorn";
997
+ import { default as default7 } from "eslint-plugin-unused-imports";
998
+
999
+ // src/configs/comments.ts
1000
+ async function comments() {
1001
+ return [
1002
+ {
1003
+ name: "vinicunca:eslint-comments",
1004
+ plugins: {
1005
+ "eslint-comments": default3
1006
+ },
1007
+ rules: {
1008
+ "eslint-comments/no-aggregating-enable": ERROR,
1009
+ "eslint-comments/no-duplicate-disable": ERROR,
1010
+ "eslint-comments/no-unlimited-disable": ERROR,
1011
+ "eslint-comments/no-unused-enable": ERROR
1012
+ }
1013
+ }
1014
+ ];
1015
+ }
1016
+
1029
1017
  // src/configs/ignores.ts
1030
1018
  import fs from "fs";
1031
1019
  import parseGitignore from "parse-gitignore";
@@ -1079,10 +1067,11 @@ var GLOB_JSON5 = "**/*.json5";
1079
1067
  var GLOB_JSONC = "**/*.jsonc";
1080
1068
  var GLOB_YAML = "**/*.y?(a)ml";
1081
1069
  var GLOB_MARKDOWN = "**/*.md";
1070
+ var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
1082
1071
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
1083
1072
 
1084
1073
  // src/configs/ignores.ts
1085
- function ignores({
1074
+ async function ignores({
1086
1075
  enableGitignore = true,
1087
1076
  items = [],
1088
1077
  replace = false
@@ -1114,13 +1103,13 @@ function ignores({
1114
1103
  }
1115
1104
 
1116
1105
  // src/configs/imports.ts
1117
- function imports() {
1106
+ async function imports() {
1118
1107
  return [
1119
1108
  {
1120
1109
  name: "vinicunca:imports",
1121
1110
  plugins: {
1122
1111
  import: pluginImport,
1123
- vinicunca: default4
1112
+ vinicunca: default2
1124
1113
  },
1125
1114
  rules: {
1126
1115
  "import/export": ERROR,
@@ -1145,7 +1134,7 @@ function imports() {
1145
1134
 
1146
1135
  // src/configs/javascript.ts
1147
1136
  import globals from "globals";
1148
- function javascript(options = {}) {
1137
+ async function javascript(options = {}) {
1149
1138
  const {
1150
1139
  isInEditor = false,
1151
1140
  overrides = {}
@@ -1162,7 +1151,9 @@ function javascript(options = {}) {
1162
1151
  window: "readonly"
1163
1152
  },
1164
1153
  parserOptions: {
1165
- ecmaFeatures: { jsx: true },
1154
+ ecmaFeatures: {
1155
+ jsx: true
1156
+ },
1166
1157
  ecmaVersion: 2022,
1167
1158
  sourceType: "module"
1168
1159
  },
@@ -1173,9 +1164,9 @@ function javascript(options = {}) {
1173
1164
  },
1174
1165
  name: "vinicunca:javascript",
1175
1166
  plugins: {
1176
- "perfectionist": default10,
1177
- "unused-imports": default14,
1178
- "vinicunca": default4
1167
+ "perfectionist": default5,
1168
+ "unused-imports": default7,
1169
+ "vinicunca": default2
1179
1170
  },
1180
1171
  rules: {
1181
1172
  "accessor-pairs": [ERROR, {
@@ -1183,7 +1174,6 @@ function javascript(options = {}) {
1183
1174
  setWithoutGet: true
1184
1175
  }],
1185
1176
  "array-callback-return": [ERROR, { checkForEach: true }],
1186
- "arrow-parens": [ERROR, ALWAYS],
1187
1177
  "block-scoped-var": ERROR,
1188
1178
  "camelcase": [ERROR, {
1189
1179
  allow: ["^UNSAFE_"],
@@ -1396,8 +1386,8 @@ function javascript(options = {}) {
1396
1386
  }],
1397
1387
  "vars-on-top": ERROR,
1398
1388
  "yoda": [ERROR, NEVER],
1399
- ...default4.configs.recommended.rules,
1400
- ...default10.configs["recommended-natural"].rules,
1389
+ ...default2.configs.recommended.rules,
1390
+ ...default5.configs["recommended-natural"].rules,
1401
1391
  "perfectionist/sort-imports": [
1402
1392
  ERROR,
1403
1393
  {
@@ -1434,13 +1424,35 @@ function javascript(options = {}) {
1434
1424
  ];
1435
1425
  }
1436
1426
 
1427
+ // src/utils.ts
1428
+ async function combineConfigs(...configs) {
1429
+ const resolvedConfigs = await Promise.all(configs);
1430
+ return resolvedConfigs.flatMap((config) => Array.isArray(config) ? config : [config]);
1431
+ }
1432
+ function renameRules(rules, from, to) {
1433
+ return Object.fromEntries(
1434
+ Object.entries(rules).map(([key, value]) => {
1435
+ if (key.startsWith(from)) {
1436
+ return [to + key.slice(from.length), value];
1437
+ }
1438
+ ;
1439
+ return [key, value];
1440
+ })
1441
+ );
1442
+ }
1443
+ async function interopDefault(m) {
1444
+ const resolved = await m;
1445
+ return resolved.default || resolved;
1446
+ }
1447
+
1437
1448
  // src/configs/jsdoc.ts
1438
- function jsdoc() {
1449
+ async function jsdoc() {
1439
1450
  return [
1440
1451
  {
1441
1452
  name: "vinicunca:jsdoc",
1442
1453
  plugins: {
1443
- jsdoc: default6
1454
+ // @ts-expect-error missing types
1455
+ jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
1444
1456
  },
1445
1457
  rules: {
1446
1458
  "jsdoc/check-access": WARN,
@@ -1468,10 +1480,22 @@ function jsdoc() {
1468
1480
  }
1469
1481
 
1470
1482
  // src/configs/jsonc.ts
1471
- function jsonc(options = {}) {
1483
+ async function jsonc(options = {}) {
1472
1484
  const {
1473
- overrides = {}
1485
+ files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
1486
+ overrides = {},
1487
+ stylistic: stylistic2 = true
1474
1488
  } = options;
1489
+ const {
1490
+ indent = 2
1491
+ } = isBoolean(stylistic2) ? {} : stylistic2;
1492
+ const [
1493
+ pluginJsonc,
1494
+ parserJsonc
1495
+ ] = await Promise.all([
1496
+ interopDefault(import("eslint-plugin-jsonc")),
1497
+ interopDefault(import("jsonc-eslint-parser"))
1498
+ ]);
1475
1499
  return [
1476
1500
  {
1477
1501
  name: "vinicunca:jsonc:setup",
@@ -1480,17 +1504,12 @@ function jsonc(options = {}) {
1480
1504
  }
1481
1505
  },
1482
1506
  {
1483
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
1507
+ files,
1484
1508
  languageOptions: {
1485
- parser: default17
1509
+ parser: parserJsonc
1486
1510
  },
1487
1511
  name: "vinicunca:jsonc:rules",
1488
1512
  rules: {
1489
- "jsonc/array-bracket-spacing": [ERROR, NEVER],
1490
- "jsonc/comma-dangle": [ERROR, NEVER],
1491
- "jsonc/comma-style": [ERROR, "last"],
1492
- "jsonc/indent": [ERROR, 2],
1493
- "jsonc/key-spacing": [ERROR, { afterColon: true, beforeColon: false }],
1494
1513
  "jsonc/no-bigint-literals": ERROR,
1495
1514
  "jsonc/no-binary-expression": ERROR,
1496
1515
  "jsonc/no-binary-numeric-literals": ERROR,
@@ -1514,14 +1533,21 @@ function jsonc(options = {}) {
1514
1533
  "jsonc/no-undefined-value": ERROR,
1515
1534
  "jsonc/no-unicode-codepoint-escapes": ERROR,
1516
1535
  "jsonc/no-useless-escape": ERROR,
1517
- "jsonc/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
1518
- "jsonc/object-curly-spacing": [ERROR, "always"],
1519
- "jsonc/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
1520
- "jsonc/quote-props": ERROR,
1521
- "jsonc/quotes": ERROR,
1522
1536
  "jsonc/space-unary-ops": ERROR,
1523
1537
  "jsonc/valid-json-number": ERROR,
1524
1538
  "jsonc/vue-custom-block/no-parsing-error": ERROR,
1539
+ ...stylistic2 ? {
1540
+ "jsonc/array-bracket-spacing": [ERROR, NEVER],
1541
+ "jsonc/comma-dangle": [ERROR, NEVER],
1542
+ "jsonc/comma-style": [ERROR, "last"],
1543
+ "jsonc/indent": [ERROR, indent],
1544
+ "jsonc/key-spacing": [ERROR, { afterColon: true, beforeColon: false }],
1545
+ "jsonc/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
1546
+ "jsonc/object-curly-spacing": [ERROR, "always"],
1547
+ "jsonc/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
1548
+ "jsonc/quote-props": ERROR,
1549
+ "jsonc/quotes": ERROR
1550
+ } : {},
1525
1551
  ...overrides
1526
1552
  }
1527
1553
  }
@@ -1529,18 +1555,26 @@ function jsonc(options = {}) {
1529
1555
  }
1530
1556
 
1531
1557
  // src/configs/markdown.ts
1532
- function markdown(options = {}) {
1558
+ async function markdown(options = {}) {
1533
1559
  const {
1534
1560
  componentExts = [],
1561
+ files = [GLOB_MARKDOWN],
1535
1562
  overrides = {}
1536
1563
  } = options;
1537
1564
  return [
1538
1565
  {
1539
1566
  name: "vinicunca:markdown:setup",
1540
1567
  plugins: {
1541
- markdown: default7
1568
+ // @ts-expect-error missing types
1569
+ markdown: await interopDefault(import("eslint-plugin-markdown"))
1542
1570
  }
1543
1571
  },
1572
+ {
1573
+ files,
1574
+ ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
1575
+ name: "vinicunca:markdown:processor",
1576
+ processor: "markdown/markdown"
1577
+ },
1544
1578
  {
1545
1579
  files: [GLOB_MARKDOWN],
1546
1580
  name: "vinicunca:markdown:processor",
@@ -1558,8 +1592,9 @@ function markdown(options = {}) {
1558
1592
  }
1559
1593
  }
1560
1594
  },
1561
- name: "vinicunca:markdown:rules",
1595
+ name: "vinicunca:markdown:disables",
1562
1596
  rules: {
1597
+ "import/newline-after-import": OFF,
1563
1598
  "no-alert": OFF,
1564
1599
  "no-console": OFF,
1565
1600
  "no-undef": OFF,
@@ -1606,12 +1641,12 @@ function markdown(options = {}) {
1606
1641
  }
1607
1642
 
1608
1643
  // src/configs/node.ts
1609
- function node() {
1644
+ async function node() {
1610
1645
  return [
1611
1646
  {
1612
1647
  name: "vinicunca:node",
1613
1648
  plugins: {
1614
- node: default8
1649
+ node: default4
1615
1650
  },
1616
1651
  rules: {
1617
1652
  "node/handle-callback-err": [ERROR, "^(err|error)$"],
@@ -1630,23 +1665,46 @@ function node() {
1630
1665
 
1631
1666
  // src/configs/react.ts
1632
1667
  var STR_PARENS_NEW_LINE = "parens-new-line";
1633
- function react(options = {}) {
1668
+ async function react(options = {}) {
1634
1669
  const {
1670
+ files = [GLOB_JSX, GLOB_TSX],
1635
1671
  overrides = {}
1636
1672
  } = options;
1673
+ const [
1674
+ pluginReact,
1675
+ pluginReactHooks
1676
+ ] = await Promise.all([
1677
+ // @ts-expect-error missing types
1678
+ interopDefault(import("eslint-plugin-react")),
1679
+ // @ts-expect-error missing types
1680
+ interopDefault(import("eslint-plugin-react-hooks"))
1681
+ ]);
1637
1682
  return [
1638
1683
  {
1639
1684
  name: "vinicunca:react:setup",
1640
1685
  plugins: {
1641
- "react": default11,
1642
- "react-hooks": default12
1686
+ "react": pluginReact,
1687
+ "react-hooks": pluginReactHooks
1688
+ },
1689
+ settings: {
1690
+ react: {
1691
+ version: "detect"
1692
+ }
1643
1693
  }
1644
1694
  },
1645
1695
  {
1696
+ files,
1697
+ languageOptions: {
1698
+ parserOptions: {
1699
+ ecmaFeatures: {
1700
+ jsx: true
1701
+ }
1702
+ }
1703
+ },
1646
1704
  name: "vinicunca:react:rules",
1647
1705
  rules: {
1648
- ...default11.configs.recommended.rules,
1649
- ...default12.configs.recommended.rules,
1706
+ ...pluginReact.configs.recommended.rules,
1707
+ ...pluginReactHooks.configs.recommended.rules,
1650
1708
  "react/boolean-prop-naming": [OFF, {
1651
1709
  message: "",
1652
1710
  propTypeNames: ["bool", "mutuallyExclusiveTrueProps"],
@@ -1706,24 +1764,19 @@ function react(options = {}) {
1706
1764
  return: STR_PARENS_NEW_LINE
1707
1765
  }],
1708
1766
  "react/no-danger": WARN,
1767
+ "react/no-unescaped-entities": OFF,
1709
1768
  "react/prop-types": OFF,
1710
1769
  "react/react-in-jsx-scope": OFF,
1711
1770
  "react/self-closing-comp": ERROR,
1712
1771
  "react/style-prop-object": ERROR,
1713
- "style/jsx-quotes": [ERROR, "prefer-double"],
1714
1772
  ...overrides
1715
- },
1716
- settings: {
1717
- react: {
1718
- version: "detect"
1719
- }
1720
1773
  }
1721
1774
  }
1722
1775
  ];
1723
1776
  }
1724
1777
 
1725
1778
  // src/configs/sort-package-json.ts
1726
- function sortPackageJson() {
1779
+ async function sortPackageJson() {
1727
1780
  return [
1728
1781
  {
1729
1782
  files: ["**/package.json"],
@@ -1939,19 +1992,35 @@ function sortTsconfig() {
1939
1992
  }
1940
1993
 
1941
1994
  // src/configs/stylistic.ts
1942
- function stylistic() {
1995
+ var STYLISTIC_CONFIG_DEFAULTS = {
1996
+ indent: 2,
1997
+ jsx: true,
1998
+ quotes: "single",
1999
+ semi: true
2000
+ };
2001
+ async function stylistic(options = {}) {
2002
+ const {
2003
+ indent,
2004
+ quotes,
2005
+ semi
2006
+ } = {
2007
+ ...STYLISTIC_CONFIG_DEFAULTS,
2008
+ ...options
2009
+ };
2010
+ const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
1943
2011
  return [
1944
2012
  {
1945
2013
  name: "vinicunca:stylistic",
1946
2014
  plugins: {
1947
- style: default2,
1948
- vinicunca: default4
2015
+ style: pluginStylistic,
2016
+ vinicunca: default2
1949
2017
  },
1950
2018
  rules: {
1951
2019
  "curly": [ERROR, "all"],
1952
2020
  "style/array-bracket-newline": [ERROR, CONSISTENT],
1953
2021
  "style/array-bracket-spacing": [ERROR, NEVER],
1954
2022
  "style/array-element-newline": [ERROR, CONSISTENT],
2023
+ "style/arrow-parens": [ERROR, ALWAYS],
1955
2024
  "style/arrow-spacing": [ERROR, { after: true, before: true }],
1956
2025
  "style/block-spacing": [ERROR, ALWAYS],
1957
2026
  "style/brace-style": [ERROR],
@@ -1962,7 +2031,7 @@ function stylistic() {
1962
2031
  "style/dot-location": [ERROR, "property"],
1963
2032
  "style/eol-last": ERROR,
1964
2033
  "style/func-call-spacing": [ERROR, NEVER],
1965
- "style/indent": [ERROR, 2, {
2034
+ "style/indent": [ERROR, indent, {
1966
2035
  ArrayExpression: 1,
1967
2036
  CallExpression: { arguments: 1 },
1968
2037
  FunctionDeclaration: { body: 1, parameters: 1 },
@@ -2000,6 +2069,7 @@ function stylistic() {
2000
2069
  offsetTernaryExpressions: true,
2001
2070
  outerIIFEBody: 1
2002
2071
  }],
2072
+ "style/indent-binary-ops": [ERROR, indent],
2003
2073
  "style/key-spacing": [ERROR, { afterColon: true, beforeColon: false }],
2004
2074
  "style/keyword-spacing": [ERROR, { after: true, before: true }],
2005
2075
  "style/lines-between-class-members": [ERROR, ALWAYS, { exceptAfterSingleLine: true }],
@@ -2029,9 +2099,9 @@ function stylistic() {
2029
2099
  "style/operator-linebreak": [ERROR, "before"],
2030
2100
  "style/padded-blocks": [ERROR, { blocks: NEVER, classes: NEVER, switches: NEVER }],
2031
2101
  "style/quote-props": [ERROR, "consistent-as-needed"],
2032
- "style/quotes": [ERROR, "single"],
2102
+ "style/quotes": [ERROR, quotes],
2033
2103
  "style/rest-spread-spacing": [ERROR, NEVER],
2034
- "style/semi": [ERROR, ALWAYS],
2104
+ "style/semi": [ERROR, semi ? ALWAYS : NEVER],
2035
2105
  "style/semi-spacing": [ERROR, { after: true, before: false }],
2036
2106
  "style/space-before-blocks": [ERROR, ALWAYS],
2037
2107
  "style/space-before-function-paren": [ERROR, {
@@ -2075,27 +2145,36 @@ function stylistic() {
2075
2145
  }
2076
2146
 
2077
2147
  // src/configs/test.ts
2078
- function test(options = {}) {
2148
+ async function test(options = {}) {
2079
2149
  const {
2150
+ files = GLOB_TESTS,
2080
2151
  isInEditor = false,
2081
2152
  overrides = {}
2082
2153
  } = options;
2154
+ const [
2155
+ pluginVitest,
2156
+ pluginNoOnlyTests
2157
+ ] = await Promise.all([
2158
+ interopDefault(import("eslint-plugin-vitest")),
2159
+ // @ts-expect-error missing types
2160
+ interopDefault(import("eslint-plugin-no-only-tests"))
2161
+ ]);
2083
2162
  return [
2084
2163
  {
2085
2164
  name: "vinicunca:test:setup",
2086
2165
  plugins: {
2087
2166
  test: {
2088
- ...default15,
2167
+ ...pluginVitest,
2089
2168
  rules: {
2090
- ...default15.rules,
2169
+ ...pluginVitest.rules,
2091
2170
  // extend `test/no-only-tests` rule
2092
- ...default9.rules
2171
+ ...pluginNoOnlyTests.rules
2093
2172
  }
2094
2173
  }
2095
2174
  }
2096
2175
  },
2097
2176
  {
2098
- files: GLOB_TESTS,
2177
+ files,
2099
2178
  name: "vinicunca:test:rules",
2100
2179
  rules: {
2101
2180
  "test/consistent-test-it": [ERROR, { fn: "it", withinDescribe: "it" }],
@@ -2111,31 +2190,17 @@ function test(options = {}) {
2111
2190
 
2112
2191
  // src/configs/typescript.ts
2113
2192
  import process from "process";
2114
-
2115
- // src/utils.ts
2116
- function combineConfigs(...configs) {
2117
- return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
2118
- }
2119
- function renameRules(rules, from, to) {
2120
- return Object.fromEntries(
2121
- Object.entries(rules).map(([key, value]) => {
2122
- if (key.startsWith(from)) {
2123
- return [to + key.slice(from.length), value];
2124
- }
2125
- ;
2126
- return [key, value];
2127
- })
2128
- );
2129
- }
2130
-
2131
- // src/configs/typescript.ts
2132
- function typescript(options) {
2193
+ async function typescript(options = {}) {
2133
2194
  const {
2134
2195
  componentExts = [],
2135
2196
  overrides = {},
2136
2197
  parserOptions = {},
2137
2198
  tsconfigPath = []
2138
2199
  } = options ?? {};
2200
+ const files = options.files ?? [
2201
+ GLOB_SRC,
2202
+ ...componentExts.map((ext) => `**/*.${ext}`)
2203
+ ];
2139
2204
  const typeAwareRules = {
2140
2205
  "dot-notation": OFF,
2141
2206
  "no-implied-eval": OFF,
@@ -2160,21 +2225,28 @@ function typescript(options) {
2160
2225
  };
2161
2226
  additionalTypeAwareRules = typeAwareRules;
2162
2227
  }
2228
+ const [
2229
+ pluginTs,
2230
+ parserTs,
2231
+ pluginStylistic
2232
+ ] = await Promise.all([
2233
+ interopDefault(import("@typescript-eslint/eslint-plugin")),
2234
+ interopDefault(import("@typescript-eslint/parser")),
2235
+ interopDefault(import("@stylistic/eslint-plugin"))
2236
+ ]);
2163
2237
  return [
2164
2238
  {
2165
2239
  // Install the plugins without globs, so they can be configured separately.
2166
2240
  name: "vinicunca:typescript:setup",
2167
2241
  plugins: {
2168
2242
  import: pluginImport,
2169
- ts: default3,
2170
- vinicunca: default4
2243
+ style: pluginStylistic,
2244
+ ts: pluginTs,
2245
+ vinicunca: default2
2171
2246
  }
2172
2247
  },
2173
2248
  {
2174
- files: [
2175
- GLOB_SRC,
2176
- ...componentExts.map((ext) => `**/*.${ext}`)
2177
- ],
2249
+ files,
2178
2250
  languageOptions: {
2179
2251
  parser: parserTs,
2180
2252
  parserOptions: {
@@ -2187,12 +2259,12 @@ function typescript(options) {
2187
2259
  name: "vinicunca:typescript:rules",
2188
2260
  rules: {
2189
2261
  ...renameRules(
2190
- default3.configs["eslint-recommended"].overrides[0].rules,
2262
+ pluginTs.configs["eslint-recommended"].overrides[0].rules,
2191
2263
  "@typescript-eslint/",
2192
2264
  "ts/"
2193
2265
  ),
2194
2266
  ...renameRules(
2195
- default3.configs.strict.rules,
2267
+ pluginTs.configs.strict.rules,
2196
2268
  "@typescript-eslint/",
2197
2269
  "ts/"
2198
2270
  ),
@@ -2203,6 +2275,8 @@ function typescript(options) {
2203
2275
  "no-unused-vars": OFF,
2204
2276
  "no-use-before-define": OFF,
2205
2277
  "no-useless-constructor": OFF,
2278
+ "style/type-generic-spacing": ERROR,
2279
+ "style/type-named-tuple-spacing": ERROR,
2206
2280
  "ts/ban-ts-comment": [ERROR, { "ts-ignore": "allow-with-description" }],
2207
2281
  "ts/ban-types": [ERROR, { types: { Function: false } }],
2208
2282
  "ts/consistent-type-definitions": [ERROR, "interface"],
@@ -2231,8 +2305,6 @@ function typescript(options) {
2231
2305
  "ts/parameter-properties": OFF,
2232
2306
  "ts/prefer-ts-expect-error": ERROR,
2233
2307
  "ts/triple-slash-reference": OFF,
2234
- "vinicunca/generic-spacing": ERROR,
2235
- "vinicunca/named-tuple-spacing": ERROR,
2236
2308
  "vinicunca/no-cjs-exports": ERROR,
2237
2309
  "vinicunca/no-ts-export-equal": ERROR,
2238
2310
  ...additionalTypeAwareRules,
@@ -2267,7 +2339,7 @@ function typescript(options) {
2267
2339
  }
2268
2340
 
2269
2341
  // src/configs/unicorn.ts
2270
- function unicorn(options = {}) {
2342
+ async function unicorn(options = {}) {
2271
2343
  const {
2272
2344
  overrides = {}
2273
2345
  } = options;
@@ -2275,7 +2347,7 @@ function unicorn(options = {}) {
2275
2347
  {
2276
2348
  name: "vinicunca:unicorn",
2277
2349
  plugins: {
2278
- unicorn: default13
2350
+ unicorn: default6
2279
2351
  },
2280
2352
  rules: {
2281
2353
  "unicorn/error-message": ERROR,
@@ -2297,13 +2369,48 @@ function unicorn(options = {}) {
2297
2369
  ];
2298
2370
  }
2299
2371
 
2372
+ // src/configs/unocss.ts
2373
+ async function unocss(options = {}) {
2374
+ const {
2375
+ attributify = false,
2376
+ strict = false
2377
+ } = options;
2378
+ const [
2379
+ pluginUnoCSS
2380
+ ] = await Promise.all([
2381
+ interopDefault(import("@unocss/eslint-plugin"))
2382
+ ]);
2383
+ return [
2384
+ {
2385
+ name: "vinicunca:unocss",
2386
+ plugins: {
2387
+ unocss: pluginUnoCSS
2388
+ },
2389
+ rules: {
2390
+ "unocss/order": "warn",
2391
+ ...attributify ? {
2392
+ "unocss/order-attributify": "warn"
2393
+ } : {},
2394
+ ...strict ? {
2395
+ "unocss/blocklist": "error"
2396
+ } : {}
2397
+ }
2398
+ }
2399
+ ];
2400
+ }
2401
+
2300
2402
  // src/configs/vue.ts
2301
2403
  import process2 from "process";
2302
- function vue(options = {}) {
2404
+ async function vue(options = {}) {
2303
2405
  const {
2406
+ files = [GLOB_VUE],
2304
2407
  overrides = {},
2408
+ stylistic: stylistic2 = true,
2305
2409
  typescript: typescript2 = {}
2306
2410
  } = options;
2411
+ const {
2412
+ indent = 2
2413
+ } = isBoolean(stylistic2) ? {} : stylistic2;
2307
2414
  let tsConfigOptions = {};
2308
2415
  const tsconfigPath = typescript2.tsconfigPath ?? [];
2309
2416
  if (!isEmpty(tsconfigPath)) {
@@ -2312,34 +2419,42 @@ function vue(options = {}) {
2312
2419
  tsconfigRootDir: process2.cwd()
2313
2420
  };
2314
2421
  }
2422
+ const [
2423
+ pluginVue,
2424
+ parserVue
2425
+ ] = await Promise.all([
2426
+ // @ts-expect-error missing types
2427
+ interopDefault(import("eslint-plugin-vue")),
2428
+ interopDefault(import("vue-eslint-parser"))
2429
+ ]);
2315
2430
  return [
2316
2431
  {
2317
2432
  name: "vinicunca:vue:setup",
2318
2433
  plugins: {
2319
- vue: default16
2434
+ vue: pluginVue
2320
2435
  }
2321
2436
  },
2322
2437
  {
2323
- files: [GLOB_VUE],
2438
+ files,
2324
2439
  languageOptions: {
2325
- parser: default18,
2440
+ parser: parserVue,
2326
2441
  parserOptions: {
2327
2442
  ecmaFeatures: {
2328
2443
  jsx: true
2329
2444
  },
2330
2445
  extraFileExtensions: [".vue"],
2331
- parser: typescript2.enabled ? parserTs : void 0,
2446
+ parser: typescript2.enabled ? await interopDefault(import("@typescript-eslint/parser")) : null,
2332
2447
  sourceType: "module",
2333
2448
  ...tsConfigOptions
2334
2449
  }
2335
2450
  },
2336
2451
  name: "vinicunca:vue:rules",
2337
- processor: default16.processors[".vue"],
2452
+ processor: pluginVue.processors[".vue"],
2338
2453
  rules: {
2339
- ...default16.configs.base.rules,
2340
- ...default16.configs["vue3-essential"].rules,
2341
- ...default16.configs["vue3-strongly-recommended"].rules,
2342
- ...default16.configs["vue3-recommended"].rules,
2454
+ ...pluginVue.configs.base.rules,
2455
+ ...pluginVue.configs["vue3-essential"].rules,
2456
+ ...pluginVue.configs["vue3-strongly-recommended"].rules,
2457
+ ...pluginVue.configs["vue3-recommended"].rules,
2343
2458
  "node/prefer-global/process": OFF,
2344
2459
  "vue/array-bracket-spacing": [ERROR, NEVER],
2345
2460
  "vue/arrow-spacing": [ERROR, {
@@ -2373,6 +2488,7 @@ function vue(options = {}) {
2373
2488
  "vue/html-comment-content-spacing": [ERROR, ALWAYS, {
2374
2489
  exceptions: ["-"]
2375
2490
  }],
2491
+ "vue/html-indent": [ERROR, indent],
2376
2492
  "vue/key-spacing": [ERROR, {
2377
2493
  afterColon: true,
2378
2494
  beforeColon: false
@@ -2432,10 +2548,23 @@ function vue(options = {}) {
2432
2548
  }
2433
2549
 
2434
2550
  // src/configs/yaml.ts
2435
- function yaml(options = {}) {
2551
+ async function yaml(options = {}) {
2436
2552
  const {
2437
- overrides = {}
2553
+ files = [GLOB_YAML],
2554
+ overrides = {},
2555
+ stylistic: stylistic2 = true
2438
2556
  } = options;
2557
+ const {
2558
+ indent = 2,
2559
+ quotes = "single"
2560
+ } = isBoolean(stylistic2) ? {} : stylistic2;
2561
+ const [
2562
+ pluginYaml,
2563
+ parserYaml
2564
+ ] = await Promise.all([
2565
+ interopDefault(import("eslint-plugin-yml")),
2566
+ interopDefault(import("yaml-eslint-parser"))
2567
+ ]);
2439
2568
  return [
2440
2569
  {
2441
2570
  name: "vinicunca:yaml:setup",
@@ -2444,9 +2573,9 @@ function yaml(options = {}) {
2444
2573
  }
2445
2574
  },
2446
2575
  {
2447
- files: [GLOB_YAML],
2576
+ files,
2448
2577
  languageOptions: {
2449
- parser: default19
2578
+ parser: parserYaml
2450
2579
  },
2451
2580
  name: "vinicunca:yaml:rules",
2452
2581
  rules: {
@@ -2459,14 +2588,14 @@ function yaml(options = {}) {
2459
2588
  "yaml/flow-mapping-curly-spacing": ERROR,
2460
2589
  "yaml/flow-sequence-bracket-newline": ERROR,
2461
2590
  "yaml/flow-sequence-bracket-spacing": ERROR,
2462
- "yaml/indent": [ERROR, 2],
2591
+ "yaml/indent": [ERROR, indent === "tab" ? 2 : indent],
2463
2592
  "yaml/key-spacing": ERROR,
2464
2593
  "yaml/no-empty-key": ERROR,
2465
2594
  "yaml/no-empty-sequence-entry": ERROR,
2466
2595
  "yaml/no-irregular-whitespace": ERROR,
2467
2596
  "yaml/no-tab-indent": ERROR,
2468
2597
  "yaml/plain-scalar": ERROR,
2469
- "yaml/quotes": [ERROR, { avoidEscape: false, prefer: "single" }],
2598
+ "yaml/quotes": [ERROR, { avoidEscape: false, prefer: quotes }],
2470
2599
  "yaml/spaced-comment": ERROR,
2471
2600
  "yaml/vue-custom-block/no-parsing-error": ERROR,
2472
2601
  ...overrides
@@ -2482,7 +2611,7 @@ var VuePackages = [
2482
2611
  "vitepress",
2483
2612
  "@slidev/cli"
2484
2613
  ];
2485
- function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
2614
+ async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
2486
2615
  const {
2487
2616
  componentExts = [],
2488
2617
  isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
@@ -2490,14 +2619,24 @@ function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
2490
2619
  markdown: enableMarkdown = true,
2491
2620
  overrides = {},
2492
2621
  react: enableReact = false,
2493
- stylistic: enableStylistic = true,
2494
2622
  test: enableTest = true,
2495
2623
  typescript: tsOptions = {},
2624
+ unocss: enableUnoCSS = false,
2496
2625
  vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
2497
2626
  yaml: enableYaml = true
2498
2627
  } = options;
2628
+ let stylisticOptions = true;
2629
+ if (options.stylistic === false) {
2630
+ stylisticOptions = false;
2631
+ } else if (isObject(options.stylistic)) {
2632
+ stylisticOptions = {
2633
+ ...options.stylistic,
2634
+ jsx: options.jsx ?? true
2635
+ };
2636
+ }
2499
2637
  const configs = [];
2500
2638
  configs.push(
2639
+ ignores(options.ignores),
2501
2640
  javascript({
2502
2641
  isInEditor,
2503
2642
  overrides: overrides.javascript
@@ -2522,7 +2661,7 @@ function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
2522
2661
  overrides: overrides.typescript
2523
2662
  }));
2524
2663
  }
2525
- if (enableStylistic) {
2664
+ if (stylisticOptions) {
2526
2665
  configs.push(stylistic());
2527
2666
  }
2528
2667
  if (enableTest) {
@@ -2542,10 +2681,21 @@ function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
2542
2681
  }));
2543
2682
  }
2544
2683
  ;
2684
+ if (enableReact) {
2685
+ configs.push(react({
2686
+ overrides: overrides.react
2687
+ }));
2688
+ }
2689
+ if (enableUnoCSS) {
2690
+ configs.push(unocss(
2691
+ isBoolean(enableUnoCSS) ? {} : enableUnoCSS
2692
+ ));
2693
+ }
2545
2694
  if (enableJsonc) {
2546
2695
  configs.push(
2547
2696
  jsonc({
2548
- overrides: overrides.jsonc
2697
+ overrides: overrides.jsonc,
2698
+ stylistic: stylisticOptions
2549
2699
  }),
2550
2700
  sortPackageJson(),
2551
2701
  sortTsconfig()
@@ -2553,7 +2703,8 @@ function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
2553
2703
  }
2554
2704
  if (enableYaml) {
2555
2705
  configs.push(yaml({
2556
- overrides: overrides.yaml
2706
+ overrides: overrides.yaml,
2707
+ stylistic: stylisticOptions
2557
2708
  }));
2558
2709
  }
2559
2710
  ;
@@ -2564,20 +2715,12 @@ function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
2564
2715
  }));
2565
2716
  }
2566
2717
  ;
2567
- if (enableReact) {
2568
- configs.push(react({
2569
- overrides: overrides.react
2570
- }));
2571
- }
2572
2718
  configs.push(ignores(options.ignores));
2573
2719
  return combineConfigs(
2574
2720
  ...configs,
2575
2721
  ...userConfigs
2576
2722
  );
2577
2723
  }
2578
-
2579
- // src/index.ts
2580
- var src_default = vinicuncaESLint;
2581
2724
  export {
2582
2725
  GLOB_EXCLUDE,
2583
2726
  GLOB_JS,
@@ -2587,6 +2730,7 @@ export {
2587
2730
  GLOB_JSX,
2588
2731
  GLOB_MARKDOWN,
2589
2732
  GLOB_MARKDOWN_CODE,
2733
+ GLOB_MARKDOWN_IN_MARKDOWN,
2590
2734
  GLOB_SRC,
2591
2735
  GLOB_SRC_EXT,
2592
2736
  GLOB_TESTS,
@@ -2596,36 +2740,21 @@ export {
2596
2740
  GLOB_YAML,
2597
2741
  combineConfigs,
2598
2742
  comments,
2599
- src_default as default,
2600
2743
  ignores,
2601
2744
  imports,
2745
+ interopDefault,
2602
2746
  javascript,
2603
2747
  jsdoc,
2604
2748
  jsonc,
2605
2749
  markdown,
2606
2750
  node,
2607
- default17 as parserJsonc,
2608
- parserTs,
2609
- default18 as parserVue,
2610
- default19 as parserYaml,
2611
- default5 as pluginComments,
2751
+ default3 as pluginComments,
2612
2752
  pluginImport,
2613
- default6 as pluginJsdoc,
2614
- pluginJsonc,
2615
- default7 as pluginMarkdown,
2616
- default9 as pluginNoOnlyTests,
2617
- default8 as pluginNode,
2618
- default10 as pluginPerfectionist,
2619
- default11 as pluginReact,
2620
- default12 as pluginReactHooks,
2621
- default2 as pluginStylistic,
2622
- default3 as pluginTs,
2623
- default13 as pluginUnicorn,
2624
- default14 as pluginUnusedImports,
2625
- default4 as pluginVinicunca,
2626
- default15 as pluginVitest,
2627
- default16 as pluginVue,
2628
- pluginYaml,
2753
+ default4 as pluginNode,
2754
+ default5 as pluginPerfectionist,
2755
+ default6 as pluginUnicorn,
2756
+ default7 as pluginUnusedImports,
2757
+ default2 as pluginVinicunca,
2629
2758
  react,
2630
2759
  renameRules,
2631
2760
  sortPackageJson,
@@ -2634,6 +2763,7 @@ export {
2634
2763
  test,
2635
2764
  typescript,
2636
2765
  unicorn,
2766
+ unocss,
2637
2767
  vinicuncaESLint,
2638
2768
  vue,
2639
2769
  yaml