@vinicunca/eslint-config 2.0.12 → 2.1.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.js CHANGED
@@ -15,9 +15,6 @@ function purry(fn, args, lazy) {
15
15
  }
16
16
  throw new Error("Wrong number of arguments");
17
17
  }
18
- function isArray(data) {
19
- return Array.isArray(data);
20
- }
21
18
  function isBoolean(data) {
22
19
  return typeof data === "boolean";
23
20
  }
@@ -36,21 +33,6 @@ function toString(value) {
36
33
  function isObject(data) {
37
34
  return toString(data) === "[object Object]";
38
35
  }
39
- function isString(data) {
40
- return typeof data === "string";
41
- }
42
- function isEmpty(data) {
43
- if (isArray(data) || isString(data)) {
44
- return data.length === 0;
45
- }
46
- if (isObject(data)) {
47
- for (const _ in data) {
48
- return false;
49
- }
50
- return !(data instanceof RegExp);
51
- }
52
- return false;
53
- }
54
36
  function _countBy(indexed) {
55
37
  return (array, fn) => {
56
38
  return array.reduce((ret, item, index) => {
@@ -977,7 +959,7 @@ function toPairs(object) {
977
959
 
978
960
  // src/base.ts
979
961
  import { isPackageExists } from "local-pkg";
980
- import process3 from "process";
962
+ import process2 from "process";
981
963
 
982
964
  // src/flags.ts
983
965
  var ERROR = "error";
@@ -1019,16 +1001,50 @@ import fs from "fs";
1019
1001
  import parseGitignore from "parse-gitignore";
1020
1002
 
1021
1003
  // src/globs.ts
1004
+ var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
1005
+ var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
1022
1006
  var GLOB_JS = "**/*.?([cm])js";
1023
1007
  var GLOB_JSX = "**/*.?([cm])jsx";
1024
1008
  var GLOB_TS = "**/*.?([cm])ts";
1025
1009
  var GLOB_TSX = "**/*.?([cm])tsx";
1010
+ var GLOB_STYLE = "**/*.{c,le,sc}ss";
1011
+ var GLOB_CSS = "**/*.css";
1012
+ var GLOB_POSTCSS = "**/*.{p,post}css";
1013
+ var GLOB_LESS = "**/*.less";
1014
+ var GLOB_SCSS = "**/*.scss";
1015
+ var GLOB_JSON = "**/*.json";
1016
+ var GLOB_JSON5 = "**/*.json5";
1017
+ var GLOB_JSONC = "**/*.jsonc";
1018
+ var GLOB_MARKDOWN = "**/*.md";
1019
+ var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
1020
+ var GLOB_VUE = "**/*.vue";
1021
+ var GLOB_YAML = "**/*.y?(a)ml";
1022
+ var GLOB_HTML = "**/*.htm?(l)";
1023
+ var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
1024
+ var GLOB_TESTS = [
1025
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
1026
+ `**/*.spec.${GLOB_SRC_EXT}`,
1027
+ `**/*.test.${GLOB_SRC_EXT}`,
1028
+ `**/*.bench.${GLOB_SRC_EXT}`,
1029
+ `**/*.benchmark.${GLOB_SRC_EXT}`
1030
+ ];
1031
+ var GLOB_ALL_SRC = [
1032
+ GLOB_SRC,
1033
+ GLOB_STYLE,
1034
+ GLOB_JSON,
1035
+ GLOB_JSON5,
1036
+ GLOB_MARKDOWN,
1037
+ GLOB_VUE,
1038
+ GLOB_YAML,
1039
+ GLOB_HTML
1040
+ ];
1026
1041
  var GLOB_EXCLUDE = [
1027
1042
  "**/node_modules",
1028
1043
  "**/dist",
1029
1044
  "**/package-lock.json",
1030
1045
  "**/yarn.lock",
1031
1046
  "**/pnpm-lock.yaml",
1047
+ "**/bun.lockb",
1032
1048
  "**/output",
1033
1049
  "**/coverage",
1034
1050
  "**/temp",
@@ -1052,23 +1068,6 @@ var GLOB_EXCLUDE = [
1052
1068
  "**/auto-import?(s).d.ts",
1053
1069
  "**/components.d.ts"
1054
1070
  ];
1055
- var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
1056
- var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
1057
- var GLOB_TESTS = [
1058
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
1059
- `**/*.spec.${GLOB_SRC_EXT}`,
1060
- `**/*.test.${GLOB_SRC_EXT}`,
1061
- `**/*.bench.${GLOB_SRC_EXT}`,
1062
- `**/*.benchmark.${GLOB_SRC_EXT}`
1063
- ];
1064
- var GLOB_VUE = "**/*.vue";
1065
- var GLOB_JSON = "**/*.json";
1066
- var GLOB_JSON5 = "**/*.json5";
1067
- var GLOB_JSONC = "**/*.jsonc";
1068
- var GLOB_YAML = "**/*.y?(a)ml";
1069
- var GLOB_MARKDOWN = "**/*.md";
1070
- var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
1071
- var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
1072
1071
 
1073
1072
  // src/configs/ignores.ts
1074
1073
  async function ignores({
@@ -1144,6 +1143,7 @@ async function javascript(options = {}) {
1144
1143
  languageOptions: {
1145
1144
  ecmaVersion: 2022,
1146
1145
  globals: {
1146
+ ...globals.browser,
1147
1147
  ...globals.es2021,
1148
1148
  ...globals.node,
1149
1149
  document: "readonly",
@@ -1426,8 +1426,8 @@ async function javascript(options = {}) {
1426
1426
 
1427
1427
  // src/utils.ts
1428
1428
  async function combineConfigs(...configs) {
1429
- const resolvedConfigs = await Promise.all(configs);
1430
- return resolvedConfigs.flatMap((config) => Array.isArray(config) ? config : [config]);
1429
+ const resolved = await Promise.all(configs);
1430
+ return resolved.flat();
1431
1431
  }
1432
1432
  function renameRules(rules, from, to) {
1433
1433
  return Object.fromEntries(
@@ -1444,9 +1444,35 @@ async function interopDefault(m) {
1444
1444
  const resolved = await m;
1445
1445
  return resolved.default || resolved;
1446
1446
  }
1447
+ var parserPlain = {
1448
+ meta: {
1449
+ name: "parser-plain"
1450
+ },
1451
+ parseForESLint: (code) => ({
1452
+ ast: {
1453
+ body: [],
1454
+ comments: [],
1455
+ loc: { end: code.length, start: 0 },
1456
+ range: [0, code.length],
1457
+ tokens: [],
1458
+ type: "Program"
1459
+ },
1460
+ scopeManager: null,
1461
+ services: { isPlain: true },
1462
+ visitorKeys: {
1463
+ Program: []
1464
+ }
1465
+ })
1466
+ };
1467
+ function toArray(value) {
1468
+ return Array.isArray(value) ? value : [value];
1469
+ }
1447
1470
 
1448
1471
  // src/configs/jsdoc.ts
1449
- async function jsdoc() {
1472
+ async function jsdoc(options = {}) {
1473
+ const {
1474
+ stylistic: stylistic2 = true
1475
+ } = options;
1450
1476
  return [
1451
1477
  {
1452
1478
  name: "vinicunca:jsdoc",
@@ -1473,7 +1499,11 @@ async function jsdoc() {
1473
1499
  "jsdoc/require-returns-check": WARN,
1474
1500
  "jsdoc/require-returns-description": WARN,
1475
1501
  "jsdoc/require-yields-check": WARN,
1476
- "jsdoc/valid-types": WARN
1502
+ "jsdoc/valid-types": WARN,
1503
+ ...stylistic2 ? {
1504
+ "jsdoc/check-alignment": "warn",
1505
+ "jsdoc/multiline-blocks": "warn"
1506
+ } : {}
1477
1507
  }
1478
1508
  }
1479
1509
  ];
@@ -1555,30 +1585,41 @@ async function jsonc(options = {}) {
1555
1585
  }
1556
1586
 
1557
1587
  // src/configs/markdown.ts
1588
+ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
1558
1589
  async function markdown(options = {}) {
1559
1590
  const {
1560
1591
  componentExts = [],
1561
1592
  files = [GLOB_MARKDOWN],
1562
1593
  overrides = {}
1563
1594
  } = options;
1595
+ const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
1564
1596
  return [
1565
1597
  {
1566
1598
  name: "vinicunca:markdown:setup",
1567
1599
  plugins: {
1568
- // @ts-expect-error missing types
1569
- markdown: await interopDefault(import("eslint-plugin-markdown"))
1600
+ markdown: markdown2
1570
1601
  }
1571
1602
  },
1572
1603
  {
1573
1604
  files,
1574
1605
  ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
1575
1606
  name: "vinicunca:markdown:processor",
1576
- processor: "markdown/markdown"
1607
+ /**
1608
+ * `eslint-plugin-markdown` only creates virtual files for code blocks,
1609
+ * but not the markdown file itself. We use `eslint-merge-processors` to
1610
+ * add a pass-through processor for the markdown file itself.
1611
+ */
1612
+ processor: mergeProcessors([
1613
+ markdown2.processors.markdown,
1614
+ processorPassThrough
1615
+ ])
1577
1616
  },
1578
1617
  {
1579
- files: [GLOB_MARKDOWN],
1580
- name: "vinicunca:markdown:processor",
1581
- processor: "markdown/markdown"
1618
+ files,
1619
+ languageOptions: {
1620
+ parser: parserPlain
1621
+ },
1622
+ name: "vinicunca:markdown:parser"
1582
1623
  },
1583
1624
  {
1584
1625
  files: [
@@ -1632,7 +1673,6 @@ async function markdown(options = {}) {
1632
1673
  "ts/restrict-template-expressions": OFF,
1633
1674
  "ts/unbound-method": OFF
1634
1675
  },
1635
- "vinicunca/no-cjs-exports": OFF,
1636
1676
  "vinicunca/no-ts-export-equal": OFF,
1637
1677
  ...overrides
1638
1678
  }
@@ -2001,6 +2041,8 @@ var STYLISTIC_CONFIG_DEFAULTS = {
2001
2041
  async function stylistic(options = {}) {
2002
2042
  const {
2003
2043
  indent,
2044
+ jsx,
2045
+ overrides = {},
2004
2046
  quotes,
2005
2047
  semi
2006
2048
  } = {
@@ -2008,6 +2050,14 @@ async function stylistic(options = {}) {
2008
2050
  ...options
2009
2051
  };
2010
2052
  const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
2053
+ const config = pluginStylistic.configs.customize({
2054
+ flat: true,
2055
+ indent,
2056
+ jsx,
2057
+ pluginName: "style",
2058
+ quotes,
2059
+ semi
2060
+ });
2011
2061
  return [
2012
2062
  {
2013
2063
  name: "vinicunca:stylistic",
@@ -2016,83 +2066,15 @@ async function stylistic(options = {}) {
2016
2066
  vinicunca: default2
2017
2067
  },
2018
2068
  rules: {
2069
+ ...config.rules,
2019
2070
  "curly": [ERROR, "all"],
2020
2071
  "style/array-bracket-newline": [ERROR, CONSISTENT],
2021
2072
  "style/array-bracket-spacing": [ERROR, NEVER],
2022
2073
  "style/array-element-newline": [ERROR, CONSISTENT],
2023
2074
  "style/arrow-parens": [ERROR, ALWAYS],
2024
- "style/arrow-spacing": [ERROR, { after: true, before: true }],
2025
- "style/block-spacing": [ERROR, ALWAYS],
2026
2075
  "style/brace-style": [ERROR],
2027
- "style/comma-dangle": [ERROR, "always-multiline"],
2028
- "style/comma-spacing": [ERROR, { after: true, before: false }],
2029
- "style/comma-style": [ERROR, "last"],
2030
- "style/computed-property-spacing": [ERROR, NEVER, { enforceForClassMembers: true }],
2031
- "style/dot-location": [ERROR, "property"],
2032
- "style/eol-last": ERROR,
2033
2076
  "style/func-call-spacing": [ERROR, NEVER],
2034
- "style/indent": [ERROR, indent, {
2035
- ArrayExpression: 1,
2036
- CallExpression: { arguments: 1 },
2037
- FunctionDeclaration: { body: 1, parameters: 1 },
2038
- FunctionExpression: { body: 1, parameters: 1 },
2039
- ImportDeclaration: 1,
2040
- MemberExpression: 1,
2041
- ObjectExpression: 1,
2042
- SwitchCase: 1,
2043
- VariableDeclarator: 1,
2044
- flatTernaryExpressions: false,
2045
- ignoreComments: false,
2046
- ignoredNodes: [
2047
- "TemplateLiteral *",
2048
- "JSXElement",
2049
- "JSXElement > *",
2050
- "JSXAttribute",
2051
- "JSXIdentifier",
2052
- "JSXNamespacedName",
2053
- "JSXMemberExpression",
2054
- "JSXSpreadAttribute",
2055
- "JSXExpressionContainer",
2056
- "JSXOpeningElement",
2057
- "JSXClosingElement",
2058
- "JSXFragment",
2059
- "JSXOpeningFragment",
2060
- "JSXClosingFragment",
2061
- "JSXText",
2062
- "JSXEmptyExpression",
2063
- "JSXSpreadChild",
2064
- "TSTypeParameterInstantiation",
2065
- "FunctionExpression > .params[decorators.length > 0]",
2066
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
2067
- "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
2068
- ],
2069
- offsetTernaryExpressions: true,
2070
- outerIIFEBody: 1
2071
- }],
2072
- "style/indent-binary-ops": [ERROR, indent],
2073
- "style/key-spacing": [ERROR, { afterColon: true, beforeColon: false }],
2074
- "style/keyword-spacing": [ERROR, { after: true, before: true }],
2075
- "style/lines-between-class-members": [ERROR, ALWAYS, { exceptAfterSingleLine: true }],
2076
- "style/max-statements-per-line": [ERROR, { max: 1 }],
2077
2077
  "style/member-delimiter-style": [ERROR],
2078
- "style/multiline-ternary": [ERROR, "always-multiline"],
2079
- "style/new-parens": ERROR,
2080
- "style/no-extra-parens": [ERROR, "functions"],
2081
- "style/no-floating-decimal": ERROR,
2082
- "style/no-mixed-operators": [ERROR, {
2083
- allowSamePrecedence: true,
2084
- groups: [
2085
- ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
2086
- ["&&", "||"],
2087
- ["in", "instanceof"]
2088
- ]
2089
- }],
2090
- "style/no-mixed-spaces-and-tabs": ERROR,
2091
- "style/no-multi-spaces": ERROR,
2092
- "style/no-multiple-empty-lines": [ERROR, { max: 1, maxBOF: 0, maxEOF: 1 }],
2093
- "style/no-tabs": ERROR,
2094
- "style/no-trailing-spaces": ERROR,
2095
- "style/no-whitespace-before-property": ERROR,
2096
2078
  "style/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
2097
2079
  "style/object-curly-spacing": [ERROR, ALWAYS],
2098
2080
  "style/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
@@ -2103,36 +2085,10 @@ async function stylistic(options = {}) {
2103
2085
  "style/rest-spread-spacing": [ERROR, NEVER],
2104
2086
  "style/semi": [ERROR, semi ? ALWAYS : NEVER],
2105
2087
  "style/semi-spacing": [ERROR, { after: true, before: false }],
2106
- "style/space-before-blocks": [ERROR, ALWAYS],
2107
- "style/space-before-function-paren": [ERROR, {
2108
- anonymous: NEVER,
2109
- asyncArrow: ALWAYS,
2110
- named: NEVER
2111
- }],
2112
- "style/space-in-parens": [ERROR, NEVER],
2113
- "style/space-infix-ops": ERROR,
2114
- "style/space-unary-ops": [ERROR, { nonwords: false, words: true }],
2115
- "style/spaced-comment": [ERROR, "always", {
2116
- block: {
2117
- balanced: true,
2118
- exceptions: ["*"],
2119
- markers: ["!"]
2120
- },
2121
- line: {
2122
- exceptions: ["/", "#"],
2123
- markers: ["/"]
2124
- }
2125
- }],
2126
- "style/template-curly-spacing": ERROR,
2127
- "style/template-tag-spacing": [ERROR, NEVER],
2128
- "style/type-annotation-spacing": [ERROR, {}],
2129
- "style/wrap-iife": [ERROR, "any", {
2130
- functionPrototypeMethods: true
2131
- }],
2132
- "style/yield-star-spacing": [ERROR, "both"],
2133
2088
  "vinicunca/consistent-list-newline": ERROR,
2134
2089
  "vinicunca/if-newline": ERROR,
2135
- "vinicunca/top-level-function": ERROR
2090
+ "vinicunca/top-level-function": ERROR,
2091
+ ...overrides
2136
2092
  }
2137
2093
  },
2138
2094
  {
@@ -2177,6 +2133,7 @@ async function test(options = {}) {
2177
2133
  files,
2178
2134
  name: "vinicunca:test:rules",
2179
2135
  rules: {
2136
+ "node/prefer-global/process": OFF,
2180
2137
  "test/consistent-test-it": [ERROR, { fn: "it", withinDescribe: "it" }],
2181
2138
  "test/no-identical-title": ERROR,
2182
2139
  "test/no-only-tests": isInEditor ? OFF : ERROR,
@@ -2194,13 +2151,13 @@ async function typescript(options = {}) {
2194
2151
  const {
2195
2152
  componentExts = [],
2196
2153
  overrides = {},
2197
- parserOptions = {},
2198
- tsconfigPath = []
2154
+ parserOptions = {}
2199
2155
  } = options ?? {};
2200
2156
  const files = options.files ?? [
2201
2157
  GLOB_SRC,
2202
2158
  ...componentExts.map((ext) => `**/*.${ext}`)
2203
2159
  ];
2160
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
2204
2161
  const typeAwareRules = {
2205
2162
  "dot-notation": OFF,
2206
2163
  "no-implied-eval": OFF,
@@ -2216,31 +2173,19 @@ async function typescript(options = {}) {
2216
2173
  "ts/restrict-plus-operands": ERROR,
2217
2174
  "ts/restrict-template-expressions": ERROR
2218
2175
  };
2219
- let tsConfigOptions = {};
2220
- let additionalTypeAwareRules = {};
2221
- if (!isEmpty(tsconfigPath)) {
2222
- tsConfigOptions = {
2223
- project: tsconfigPath,
2224
- tsconfigRootDir: process.cwd()
2225
- };
2226
- additionalTypeAwareRules = typeAwareRules;
2227
- }
2176
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
2228
2177
  const [
2229
2178
  pluginTs,
2230
- parserTs,
2231
- pluginStylistic
2179
+ parserTs
2232
2180
  ] = await Promise.all([
2233
2181
  interopDefault(import("@typescript-eslint/eslint-plugin")),
2234
- interopDefault(import("@typescript-eslint/parser")),
2235
- interopDefault(import("@stylistic/eslint-plugin"))
2182
+ interopDefault(import("@typescript-eslint/parser"))
2236
2183
  ]);
2237
2184
  return [
2238
2185
  {
2239
2186
  // Install the plugins without globs, so they can be configured separately.
2240
2187
  name: "vinicunca:typescript:setup",
2241
2188
  plugins: {
2242
- import: pluginImport,
2243
- style: pluginStylistic,
2244
2189
  ts: pluginTs,
2245
2190
  vinicunca: default2
2246
2191
  }
@@ -2252,7 +2197,10 @@ async function typescript(options = {}) {
2252
2197
  parserOptions: {
2253
2198
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
2254
2199
  sourceType: "module",
2255
- ...tsConfigOptions,
2200
+ ...tsconfigPath ? {
2201
+ project: tsconfigPath,
2202
+ tsconfigRootDir: process.cwd()
2203
+ } : {},
2256
2204
  ...parserOptions
2257
2205
  }
2258
2206
  },
@@ -2275,8 +2223,6 @@ async function typescript(options = {}) {
2275
2223
  "no-unused-vars": OFF,
2276
2224
  "no-use-before-define": OFF,
2277
2225
  "no-useless-constructor": OFF,
2278
- "style/type-generic-spacing": ERROR,
2279
- "style/type-named-tuple-spacing": ERROR,
2280
2226
  "ts/ban-ts-comment": [ERROR, { "ts-ignore": "allow-with-description" }],
2281
2227
  "ts/ban-types": [ERROR, { types: { Function: false } }],
2282
2228
  "ts/consistent-type-definitions": [ERROR, "interface"],
@@ -2305,9 +2251,14 @@ async function typescript(options = {}) {
2305
2251
  "ts/parameter-properties": OFF,
2306
2252
  "ts/prefer-ts-expect-error": ERROR,
2307
2253
  "ts/triple-slash-reference": OFF,
2308
- "vinicunca/no-cjs-exports": ERROR,
2309
- "vinicunca/no-ts-export-equal": ERROR,
2310
- ...additionalTypeAwareRules,
2254
+ ...overrides
2255
+ }
2256
+ },
2257
+ {
2258
+ files: filesTypeAware,
2259
+ name: "vinicunca:typescript:rules-type-aware",
2260
+ rules: {
2261
+ ...tsconfigPath ? typeAwareRules : {},
2311
2262
  ...overrides
2312
2263
  }
2313
2264
  },
@@ -2317,6 +2268,7 @@ async function typescript(options = {}) {
2317
2268
  rules: {
2318
2269
  "eslint-comments/no-unlimited-disable": OFF,
2319
2270
  "import/no-duplicates": OFF,
2271
+ "no-restricted-syntax": "off",
2320
2272
  "unused-imports/no-unused-vars": OFF
2321
2273
  }
2322
2274
  },
@@ -2339,10 +2291,7 @@ async function typescript(options = {}) {
2339
2291
  }
2340
2292
 
2341
2293
  // src/configs/unicorn.ts
2342
- async function unicorn(options = {}) {
2343
- const {
2344
- overrides = {}
2345
- } = options;
2294
+ async function unicorn() {
2346
2295
  return [
2347
2296
  {
2348
2297
  name: "vinicunca:unicorn",
@@ -2362,8 +2311,7 @@ async function unicorn(options = {}) {
2362
2311
  "unicorn/prefer-number-properties": ERROR,
2363
2312
  "unicorn/prefer-string-starts-ends-with": ERROR,
2364
2313
  "unicorn/prefer-type-error": ERROR,
2365
- "unicorn/throw-new-error": ERROR,
2366
- ...overrides
2314
+ "unicorn/throw-new-error": ERROR
2367
2315
  }
2368
2316
  }
2369
2317
  ];
@@ -2400,32 +2348,26 @@ async function unocss(options = {}) {
2400
2348
  }
2401
2349
 
2402
2350
  // src/configs/vue.ts
2403
- import process2 from "process";
2351
+ import { mergeProcessors as mergeProcessors2 } from "eslint-merge-processors";
2404
2352
  async function vue(options = {}) {
2405
2353
  const {
2406
2354
  files = [GLOB_VUE],
2407
2355
  overrides = {},
2408
- stylistic: stylistic2 = true,
2409
- typescript: typescript2 = {}
2356
+ stylistic: stylistic2 = true
2410
2357
  } = options;
2358
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
2411
2359
  const {
2412
2360
  indent = 2
2413
2361
  } = isBoolean(stylistic2) ? {} : stylistic2;
2414
- let tsConfigOptions = {};
2415
- const tsconfigPath = typescript2.tsconfigPath ?? [];
2416
- if (!isEmpty(tsconfigPath)) {
2417
- tsConfigOptions = {
2418
- project: tsconfigPath,
2419
- tsconfigRootDir: process2.cwd()
2420
- };
2421
- }
2422
2362
  const [
2423
2363
  pluginVue,
2424
- parserVue
2364
+ parserVue,
2365
+ processorVueBlocks
2425
2366
  ] = await Promise.all([
2426
2367
  // @ts-expect-error missing types
2427
2368
  interopDefault(import("eslint-plugin-vue")),
2428
- interopDefault(import("vue-eslint-parser"))
2369
+ interopDefault(import("vue-eslint-parser")),
2370
+ interopDefault(import("eslint-processor-vue-blocks"))
2429
2371
  ]);
2430
2372
  return [
2431
2373
  {
@@ -2443,39 +2385,30 @@ async function vue(options = {}) {
2443
2385
  jsx: true
2444
2386
  },
2445
2387
  extraFileExtensions: [".vue"],
2446
- parser: typescript2.enabled ? await interopDefault(import("@typescript-eslint/parser")) : null,
2447
- sourceType: "module",
2448
- ...tsConfigOptions
2388
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
2389
+ sourceType: "module"
2449
2390
  }
2450
2391
  },
2451
2392
  name: "vinicunca:vue:rules",
2452
- processor: pluginVue.processors[".vue"],
2393
+ processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors2([
2394
+ pluginVue.processors[".vue"],
2395
+ processorVueBlocks({
2396
+ ...sfcBlocks,
2397
+ blocks: {
2398
+ styles: true,
2399
+ ...sfcBlocks.blocks
2400
+ }
2401
+ })
2402
+ ]),
2453
2403
  rules: {
2454
2404
  ...pluginVue.configs.base.rules,
2455
2405
  ...pluginVue.configs["vue3-essential"].rules,
2456
2406
  ...pluginVue.configs["vue3-strongly-recommended"].rules,
2457
2407
  ...pluginVue.configs["vue3-recommended"].rules,
2458
2408
  "node/prefer-global/process": OFF,
2459
- "vue/array-bracket-spacing": [ERROR, NEVER],
2460
- "vue/arrow-spacing": [ERROR, {
2461
- after: true,
2462
- before: true
2463
- }],
2464
2409
  "vue/block-order": [ERROR, {
2465
2410
  order: ["script", "template", "style"]
2466
2411
  }],
2467
- "vue/block-spacing": [ERROR, ALWAYS],
2468
- "vue/block-tag-newline": [ERROR, {
2469
- multiline: ALWAYS,
2470
- singleline: ALWAYS
2471
- }],
2472
- "vue/brace-style": [ERROR, "stroustrup", { allowSingleLine: true }],
2473
- "vue/comma-dangle": [ERROR, "always-multiline"],
2474
- "vue/comma-spacing": [ERROR, {
2475
- after: true,
2476
- before: false
2477
- }],
2478
- "vue/comma-style": [ERROR, "last"],
2479
2412
  "vue/component-name-in-template-casing": [ERROR, "PascalCase"],
2480
2413
  "vue/component-options-name-casing": [ERROR, "PascalCase"],
2481
2414
  "vue/custom-event-name-casing": [ERROR, "camelCase"],
@@ -2485,18 +2418,7 @@ async function vue(options = {}) {
2485
2418
  "vue/dot-location": [ERROR, "property"],
2486
2419
  "vue/dot-notation": [ERROR, { allowKeywords: true }],
2487
2420
  "vue/eqeqeq": [ERROR, "smart"],
2488
- "vue/html-comment-content-spacing": [ERROR, ALWAYS, {
2489
- exceptions: ["-"]
2490
- }],
2491
2421
  "vue/html-indent": [ERROR, indent],
2492
- "vue/key-spacing": [ERROR, {
2493
- afterColon: true,
2494
- beforeColon: false
2495
- }],
2496
- "vue/keyword-spacing": [ERROR, {
2497
- after: true,
2498
- before: true
2499
- }],
2500
2422
  "vue/max-attributes-per-line": [ERROR],
2501
2423
  "vue/multi-word-component-names": OFF,
2502
2424
  "vue/no-constant-condition": WARN,
@@ -2519,28 +2441,58 @@ async function vue(options = {}) {
2519
2441
  "vue/no-useless-v-bind": ERROR,
2520
2442
  "vue/no-v-html": OFF,
2521
2443
  "vue/no-v-text-v-html-on-component": OFF,
2522
- "vue/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
2523
- "vue/object-curly-spacing": [ERROR, ALWAYS],
2524
- "vue/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
2525
2444
  "vue/object-shorthand": [ERROR, ALWAYS, {
2526
2445
  avoidQuotes: true,
2527
2446
  ignoreConstructors: false
2528
2447
  }],
2529
- "vue/operator-linebreak": [ERROR, "before"],
2530
- "vue/padding-line-between-blocks": [ERROR, ALWAYS],
2531
2448
  "vue/prefer-import-from-vue": OFF,
2532
2449
  "vue/prefer-separate-static-class": ERROR,
2533
2450
  "vue/prefer-template": ERROR,
2534
- "vue/quote-props": [ERROR, "consistent-as-needed"],
2535
2451
  "vue/require-default-prop": OFF,
2536
2452
  "vue/require-prop-types": OFF,
2537
- "vue/space-in-parens": [ERROR, NEVER],
2538
2453
  "vue/space-infix-ops": ERROR,
2539
2454
  "vue/space-unary-ops": [ERROR, {
2540
2455
  nonwords: false,
2541
2456
  words: true
2542
2457
  }],
2543
- "vue/template-curly-spacing": ERROR,
2458
+ ...stylistic2 ? {
2459
+ "vue/array-bracket-spacing": [ERROR, NEVER],
2460
+ "vue/arrow-spacing": [ERROR, {
2461
+ after: true,
2462
+ before: true
2463
+ }],
2464
+ "vue/block-spacing": [ERROR, ALWAYS],
2465
+ "vue/block-tag-newline": [ERROR, {
2466
+ multiline: ALWAYS,
2467
+ singleline: ALWAYS
2468
+ }],
2469
+ "vue/brace-style": [ERROR, "stroustrup", { allowSingleLine: true }],
2470
+ "vue/comma-dangle": [ERROR, "always-multiline"],
2471
+ "vue/comma-spacing": [ERROR, {
2472
+ after: true,
2473
+ before: false
2474
+ }],
2475
+ "vue/comma-style": [ERROR, "last"],
2476
+ "vue/html-comment-content-spacing": [ERROR, ALWAYS, {
2477
+ exceptions: ["-"]
2478
+ }],
2479
+ "vue/key-spacing": [ERROR, {
2480
+ afterColon: true,
2481
+ beforeColon: false
2482
+ }],
2483
+ "vue/keyword-spacing": [ERROR, {
2484
+ after: true,
2485
+ before: true
2486
+ }],
2487
+ "vue/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
2488
+ "vue/object-curly-spacing": [ERROR, ALWAYS],
2489
+ "vue/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
2490
+ "vue/operator-linebreak": [ERROR, "before"],
2491
+ "vue/padding-line-between-blocks": [ERROR, ALWAYS],
2492
+ "vue/quote-props": [ERROR, "consistent-as-needed"],
2493
+ "vue/space-in-parens": [ERROR, NEVER],
2494
+ "vue/template-curly-spacing": ERROR
2495
+ } : {},
2544
2496
  ...overrides
2545
2497
  }
2546
2498
  }
@@ -2581,51 +2533,219 @@ async function yaml(options = {}) {
2581
2533
  rules: {
2582
2534
  "style/spaced-comment": OFF,
2583
2535
  "yaml/block-mapping": ERROR,
2584
- "yaml/block-mapping-question-indicator-newline": ERROR,
2585
2536
  "yaml/block-sequence": ERROR,
2586
- "yaml/block-sequence-hyphen-indicator-newline": ERROR,
2587
- "yaml/flow-mapping-curly-newline": ERROR,
2588
- "yaml/flow-mapping-curly-spacing": ERROR,
2589
- "yaml/flow-sequence-bracket-newline": ERROR,
2590
- "yaml/flow-sequence-bracket-spacing": ERROR,
2591
- "yaml/indent": [ERROR, indent === "tab" ? 2 : indent],
2592
- "yaml/key-spacing": ERROR,
2593
2537
  "yaml/no-empty-key": ERROR,
2594
2538
  "yaml/no-empty-sequence-entry": ERROR,
2595
2539
  "yaml/no-irregular-whitespace": ERROR,
2596
- "yaml/no-tab-indent": ERROR,
2597
2540
  "yaml/plain-scalar": ERROR,
2598
- "yaml/quotes": [ERROR, { avoidEscape: false, prefer: quotes }],
2599
- "yaml/spaced-comment": ERROR,
2600
2541
  "yaml/vue-custom-block/no-parsing-error": ERROR,
2542
+ ...stylistic2 ? {
2543
+ "yaml/block-mapping-question-indicator-newline": ERROR,
2544
+ "yaml/block-sequence-hyphen-indicator-newline": ERROR,
2545
+ "yaml/flow-mapping-curly-newline": ERROR,
2546
+ "yaml/flow-mapping-curly-spacing": ERROR,
2547
+ "yaml/flow-sequence-bracket-newline": ERROR,
2548
+ "yaml/flow-sequence-bracket-spacing": ERROR,
2549
+ "yaml/indent": [ERROR, indent === "tab" ? 2 : indent],
2550
+ "yaml/key-spacing": ERROR,
2551
+ "yaml/no-tab-indent": ERROR,
2552
+ "yaml/quotes": [ERROR, { avoidEscape: false, prefer: quotes }],
2553
+ "yaml/spaced-comment": ERROR
2554
+ } : {},
2601
2555
  ...overrides
2602
2556
  }
2603
2557
  }
2604
2558
  ];
2605
2559
  }
2606
2560
 
2561
+ // src/configs/formatters.ts
2562
+ async function formatters(options = {}, stylistic2 = {}) {
2563
+ if (options === true) {
2564
+ options = {
2565
+ css: true,
2566
+ graphql: true,
2567
+ html: true,
2568
+ markdown: true
2569
+ };
2570
+ }
2571
+ const {
2572
+ indent,
2573
+ quotes,
2574
+ semi
2575
+ } = {
2576
+ ...STYLISTIC_CONFIG_DEFAULTS,
2577
+ ...stylistic2
2578
+ };
2579
+ const prettierOptions = Object.assign(
2580
+ {
2581
+ endOfLine: "auto",
2582
+ semi,
2583
+ singleQuote: quotes === "single",
2584
+ tabWidth: typeof indent === "number" ? indent : 2,
2585
+ trailingComma: "all",
2586
+ useTabs: indent === "tab"
2587
+ },
2588
+ options.prettierOptions || {}
2589
+ );
2590
+ const dprintOptions = Object.assign(
2591
+ {
2592
+ indentWidth: typeof indent === "number" ? indent : 2,
2593
+ quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
2594
+ useTabs: indent === "tab"
2595
+ },
2596
+ options.dprintOptions || {}
2597
+ );
2598
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
2599
+ const configs = [
2600
+ {
2601
+ name: "vinicunca:formatters:setup",
2602
+ plugins: {
2603
+ format: pluginFormat
2604
+ }
2605
+ }
2606
+ ];
2607
+ if (options.css) {
2608
+ configs.push(
2609
+ {
2610
+ files: [GLOB_CSS, GLOB_POSTCSS],
2611
+ languageOptions: {
2612
+ parser: parserPlain
2613
+ },
2614
+ name: "vinicunca:formatter:css",
2615
+ rules: {
2616
+ "format/prettier": [
2617
+ "error",
2618
+ {
2619
+ ...prettierOptions,
2620
+ parser: "css"
2621
+ }
2622
+ ]
2623
+ }
2624
+ },
2625
+ {
2626
+ files: [GLOB_SCSS],
2627
+ languageOptions: {
2628
+ parser: parserPlain
2629
+ },
2630
+ name: "vinicunca:formatter:scss",
2631
+ rules: {
2632
+ "format/prettier": [
2633
+ "error",
2634
+ {
2635
+ ...prettierOptions,
2636
+ parser: "scss"
2637
+ }
2638
+ ]
2639
+ }
2640
+ },
2641
+ {
2642
+ files: [GLOB_LESS],
2643
+ languageOptions: {
2644
+ parser: parserPlain
2645
+ },
2646
+ name: "vinicunca:formatter:less",
2647
+ rules: {
2648
+ "format/prettier": [
2649
+ "error",
2650
+ {
2651
+ ...prettierOptions,
2652
+ parser: "less"
2653
+ }
2654
+ ]
2655
+ }
2656
+ }
2657
+ );
2658
+ }
2659
+ if (options.html) {
2660
+ configs.push({
2661
+ files: ["**/*.html"],
2662
+ languageOptions: {
2663
+ parser: parserPlain
2664
+ },
2665
+ name: "vinicunca:formatter:html",
2666
+ rules: {
2667
+ "format/prettier": [
2668
+ "error",
2669
+ {
2670
+ ...prettierOptions,
2671
+ parser: "html"
2672
+ }
2673
+ ]
2674
+ }
2675
+ });
2676
+ }
2677
+ if (options.markdown) {
2678
+ const formater = options.markdown === true ? "prettier" : options.markdown;
2679
+ configs.push({
2680
+ files: [GLOB_MARKDOWN],
2681
+ languageOptions: {
2682
+ parser: parserPlain
2683
+ },
2684
+ name: "vinicunca:formatter:markdown",
2685
+ rules: {
2686
+ [`format/${formater}`]: [
2687
+ "error",
2688
+ formater === "prettier" ? {
2689
+ printWidth: 120,
2690
+ ...prettierOptions,
2691
+ embeddedLanguageFormatting: "off",
2692
+ parser: "markdown"
2693
+ } : {
2694
+ ...dprintOptions,
2695
+ language: "markdown"
2696
+ }
2697
+ ]
2698
+ }
2699
+ });
2700
+ }
2701
+ if (options.graphql) {
2702
+ configs.push({
2703
+ files: ["**/*.graphql"],
2704
+ languageOptions: {
2705
+ parser: parserPlain
2706
+ },
2707
+ name: "vinicunca:formatter:graphql",
2708
+ rules: {
2709
+ "format/prettier": [
2710
+ "error",
2711
+ {
2712
+ ...prettierOptions,
2713
+ parser: "graphql"
2714
+ }
2715
+ ]
2716
+ }
2717
+ });
2718
+ }
2719
+ return configs;
2720
+ }
2721
+
2607
2722
  // src/base.ts
2723
+ var flatConfigProps = [
2724
+ "files",
2725
+ "ignores",
2726
+ "languageOptions",
2727
+ "linterOptions",
2728
+ "processor",
2729
+ "plugins",
2730
+ "rules",
2731
+ "settings"
2732
+ ];
2608
2733
  var VuePackages = [
2609
2734
  "vue",
2610
2735
  "nuxt",
2611
2736
  "vitepress",
2612
2737
  "@slidev/cli"
2613
2738
  ];
2614
- async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
2739
+ async function vinicuncaESLint(options = {}, ...userConfigs) {
2615
2740
  const {
2616
2741
  componentExts = [],
2617
- isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
2618
- jsonc: enableJsonc = true,
2619
- markdown: enableMarkdown = true,
2620
- overrides = {},
2742
+ isInEditor = !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE || process2.env.VIM) && !process2.env.CI),
2621
2743
  react: enableReact = false,
2622
- test: enableTest = true,
2623
- typescript: tsOptions = {},
2744
+ typescript: enableTypeScript = isPackageExists("typescript"),
2624
2745
  unocss: enableUnoCSS = false,
2625
- vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
2626
- yaml: enableYaml = true
2746
+ vue: enableVue = VuePackages.some((i) => isPackageExists(i))
2627
2747
  } = options;
2628
- let stylisticOptions = true;
2748
+ let stylisticOptions = {};
2629
2749
  if (options.stylistic === false) {
2630
2750
  stylisticOptions = false;
2631
2751
  } else if (isObject(options.stylistic)) {
@@ -2639,105 +2759,138 @@ async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
2639
2759
  ignores(options.ignores),
2640
2760
  javascript({
2641
2761
  isInEditor,
2642
- overrides: overrides.javascript
2762
+ overrides: getOverrides(options, "javascript")
2643
2763
  }),
2644
2764
  comments(),
2645
2765
  node(),
2646
- jsdoc(),
2766
+ jsdoc({
2767
+ stylistic: stylisticOptions
2768
+ }),
2647
2769
  imports(),
2648
2770
  unicorn()
2649
2771
  );
2650
2772
  if (enableVue) {
2651
2773
  componentExts.push("vue");
2652
2774
  }
2653
- const {
2654
- enabled: tsEnabled = isPackageExists("typescript"),
2655
- ...tsParams
2656
- } = tsOptions;
2657
- if (tsEnabled) {
2775
+ if (enableTypeScript) {
2658
2776
  configs.push(typescript({
2659
- ...tsParams,
2660
- componentExts,
2661
- overrides: overrides.typescript
2777
+ ...resolveSubOptions(options, "typescript"),
2778
+ componentExts
2662
2779
  }));
2663
2780
  }
2664
2781
  if (stylisticOptions) {
2665
- configs.push(stylistic());
2782
+ configs.push(stylistic({
2783
+ ...stylisticOptions,
2784
+ overrides: getOverrides(options, "stylistic")
2785
+ }));
2666
2786
  }
2667
- if (enableTest) {
2787
+ if (options.test ?? true) {
2668
2788
  configs.push(test({
2669
2789
  isInEditor,
2670
- overrides: overrides.test
2790
+ overrides: getOverrides(options, "test")
2671
2791
  }));
2672
2792
  }
2673
- ;
2674
2793
  if (enableVue) {
2675
2794
  configs.push(vue({
2676
- overrides: overrides.vue,
2677
- typescript: {
2678
- enabled: tsEnabled,
2679
- ...tsParams
2680
- }
2795
+ ...resolveSubOptions(options, "vue"),
2796
+ stylistic: stylisticOptions,
2797
+ typescript: !!enableTypeScript
2681
2798
  }));
2682
2799
  }
2683
- ;
2684
2800
  if (enableReact) {
2685
2801
  configs.push(react({
2686
- overrides: overrides.react
2802
+ overrides: getOverrides(options, "react"),
2803
+ typescript: !!enableTypeScript
2687
2804
  }));
2688
2805
  }
2689
2806
  if (enableUnoCSS) {
2690
- configs.push(unocss(
2691
- isBoolean(enableUnoCSS) ? {} : enableUnoCSS
2692
- ));
2807
+ configs.push(unocss({
2808
+ ...resolveSubOptions(options, "unocss"),
2809
+ overrides: getOverrides(options, "unocss")
2810
+ }));
2693
2811
  }
2694
- if (enableJsonc) {
2812
+ if (options.jsonc ?? true) {
2695
2813
  configs.push(
2696
2814
  jsonc({
2697
- overrides: overrides.jsonc,
2815
+ overrides: getOverrides(options, "jsonc"),
2698
2816
  stylistic: stylisticOptions
2699
2817
  }),
2700
2818
  sortPackageJson(),
2701
2819
  sortTsconfig()
2702
2820
  );
2703
2821
  }
2704
- if (enableYaml) {
2822
+ if (options.yaml ?? true) {
2705
2823
  configs.push(yaml({
2706
- overrides: overrides.yaml,
2824
+ overrides: getOverrides(options, "yaml"),
2707
2825
  stylistic: stylisticOptions
2708
2826
  }));
2709
2827
  }
2710
- ;
2711
- if (enableMarkdown) {
2712
- configs.push(markdown({
2713
- componentExts,
2714
- overrides: overrides.markdown
2715
- }));
2828
+ if (options.markdown ?? true) {
2829
+ configs.push(
2830
+ markdown(
2831
+ {
2832
+ componentExts,
2833
+ overrides: getOverrides(options, "markdown")
2834
+ }
2835
+ )
2836
+ );
2837
+ }
2838
+ if (options.formatters) {
2839
+ configs.push(formatters(
2840
+ options.formatters,
2841
+ typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2842
+ ));
2843
+ }
2844
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
2845
+ if (key in options) {
2846
+ acc[key] = options[key];
2847
+ }
2848
+ ;
2849
+ return acc;
2850
+ }, {});
2851
+ if (Object.keys(fusedConfig).length) {
2852
+ configs.push([fusedConfig]);
2716
2853
  }
2717
2854
  ;
2718
- configs.push(ignores(options.ignores));
2719
2855
  return combineConfigs(
2720
2856
  ...configs,
2721
2857
  ...userConfigs
2722
2858
  );
2723
2859
  }
2860
+ function getOverrides(options, key) {
2861
+ const sub = resolveSubOptions(options, key);
2862
+ return {
2863
+ ..."overrides" in sub ? sub.overrides : {}
2864
+ };
2865
+ }
2866
+ function resolveSubOptions(options, key) {
2867
+ return isBoolean(options[key]) ? {} : options[key] || {};
2868
+ }
2724
2869
  export {
2870
+ GLOB_ALL_SRC,
2871
+ GLOB_CSS,
2725
2872
  GLOB_EXCLUDE,
2873
+ GLOB_HTML,
2726
2874
  GLOB_JS,
2727
2875
  GLOB_JSON,
2728
2876
  GLOB_JSON5,
2729
2877
  GLOB_JSONC,
2730
2878
  GLOB_JSX,
2879
+ GLOB_LESS,
2731
2880
  GLOB_MARKDOWN,
2732
2881
  GLOB_MARKDOWN_CODE,
2733
2882
  GLOB_MARKDOWN_IN_MARKDOWN,
2883
+ GLOB_POSTCSS,
2884
+ GLOB_SCSS,
2734
2885
  GLOB_SRC,
2735
2886
  GLOB_SRC_EXT,
2887
+ GLOB_STYLE,
2736
2888
  GLOB_TESTS,
2737
2889
  GLOB_TS,
2738
2890
  GLOB_TSX,
2739
2891
  GLOB_VUE,
2740
2892
  GLOB_YAML,
2893
+ STYLISTIC_CONFIG_DEFAULTS,
2741
2894
  combineConfigs,
2742
2895
  comments,
2743
2896
  ignores,
@@ -2748,6 +2901,7 @@ export {
2748
2901
  jsonc,
2749
2902
  markdown,
2750
2903
  node,
2904
+ parserPlain,
2751
2905
  default3 as pluginComments,
2752
2906
  pluginImport,
2753
2907
  default4 as pluginNode,
@@ -2761,6 +2915,7 @@ export {
2761
2915
  sortTsconfig,
2762
2916
  stylistic,
2763
2917
  test,
2918
+ toArray,
2764
2919
  typescript,
2765
2920
  unicorn,
2766
2921
  unocss,