@vinicunca/eslint-config 2.0.13 → 2.1.2

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,14 +1444,39 @@ 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",
1453
1479
  plugins: {
1454
- // @ts-expect-error missing types
1455
1480
  jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
1456
1481
  },
1457
1482
  rules: {
@@ -1473,7 +1498,11 @@ async function jsdoc() {
1473
1498
  "jsdoc/require-returns-check": WARN,
1474
1499
  "jsdoc/require-returns-description": WARN,
1475
1500
  "jsdoc/require-yields-check": WARN,
1476
- "jsdoc/valid-types": WARN
1501
+ "jsdoc/valid-types": WARN,
1502
+ ...stylistic2 ? {
1503
+ "jsdoc/check-alignment": "warn",
1504
+ "jsdoc/multiline-blocks": "warn"
1505
+ } : {}
1477
1506
  }
1478
1507
  }
1479
1508
  ];
@@ -1555,30 +1584,41 @@ async function jsonc(options = {}) {
1555
1584
  }
1556
1585
 
1557
1586
  // src/configs/markdown.ts
1587
+ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
1558
1588
  async function markdown(options = {}) {
1559
1589
  const {
1560
1590
  componentExts = [],
1561
1591
  files = [GLOB_MARKDOWN],
1562
1592
  overrides = {}
1563
1593
  } = options;
1594
+ const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
1564
1595
  return [
1565
1596
  {
1566
1597
  name: "vinicunca:markdown:setup",
1567
1598
  plugins: {
1568
- // @ts-expect-error missing types
1569
- markdown: await interopDefault(import("eslint-plugin-markdown"))
1599
+ markdown: markdown2
1570
1600
  }
1571
1601
  },
1572
1602
  {
1573
1603
  files,
1574
1604
  ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
1575
1605
  name: "vinicunca:markdown:processor",
1576
- processor: "markdown/markdown"
1606
+ /**
1607
+ * `eslint-plugin-markdown` only creates virtual files for code blocks,
1608
+ * but not the markdown file itself. We use `eslint-merge-processors` to
1609
+ * add a pass-through processor for the markdown file itself.
1610
+ */
1611
+ processor: mergeProcessors([
1612
+ markdown2.processors.markdown,
1613
+ processorPassThrough
1614
+ ])
1577
1615
  },
1578
1616
  {
1579
- files: [GLOB_MARKDOWN],
1580
- name: "vinicunca:markdown:processor",
1581
- processor: "markdown/markdown"
1617
+ files,
1618
+ languageOptions: {
1619
+ parser: parserPlain
1620
+ },
1621
+ name: "vinicunca:markdown:parser"
1582
1622
  },
1583
1623
  {
1584
1624
  files: [
@@ -2000,6 +2040,8 @@ var STYLISTIC_CONFIG_DEFAULTS = {
2000
2040
  async function stylistic(options = {}) {
2001
2041
  const {
2002
2042
  indent,
2043
+ jsx,
2044
+ overrides = {},
2003
2045
  quotes,
2004
2046
  semi
2005
2047
  } = {
@@ -2007,6 +2049,14 @@ async function stylistic(options = {}) {
2007
2049
  ...options
2008
2050
  };
2009
2051
  const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
2052
+ const config = pluginStylistic.configs.customize({
2053
+ flat: true,
2054
+ indent,
2055
+ jsx,
2056
+ pluginName: "style",
2057
+ quotes,
2058
+ semi
2059
+ });
2010
2060
  return [
2011
2061
  {
2012
2062
  name: "vinicunca:stylistic",
@@ -2015,83 +2065,15 @@ async function stylistic(options = {}) {
2015
2065
  vinicunca: default2
2016
2066
  },
2017
2067
  rules: {
2068
+ ...config.rules,
2018
2069
  "curly": [ERROR, "all"],
2019
2070
  "style/array-bracket-newline": [ERROR, CONSISTENT],
2020
2071
  "style/array-bracket-spacing": [ERROR, NEVER],
2021
2072
  "style/array-element-newline": [ERROR, CONSISTENT],
2022
2073
  "style/arrow-parens": [ERROR, ALWAYS],
2023
- "style/arrow-spacing": [ERROR, { after: true, before: true }],
2024
- "style/block-spacing": [ERROR, ALWAYS],
2025
2074
  "style/brace-style": [ERROR],
2026
- "style/comma-dangle": [ERROR, "always-multiline"],
2027
- "style/comma-spacing": [ERROR, { after: true, before: false }],
2028
- "style/comma-style": [ERROR, "last"],
2029
- "style/computed-property-spacing": [ERROR, NEVER, { enforceForClassMembers: true }],
2030
- "style/dot-location": [ERROR, "property"],
2031
- "style/eol-last": ERROR,
2032
2075
  "style/func-call-spacing": [ERROR, NEVER],
2033
- "style/indent": [ERROR, indent, {
2034
- ArrayExpression: 1,
2035
- CallExpression: { arguments: 1 },
2036
- FunctionDeclaration: { body: 1, parameters: 1 },
2037
- FunctionExpression: { body: 1, parameters: 1 },
2038
- ImportDeclaration: 1,
2039
- MemberExpression: 1,
2040
- ObjectExpression: 1,
2041
- SwitchCase: 1,
2042
- VariableDeclarator: 1,
2043
- flatTernaryExpressions: false,
2044
- ignoreComments: false,
2045
- ignoredNodes: [
2046
- "TemplateLiteral *",
2047
- "JSXElement",
2048
- "JSXElement > *",
2049
- "JSXAttribute",
2050
- "JSXIdentifier",
2051
- "JSXNamespacedName",
2052
- "JSXMemberExpression",
2053
- "JSXSpreadAttribute",
2054
- "JSXExpressionContainer",
2055
- "JSXOpeningElement",
2056
- "JSXClosingElement",
2057
- "JSXFragment",
2058
- "JSXOpeningFragment",
2059
- "JSXClosingFragment",
2060
- "JSXText",
2061
- "JSXEmptyExpression",
2062
- "JSXSpreadChild",
2063
- "TSTypeParameterInstantiation",
2064
- "FunctionExpression > .params[decorators.length > 0]",
2065
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
2066
- "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
2067
- ],
2068
- offsetTernaryExpressions: true,
2069
- outerIIFEBody: 1
2070
- }],
2071
- "style/indent-binary-ops": [ERROR, indent],
2072
- "style/key-spacing": [ERROR, { afterColon: true, beforeColon: false }],
2073
- "style/keyword-spacing": [ERROR, { after: true, before: true }],
2074
- "style/lines-between-class-members": [ERROR, ALWAYS, { exceptAfterSingleLine: true }],
2075
- "style/max-statements-per-line": [ERROR, { max: 1 }],
2076
2076
  "style/member-delimiter-style": [ERROR],
2077
- "style/multiline-ternary": [ERROR, "always-multiline"],
2078
- "style/new-parens": ERROR,
2079
- "style/no-extra-parens": [ERROR, "functions"],
2080
- "style/no-floating-decimal": ERROR,
2081
- "style/no-mixed-operators": [ERROR, {
2082
- allowSamePrecedence: true,
2083
- groups: [
2084
- ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
2085
- ["&&", "||"],
2086
- ["in", "instanceof"]
2087
- ]
2088
- }],
2089
- "style/no-mixed-spaces-and-tabs": ERROR,
2090
- "style/no-multi-spaces": ERROR,
2091
- "style/no-multiple-empty-lines": [ERROR, { max: 1, maxBOF: 0, maxEOF: 1 }],
2092
- "style/no-tabs": ERROR,
2093
- "style/no-trailing-spaces": ERROR,
2094
- "style/no-whitespace-before-property": ERROR,
2095
2077
  "style/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
2096
2078
  "style/object-curly-spacing": [ERROR, ALWAYS],
2097
2079
  "style/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
@@ -2102,36 +2084,10 @@ async function stylistic(options = {}) {
2102
2084
  "style/rest-spread-spacing": [ERROR, NEVER],
2103
2085
  "style/semi": [ERROR, semi ? ALWAYS : NEVER],
2104
2086
  "style/semi-spacing": [ERROR, { after: true, before: false }],
2105
- "style/space-before-blocks": [ERROR, ALWAYS],
2106
- "style/space-before-function-paren": [ERROR, {
2107
- anonymous: NEVER,
2108
- asyncArrow: ALWAYS,
2109
- named: NEVER
2110
- }],
2111
- "style/space-in-parens": [ERROR, NEVER],
2112
- "style/space-infix-ops": ERROR,
2113
- "style/space-unary-ops": [ERROR, { nonwords: false, words: true }],
2114
- "style/spaced-comment": [ERROR, "always", {
2115
- block: {
2116
- balanced: true,
2117
- exceptions: ["*"],
2118
- markers: ["!"]
2119
- },
2120
- line: {
2121
- exceptions: ["/", "#"],
2122
- markers: ["/"]
2123
- }
2124
- }],
2125
- "style/template-curly-spacing": ERROR,
2126
- "style/template-tag-spacing": [ERROR, NEVER],
2127
- "style/type-annotation-spacing": [ERROR, {}],
2128
- "style/wrap-iife": [ERROR, "any", {
2129
- functionPrototypeMethods: true
2130
- }],
2131
- "style/yield-star-spacing": [ERROR, "both"],
2132
2087
  "vinicunca/consistent-list-newline": ERROR,
2133
2088
  "vinicunca/if-newline": ERROR,
2134
- "vinicunca/top-level-function": ERROR
2089
+ "vinicunca/top-level-function": ERROR,
2090
+ ...overrides
2135
2091
  }
2136
2092
  },
2137
2093
  {
@@ -2176,6 +2132,7 @@ async function test(options = {}) {
2176
2132
  files,
2177
2133
  name: "vinicunca:test:rules",
2178
2134
  rules: {
2135
+ "node/prefer-global/process": OFF,
2179
2136
  "test/consistent-test-it": [ERROR, { fn: "it", withinDescribe: "it" }],
2180
2137
  "test/no-identical-title": ERROR,
2181
2138
  "test/no-only-tests": isInEditor ? OFF : ERROR,
@@ -2193,13 +2150,13 @@ async function typescript(options = {}) {
2193
2150
  const {
2194
2151
  componentExts = [],
2195
2152
  overrides = {},
2196
- parserOptions = {},
2197
- tsconfigPath = []
2153
+ parserOptions = {}
2198
2154
  } = options ?? {};
2199
2155
  const files = options.files ?? [
2200
2156
  GLOB_SRC,
2201
2157
  ...componentExts.map((ext) => `**/*.${ext}`)
2202
2158
  ];
2159
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
2203
2160
  const typeAwareRules = {
2204
2161
  "dot-notation": OFF,
2205
2162
  "no-implied-eval": OFF,
@@ -2215,31 +2172,19 @@ async function typescript(options = {}) {
2215
2172
  "ts/restrict-plus-operands": ERROR,
2216
2173
  "ts/restrict-template-expressions": ERROR
2217
2174
  };
2218
- let tsConfigOptions = {};
2219
- let additionalTypeAwareRules = {};
2220
- if (!isEmpty(tsconfigPath)) {
2221
- tsConfigOptions = {
2222
- project: tsconfigPath,
2223
- tsconfigRootDir: process.cwd()
2224
- };
2225
- additionalTypeAwareRules = typeAwareRules;
2226
- }
2175
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
2227
2176
  const [
2228
2177
  pluginTs,
2229
- parserTs,
2230
- pluginStylistic
2178
+ parserTs
2231
2179
  ] = await Promise.all([
2232
2180
  interopDefault(import("@typescript-eslint/eslint-plugin")),
2233
- interopDefault(import("@typescript-eslint/parser")),
2234
- interopDefault(import("@stylistic/eslint-plugin"))
2181
+ interopDefault(import("@typescript-eslint/parser"))
2235
2182
  ]);
2236
2183
  return [
2237
2184
  {
2238
2185
  // Install the plugins without globs, so they can be configured separately.
2239
2186
  name: "vinicunca:typescript:setup",
2240
2187
  plugins: {
2241
- import: pluginImport,
2242
- style: pluginStylistic,
2243
2188
  ts: pluginTs,
2244
2189
  vinicunca: default2
2245
2190
  }
@@ -2251,7 +2196,10 @@ async function typescript(options = {}) {
2251
2196
  parserOptions: {
2252
2197
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
2253
2198
  sourceType: "module",
2254
- ...tsConfigOptions,
2199
+ ...tsconfigPath ? {
2200
+ project: tsconfigPath,
2201
+ tsconfigRootDir: process.cwd()
2202
+ } : {},
2255
2203
  ...parserOptions
2256
2204
  }
2257
2205
  },
@@ -2274,8 +2222,6 @@ async function typescript(options = {}) {
2274
2222
  "no-unused-vars": OFF,
2275
2223
  "no-use-before-define": OFF,
2276
2224
  "no-useless-constructor": OFF,
2277
- "style/type-generic-spacing": ERROR,
2278
- "style/type-named-tuple-spacing": ERROR,
2279
2225
  "ts/ban-ts-comment": [ERROR, { "ts-ignore": "allow-with-description" }],
2280
2226
  "ts/ban-types": [ERROR, { types: { Function: false } }],
2281
2227
  "ts/consistent-type-definitions": [ERROR, "interface"],
@@ -2298,14 +2244,21 @@ async function typescript(options = {}) {
2298
2244
  "ts/no-unused-vars": [ERROR, {
2299
2245
  argsIgnorePattern: "^_",
2300
2246
  destructuredArrayIgnorePattern: "^_",
2301
- ignoreRestSiblings: true
2247
+ ignoreRestSiblings: true,
2248
+ varsIgnorePattern: "^_"
2302
2249
  }],
2303
2250
  "ts/no-use-before-define": [ERROR, { classes: false, functions: false, variables: true }],
2304
2251
  "ts/parameter-properties": OFF,
2305
2252
  "ts/prefer-ts-expect-error": ERROR,
2306
2253
  "ts/triple-slash-reference": OFF,
2307
- "vinicunca/no-ts-export-equal": ERROR,
2308
- ...additionalTypeAwareRules,
2254
+ ...overrides
2255
+ }
2256
+ },
2257
+ {
2258
+ files: filesTypeAware,
2259
+ name: "vinicunca:typescript:rules-type-aware",
2260
+ rules: {
2261
+ ...tsconfigPath ? typeAwareRules : {},
2309
2262
  ...overrides
2310
2263
  }
2311
2264
  },
@@ -2315,6 +2268,7 @@ async function typescript(options = {}) {
2315
2268
  rules: {
2316
2269
  "eslint-comments/no-unlimited-disable": OFF,
2317
2270
  "import/no-duplicates": OFF,
2271
+ "no-restricted-syntax": "off",
2318
2272
  "unused-imports/no-unused-vars": OFF
2319
2273
  }
2320
2274
  },
@@ -2337,10 +2291,7 @@ async function typescript(options = {}) {
2337
2291
  }
2338
2292
 
2339
2293
  // src/configs/unicorn.ts
2340
- async function unicorn(options = {}) {
2341
- const {
2342
- overrides = {}
2343
- } = options;
2294
+ async function unicorn() {
2344
2295
  return [
2345
2296
  {
2346
2297
  name: "vinicunca:unicorn",
@@ -2360,8 +2311,7 @@ async function unicorn(options = {}) {
2360
2311
  "unicorn/prefer-number-properties": ERROR,
2361
2312
  "unicorn/prefer-string-starts-ends-with": ERROR,
2362
2313
  "unicorn/prefer-type-error": ERROR,
2363
- "unicorn/throw-new-error": ERROR,
2364
- ...overrides
2314
+ "unicorn/throw-new-error": ERROR
2365
2315
  }
2366
2316
  }
2367
2317
  ];
@@ -2398,32 +2348,26 @@ async function unocss(options = {}) {
2398
2348
  }
2399
2349
 
2400
2350
  // src/configs/vue.ts
2401
- import process2 from "process";
2351
+ import { mergeProcessors as mergeProcessors2 } from "eslint-merge-processors";
2402
2352
  async function vue(options = {}) {
2403
2353
  const {
2404
2354
  files = [GLOB_VUE],
2405
2355
  overrides = {},
2406
- stylistic: stylistic2 = true,
2407
- typescript: typescript2 = {}
2356
+ stylistic: stylistic2 = true
2408
2357
  } = options;
2358
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
2409
2359
  const {
2410
2360
  indent = 2
2411
2361
  } = isBoolean(stylistic2) ? {} : stylistic2;
2412
- let tsConfigOptions = {};
2413
- const tsconfigPath = typescript2.tsconfigPath ?? [];
2414
- if (!isEmpty(tsconfigPath)) {
2415
- tsConfigOptions = {
2416
- project: tsconfigPath,
2417
- tsconfigRootDir: process2.cwd()
2418
- };
2419
- }
2420
2362
  const [
2421
2363
  pluginVue,
2422
- parserVue
2364
+ parserVue,
2365
+ processorVueBlocks
2423
2366
  ] = await Promise.all([
2424
2367
  // @ts-expect-error missing types
2425
2368
  interopDefault(import("eslint-plugin-vue")),
2426
- interopDefault(import("vue-eslint-parser"))
2369
+ interopDefault(import("vue-eslint-parser")),
2370
+ interopDefault(import("eslint-processor-vue-blocks"))
2427
2371
  ]);
2428
2372
  return [
2429
2373
  {
@@ -2441,39 +2385,30 @@ async function vue(options = {}) {
2441
2385
  jsx: true
2442
2386
  },
2443
2387
  extraFileExtensions: [".vue"],
2444
- parser: typescript2.enabled ? await interopDefault(import("@typescript-eslint/parser")) : null,
2445
- sourceType: "module",
2446
- ...tsConfigOptions
2388
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
2389
+ sourceType: "module"
2447
2390
  }
2448
2391
  },
2449
2392
  name: "vinicunca:vue:rules",
2450
- 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
+ ]),
2451
2403
  rules: {
2452
2404
  ...pluginVue.configs.base.rules,
2453
2405
  ...pluginVue.configs["vue3-essential"].rules,
2454
2406
  ...pluginVue.configs["vue3-strongly-recommended"].rules,
2455
2407
  ...pluginVue.configs["vue3-recommended"].rules,
2456
2408
  "node/prefer-global/process": OFF,
2457
- "vue/array-bracket-spacing": [ERROR, NEVER],
2458
- "vue/arrow-spacing": [ERROR, {
2459
- after: true,
2460
- before: true
2461
- }],
2462
2409
  "vue/block-order": [ERROR, {
2463
2410
  order: ["script", "template", "style"]
2464
2411
  }],
2465
- "vue/block-spacing": [ERROR, ALWAYS],
2466
- "vue/block-tag-newline": [ERROR, {
2467
- multiline: ALWAYS,
2468
- singleline: ALWAYS
2469
- }],
2470
- "vue/brace-style": [ERROR, "stroustrup", { allowSingleLine: true }],
2471
- "vue/comma-dangle": [ERROR, "always-multiline"],
2472
- "vue/comma-spacing": [ERROR, {
2473
- after: true,
2474
- before: false
2475
- }],
2476
- "vue/comma-style": [ERROR, "last"],
2477
2412
  "vue/component-name-in-template-casing": [ERROR, "PascalCase"],
2478
2413
  "vue/component-options-name-casing": [ERROR, "PascalCase"],
2479
2414
  "vue/custom-event-name-casing": [ERROR, "camelCase"],
@@ -2483,18 +2418,7 @@ async function vue(options = {}) {
2483
2418
  "vue/dot-location": [ERROR, "property"],
2484
2419
  "vue/dot-notation": [ERROR, { allowKeywords: true }],
2485
2420
  "vue/eqeqeq": [ERROR, "smart"],
2486
- "vue/html-comment-content-spacing": [ERROR, ALWAYS, {
2487
- exceptions: ["-"]
2488
- }],
2489
2421
  "vue/html-indent": [ERROR, indent],
2490
- "vue/key-spacing": [ERROR, {
2491
- afterColon: true,
2492
- beforeColon: false
2493
- }],
2494
- "vue/keyword-spacing": [ERROR, {
2495
- after: true,
2496
- before: true
2497
- }],
2498
2422
  "vue/max-attributes-per-line": [ERROR],
2499
2423
  "vue/multi-word-component-names": OFF,
2500
2424
  "vue/no-constant-condition": WARN,
@@ -2517,28 +2441,58 @@ async function vue(options = {}) {
2517
2441
  "vue/no-useless-v-bind": ERROR,
2518
2442
  "vue/no-v-html": OFF,
2519
2443
  "vue/no-v-text-v-html-on-component": OFF,
2520
- "vue/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
2521
- "vue/object-curly-spacing": [ERROR, ALWAYS],
2522
- "vue/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
2523
2444
  "vue/object-shorthand": [ERROR, ALWAYS, {
2524
2445
  avoidQuotes: true,
2525
2446
  ignoreConstructors: false
2526
2447
  }],
2527
- "vue/operator-linebreak": [ERROR, "before"],
2528
- "vue/padding-line-between-blocks": [ERROR, ALWAYS],
2529
2448
  "vue/prefer-import-from-vue": OFF,
2530
2449
  "vue/prefer-separate-static-class": ERROR,
2531
2450
  "vue/prefer-template": ERROR,
2532
- "vue/quote-props": [ERROR, "consistent-as-needed"],
2533
2451
  "vue/require-default-prop": OFF,
2534
2452
  "vue/require-prop-types": OFF,
2535
- "vue/space-in-parens": [ERROR, NEVER],
2536
2453
  "vue/space-infix-ops": ERROR,
2537
2454
  "vue/space-unary-ops": [ERROR, {
2538
2455
  nonwords: false,
2539
2456
  words: true
2540
2457
  }],
2541
- "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
+ } : {},
2542
2496
  ...overrides
2543
2497
  }
2544
2498
  }
@@ -2579,51 +2533,219 @@ async function yaml(options = {}) {
2579
2533
  rules: {
2580
2534
  "style/spaced-comment": OFF,
2581
2535
  "yaml/block-mapping": ERROR,
2582
- "yaml/block-mapping-question-indicator-newline": ERROR,
2583
2536
  "yaml/block-sequence": ERROR,
2584
- "yaml/block-sequence-hyphen-indicator-newline": ERROR,
2585
- "yaml/flow-mapping-curly-newline": ERROR,
2586
- "yaml/flow-mapping-curly-spacing": ERROR,
2587
- "yaml/flow-sequence-bracket-newline": ERROR,
2588
- "yaml/flow-sequence-bracket-spacing": ERROR,
2589
- "yaml/indent": [ERROR, indent === "tab" ? 2 : indent],
2590
- "yaml/key-spacing": ERROR,
2591
2537
  "yaml/no-empty-key": ERROR,
2592
2538
  "yaml/no-empty-sequence-entry": ERROR,
2593
2539
  "yaml/no-irregular-whitespace": ERROR,
2594
- "yaml/no-tab-indent": ERROR,
2595
2540
  "yaml/plain-scalar": ERROR,
2596
- "yaml/quotes": [ERROR, { avoidEscape: false, prefer: quotes }],
2597
- "yaml/spaced-comment": ERROR,
2598
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
+ } : {},
2599
2555
  ...overrides
2600
2556
  }
2601
2557
  }
2602
2558
  ];
2603
2559
  }
2604
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
+
2605
2722
  // src/base.ts
2723
+ var flatConfigProps = [
2724
+ "files",
2725
+ "ignores",
2726
+ "languageOptions",
2727
+ "linterOptions",
2728
+ "processor",
2729
+ "plugins",
2730
+ "rules",
2731
+ "settings"
2732
+ ];
2606
2733
  var VuePackages = [
2607
2734
  "vue",
2608
2735
  "nuxt",
2609
2736
  "vitepress",
2610
2737
  "@slidev/cli"
2611
2738
  ];
2612
- async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
2739
+ async function vinicuncaESLint(options = {}, ...userConfigs) {
2613
2740
  const {
2614
2741
  componentExts = [],
2615
- isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
2616
- jsonc: enableJsonc = true,
2617
- markdown: enableMarkdown = true,
2618
- overrides = {},
2742
+ isInEditor = !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE || process2.env.VIM) && !process2.env.CI),
2619
2743
  react: enableReact = false,
2620
- test: enableTest = true,
2621
- typescript: tsOptions = {},
2744
+ typescript: enableTypeScript = isPackageExists("typescript"),
2622
2745
  unocss: enableUnoCSS = false,
2623
- vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
2624
- yaml: enableYaml = true
2746
+ vue: enableVue = VuePackages.some((i) => isPackageExists(i))
2625
2747
  } = options;
2626
- let stylisticOptions = true;
2748
+ let stylisticOptions = {};
2627
2749
  if (options.stylistic === false) {
2628
2750
  stylisticOptions = false;
2629
2751
  } else if (isObject(options.stylistic)) {
@@ -2637,105 +2759,140 @@ async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
2637
2759
  ignores(options.ignores),
2638
2760
  javascript({
2639
2761
  isInEditor,
2640
- overrides: overrides.javascript
2762
+ overrides: getOverrides(options, "javascript")
2641
2763
  }),
2642
2764
  comments(),
2643
2765
  node(),
2644
- jsdoc(),
2766
+ jsdoc({
2767
+ stylistic: stylisticOptions
2768
+ }),
2645
2769
  imports(),
2646
2770
  unicorn()
2647
2771
  );
2648
2772
  if (enableVue) {
2649
2773
  componentExts.push("vue");
2650
2774
  }
2651
- const {
2652
- enabled: tsEnabled = isPackageExists("typescript"),
2653
- ...tsParams
2654
- } = tsOptions;
2655
- if (tsEnabled) {
2775
+ if (enableTypeScript) {
2656
2776
  configs.push(typescript({
2657
- ...tsParams,
2777
+ ...resolveSubOptions(options, "typescript"),
2658
2778
  componentExts,
2659
- overrides: overrides.typescript
2779
+ overrides: getOverrides(options, "typescript")
2660
2780
  }));
2661
2781
  }
2662
2782
  if (stylisticOptions) {
2663
- configs.push(stylistic());
2783
+ configs.push(stylistic({
2784
+ ...stylisticOptions,
2785
+ overrides: getOverrides(options, "stylistic")
2786
+ }));
2664
2787
  }
2665
- if (enableTest) {
2788
+ if (options.test ?? true) {
2666
2789
  configs.push(test({
2667
2790
  isInEditor,
2668
- overrides: overrides.test
2791
+ overrides: getOverrides(options, "test")
2669
2792
  }));
2670
2793
  }
2671
- ;
2672
2794
  if (enableVue) {
2673
2795
  configs.push(vue({
2674
- overrides: overrides.vue,
2675
- typescript: {
2676
- enabled: tsEnabled,
2677
- ...tsParams
2678
- }
2796
+ ...resolveSubOptions(options, "vue"),
2797
+ overrides: getOverrides(options, "vue"),
2798
+ stylistic: stylisticOptions,
2799
+ typescript: !!enableTypeScript
2679
2800
  }));
2680
2801
  }
2681
- ;
2682
2802
  if (enableReact) {
2683
2803
  configs.push(react({
2684
- overrides: overrides.react
2804
+ overrides: getOverrides(options, "react"),
2805
+ typescript: !!enableTypeScript
2685
2806
  }));
2686
2807
  }
2687
2808
  if (enableUnoCSS) {
2688
- configs.push(unocss(
2689
- isBoolean(enableUnoCSS) ? {} : enableUnoCSS
2690
- ));
2809
+ configs.push(unocss({
2810
+ ...resolveSubOptions(options, "unocss"),
2811
+ overrides: getOverrides(options, "unocss")
2812
+ }));
2691
2813
  }
2692
- if (enableJsonc) {
2814
+ if (options.jsonc ?? true) {
2693
2815
  configs.push(
2694
2816
  jsonc({
2695
- overrides: overrides.jsonc,
2817
+ overrides: getOverrides(options, "jsonc"),
2696
2818
  stylistic: stylisticOptions
2697
2819
  }),
2698
2820
  sortPackageJson(),
2699
2821
  sortTsconfig()
2700
2822
  );
2701
2823
  }
2702
- if (enableYaml) {
2824
+ if (options.yaml ?? true) {
2703
2825
  configs.push(yaml({
2704
- overrides: overrides.yaml,
2826
+ overrides: getOverrides(options, "yaml"),
2705
2827
  stylistic: stylisticOptions
2706
2828
  }));
2707
2829
  }
2708
- ;
2709
- if (enableMarkdown) {
2710
- configs.push(markdown({
2711
- componentExts,
2712
- overrides: overrides.markdown
2713
- }));
2830
+ if (options.markdown ?? true) {
2831
+ configs.push(
2832
+ markdown(
2833
+ {
2834
+ componentExts,
2835
+ overrides: getOverrides(options, "markdown")
2836
+ }
2837
+ )
2838
+ );
2839
+ }
2840
+ if (options.formatters) {
2841
+ configs.push(formatters(
2842
+ options.formatters,
2843
+ typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2844
+ ));
2845
+ }
2846
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
2847
+ if (key in options) {
2848
+ acc[key] = options[key];
2849
+ }
2850
+ ;
2851
+ return acc;
2852
+ }, {});
2853
+ if (Object.keys(fusedConfig).length) {
2854
+ configs.push([fusedConfig]);
2714
2855
  }
2715
2856
  ;
2716
- configs.push(ignores(options.ignores));
2717
2857
  return combineConfigs(
2718
2858
  ...configs,
2719
2859
  ...userConfigs
2720
2860
  );
2721
2861
  }
2862
+ function getOverrides(options, key) {
2863
+ const sub = resolveSubOptions(options, key);
2864
+ return {
2865
+ ..."overrides" in sub ? sub.overrides : {}
2866
+ };
2867
+ }
2868
+ function resolveSubOptions(options, key) {
2869
+ return isBoolean(options[key]) ? {} : options[key] || {};
2870
+ }
2722
2871
  export {
2872
+ GLOB_ALL_SRC,
2873
+ GLOB_CSS,
2723
2874
  GLOB_EXCLUDE,
2875
+ GLOB_HTML,
2724
2876
  GLOB_JS,
2725
2877
  GLOB_JSON,
2726
2878
  GLOB_JSON5,
2727
2879
  GLOB_JSONC,
2728
2880
  GLOB_JSX,
2881
+ GLOB_LESS,
2729
2882
  GLOB_MARKDOWN,
2730
2883
  GLOB_MARKDOWN_CODE,
2731
2884
  GLOB_MARKDOWN_IN_MARKDOWN,
2885
+ GLOB_POSTCSS,
2886
+ GLOB_SCSS,
2732
2887
  GLOB_SRC,
2733
2888
  GLOB_SRC_EXT,
2889
+ GLOB_STYLE,
2734
2890
  GLOB_TESTS,
2735
2891
  GLOB_TS,
2736
2892
  GLOB_TSX,
2737
2893
  GLOB_VUE,
2738
2894
  GLOB_YAML,
2895
+ STYLISTIC_CONFIG_DEFAULTS,
2739
2896
  combineConfigs,
2740
2897
  comments,
2741
2898
  ignores,
@@ -2746,6 +2903,7 @@ export {
2746
2903
  jsonc,
2747
2904
  markdown,
2748
2905
  node,
2906
+ parserPlain,
2749
2907
  default3 as pluginComments,
2750
2908
  pluginImport,
2751
2909
  default4 as pluginNode,
@@ -2759,6 +2917,7 @@ export {
2759
2917
  sortTsconfig,
2760
2918
  stylistic,
2761
2919
  test,
2920
+ toArray,
2762
2921
  typescript,
2763
2922
  unicorn,
2764
2923
  unocss,