@vinicunca/eslint-config 2.0.13 → 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.cjs +447 -280
- package/dist/index.d.cts +239 -45
- package/dist/index.d.ts +239 -45
- package/dist/index.js +437 -280
- package/package.json +28 -22
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
|
|
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
|
|
1430
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
1580
|
-
|
|
1581
|
-
|
|
1618
|
+
files,
|
|
1619
|
+
languageOptions: {
|
|
1620
|
+
parser: parserPlain
|
|
1621
|
+
},
|
|
1622
|
+
name: "vinicunca:markdown:parser"
|
|
1582
1623
|
},
|
|
1583
1624
|
{
|
|
1584
1625
|
files: [
|
|
@@ -2000,6 +2041,8 @@ var STYLISTIC_CONFIG_DEFAULTS = {
|
|
|
2000
2041
|
async function stylistic(options = {}) {
|
|
2001
2042
|
const {
|
|
2002
2043
|
indent,
|
|
2044
|
+
jsx,
|
|
2045
|
+
overrides = {},
|
|
2003
2046
|
quotes,
|
|
2004
2047
|
semi
|
|
2005
2048
|
} = {
|
|
@@ -2007,6 +2050,14 @@ async function stylistic(options = {}) {
|
|
|
2007
2050
|
...options
|
|
2008
2051
|
};
|
|
2009
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
|
+
});
|
|
2010
2061
|
return [
|
|
2011
2062
|
{
|
|
2012
2063
|
name: "vinicunca:stylistic",
|
|
@@ -2015,83 +2066,15 @@ async function stylistic(options = {}) {
|
|
|
2015
2066
|
vinicunca: default2
|
|
2016
2067
|
},
|
|
2017
2068
|
rules: {
|
|
2069
|
+
...config.rules,
|
|
2018
2070
|
"curly": [ERROR, "all"],
|
|
2019
2071
|
"style/array-bracket-newline": [ERROR, CONSISTENT],
|
|
2020
2072
|
"style/array-bracket-spacing": [ERROR, NEVER],
|
|
2021
2073
|
"style/array-element-newline": [ERROR, CONSISTENT],
|
|
2022
2074
|
"style/arrow-parens": [ERROR, ALWAYS],
|
|
2023
|
-
"style/arrow-spacing": [ERROR, { after: true, before: true }],
|
|
2024
|
-
"style/block-spacing": [ERROR, ALWAYS],
|
|
2025
2075
|
"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
2076
|
"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
2077
|
"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
2078
|
"style/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
|
|
2096
2079
|
"style/object-curly-spacing": [ERROR, ALWAYS],
|
|
2097
2080
|
"style/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
|
|
@@ -2102,36 +2085,10 @@ async function stylistic(options = {}) {
|
|
|
2102
2085
|
"style/rest-spread-spacing": [ERROR, NEVER],
|
|
2103
2086
|
"style/semi": [ERROR, semi ? ALWAYS : NEVER],
|
|
2104
2087
|
"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
2088
|
"vinicunca/consistent-list-newline": ERROR,
|
|
2133
2089
|
"vinicunca/if-newline": ERROR,
|
|
2134
|
-
"vinicunca/top-level-function": ERROR
|
|
2090
|
+
"vinicunca/top-level-function": ERROR,
|
|
2091
|
+
...overrides
|
|
2135
2092
|
}
|
|
2136
2093
|
},
|
|
2137
2094
|
{
|
|
@@ -2176,6 +2133,7 @@ async function test(options = {}) {
|
|
|
2176
2133
|
files,
|
|
2177
2134
|
name: "vinicunca:test:rules",
|
|
2178
2135
|
rules: {
|
|
2136
|
+
"node/prefer-global/process": OFF,
|
|
2179
2137
|
"test/consistent-test-it": [ERROR, { fn: "it", withinDescribe: "it" }],
|
|
2180
2138
|
"test/no-identical-title": ERROR,
|
|
2181
2139
|
"test/no-only-tests": isInEditor ? OFF : ERROR,
|
|
@@ -2193,13 +2151,13 @@ async function typescript(options = {}) {
|
|
|
2193
2151
|
const {
|
|
2194
2152
|
componentExts = [],
|
|
2195
2153
|
overrides = {},
|
|
2196
|
-
parserOptions = {}
|
|
2197
|
-
tsconfigPath = []
|
|
2154
|
+
parserOptions = {}
|
|
2198
2155
|
} = options ?? {};
|
|
2199
2156
|
const files = options.files ?? [
|
|
2200
2157
|
GLOB_SRC,
|
|
2201
2158
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
2202
2159
|
];
|
|
2160
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
2203
2161
|
const typeAwareRules = {
|
|
2204
2162
|
"dot-notation": OFF,
|
|
2205
2163
|
"no-implied-eval": OFF,
|
|
@@ -2215,31 +2173,19 @@ async function typescript(options = {}) {
|
|
|
2215
2173
|
"ts/restrict-plus-operands": ERROR,
|
|
2216
2174
|
"ts/restrict-template-expressions": ERROR
|
|
2217
2175
|
};
|
|
2218
|
-
|
|
2219
|
-
let additionalTypeAwareRules = {};
|
|
2220
|
-
if (!isEmpty(tsconfigPath)) {
|
|
2221
|
-
tsConfigOptions = {
|
|
2222
|
-
project: tsconfigPath,
|
|
2223
|
-
tsconfigRootDir: process.cwd()
|
|
2224
|
-
};
|
|
2225
|
-
additionalTypeAwareRules = typeAwareRules;
|
|
2226
|
-
}
|
|
2176
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
2227
2177
|
const [
|
|
2228
2178
|
pluginTs,
|
|
2229
|
-
parserTs
|
|
2230
|
-
pluginStylistic
|
|
2179
|
+
parserTs
|
|
2231
2180
|
] = await Promise.all([
|
|
2232
2181
|
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
2233
|
-
interopDefault(import("@typescript-eslint/parser"))
|
|
2234
|
-
interopDefault(import("@stylistic/eslint-plugin"))
|
|
2182
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
2235
2183
|
]);
|
|
2236
2184
|
return [
|
|
2237
2185
|
{
|
|
2238
2186
|
// Install the plugins without globs, so they can be configured separately.
|
|
2239
2187
|
name: "vinicunca:typescript:setup",
|
|
2240
2188
|
plugins: {
|
|
2241
|
-
import: pluginImport,
|
|
2242
|
-
style: pluginStylistic,
|
|
2243
2189
|
ts: pluginTs,
|
|
2244
2190
|
vinicunca: default2
|
|
2245
2191
|
}
|
|
@@ -2251,7 +2197,10 @@ async function typescript(options = {}) {
|
|
|
2251
2197
|
parserOptions: {
|
|
2252
2198
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
2253
2199
|
sourceType: "module",
|
|
2254
|
-
...
|
|
2200
|
+
...tsconfigPath ? {
|
|
2201
|
+
project: tsconfigPath,
|
|
2202
|
+
tsconfigRootDir: process.cwd()
|
|
2203
|
+
} : {},
|
|
2255
2204
|
...parserOptions
|
|
2256
2205
|
}
|
|
2257
2206
|
},
|
|
@@ -2274,8 +2223,6 @@ async function typescript(options = {}) {
|
|
|
2274
2223
|
"no-unused-vars": OFF,
|
|
2275
2224
|
"no-use-before-define": OFF,
|
|
2276
2225
|
"no-useless-constructor": OFF,
|
|
2277
|
-
"style/type-generic-spacing": ERROR,
|
|
2278
|
-
"style/type-named-tuple-spacing": ERROR,
|
|
2279
2226
|
"ts/ban-ts-comment": [ERROR, { "ts-ignore": "allow-with-description" }],
|
|
2280
2227
|
"ts/ban-types": [ERROR, { types: { Function: false } }],
|
|
2281
2228
|
"ts/consistent-type-definitions": [ERROR, "interface"],
|
|
@@ -2304,8 +2251,14 @@ async function typescript(options = {}) {
|
|
|
2304
2251
|
"ts/parameter-properties": OFF,
|
|
2305
2252
|
"ts/prefer-ts-expect-error": ERROR,
|
|
2306
2253
|
"ts/triple-slash-reference": OFF,
|
|
2307
|
-
|
|
2308
|
-
|
|
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(
|
|
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
|
|
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:
|
|
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
|
-
|
|
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(
|
|
2739
|
+
async function vinicuncaESLint(options = {}, ...userConfigs) {
|
|
2613
2740
|
const {
|
|
2614
2741
|
componentExts = [],
|
|
2615
|
-
isInEditor = !!((
|
|
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
|
-
|
|
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 =
|
|
2748
|
+
let stylisticOptions = {};
|
|
2627
2749
|
if (options.stylistic === false) {
|
|
2628
2750
|
stylisticOptions = false;
|
|
2629
2751
|
} else if (isObject(options.stylistic)) {
|
|
@@ -2637,105 +2759,138 @@ async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
|
2637
2759
|
ignores(options.ignores),
|
|
2638
2760
|
javascript({
|
|
2639
2761
|
isInEditor,
|
|
2640
|
-
overrides:
|
|
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
|
-
|
|
2652
|
-
enabled: tsEnabled = isPackageExists("typescript"),
|
|
2653
|
-
...tsParams
|
|
2654
|
-
} = tsOptions;
|
|
2655
|
-
if (tsEnabled) {
|
|
2775
|
+
if (enableTypeScript) {
|
|
2656
2776
|
configs.push(typescript({
|
|
2657
|
-
...
|
|
2658
|
-
componentExts
|
|
2659
|
-
overrides: overrides.typescript
|
|
2777
|
+
...resolveSubOptions(options, "typescript"),
|
|
2778
|
+
componentExts
|
|
2660
2779
|
}));
|
|
2661
2780
|
}
|
|
2662
2781
|
if (stylisticOptions) {
|
|
2663
|
-
configs.push(stylistic(
|
|
2782
|
+
configs.push(stylistic({
|
|
2783
|
+
...stylisticOptions,
|
|
2784
|
+
overrides: getOverrides(options, "stylistic")
|
|
2785
|
+
}));
|
|
2664
2786
|
}
|
|
2665
|
-
if (
|
|
2787
|
+
if (options.test ?? true) {
|
|
2666
2788
|
configs.push(test({
|
|
2667
2789
|
isInEditor,
|
|
2668
|
-
overrides:
|
|
2790
|
+
overrides: getOverrides(options, "test")
|
|
2669
2791
|
}));
|
|
2670
2792
|
}
|
|
2671
|
-
;
|
|
2672
2793
|
if (enableVue) {
|
|
2673
2794
|
configs.push(vue({
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
...tsParams
|
|
2678
|
-
}
|
|
2795
|
+
...resolveSubOptions(options, "vue"),
|
|
2796
|
+
stylistic: stylisticOptions,
|
|
2797
|
+
typescript: !!enableTypeScript
|
|
2679
2798
|
}));
|
|
2680
2799
|
}
|
|
2681
|
-
;
|
|
2682
2800
|
if (enableReact) {
|
|
2683
2801
|
configs.push(react({
|
|
2684
|
-
overrides:
|
|
2802
|
+
overrides: getOverrides(options, "react"),
|
|
2803
|
+
typescript: !!enableTypeScript
|
|
2685
2804
|
}));
|
|
2686
2805
|
}
|
|
2687
2806
|
if (enableUnoCSS) {
|
|
2688
|
-
configs.push(unocss(
|
|
2689
|
-
|
|
2690
|
-
|
|
2807
|
+
configs.push(unocss({
|
|
2808
|
+
...resolveSubOptions(options, "unocss"),
|
|
2809
|
+
overrides: getOverrides(options, "unocss")
|
|
2810
|
+
}));
|
|
2691
2811
|
}
|
|
2692
|
-
if (
|
|
2812
|
+
if (options.jsonc ?? true) {
|
|
2693
2813
|
configs.push(
|
|
2694
2814
|
jsonc({
|
|
2695
|
-
overrides:
|
|
2815
|
+
overrides: getOverrides(options, "jsonc"),
|
|
2696
2816
|
stylistic: stylisticOptions
|
|
2697
2817
|
}),
|
|
2698
2818
|
sortPackageJson(),
|
|
2699
2819
|
sortTsconfig()
|
|
2700
2820
|
);
|
|
2701
2821
|
}
|
|
2702
|
-
if (
|
|
2822
|
+
if (options.yaml ?? true) {
|
|
2703
2823
|
configs.push(yaml({
|
|
2704
|
-
overrides:
|
|
2824
|
+
overrides: getOverrides(options, "yaml"),
|
|
2705
2825
|
stylistic: stylisticOptions
|
|
2706
2826
|
}));
|
|
2707
2827
|
}
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
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]);
|
|
2714
2853
|
}
|
|
2715
2854
|
;
|
|
2716
|
-
configs.push(ignores(options.ignores));
|
|
2717
2855
|
return combineConfigs(
|
|
2718
2856
|
...configs,
|
|
2719
2857
|
...userConfigs
|
|
2720
2858
|
);
|
|
2721
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
|
+
}
|
|
2722
2869
|
export {
|
|
2870
|
+
GLOB_ALL_SRC,
|
|
2871
|
+
GLOB_CSS,
|
|
2723
2872
|
GLOB_EXCLUDE,
|
|
2873
|
+
GLOB_HTML,
|
|
2724
2874
|
GLOB_JS,
|
|
2725
2875
|
GLOB_JSON,
|
|
2726
2876
|
GLOB_JSON5,
|
|
2727
2877
|
GLOB_JSONC,
|
|
2728
2878
|
GLOB_JSX,
|
|
2879
|
+
GLOB_LESS,
|
|
2729
2880
|
GLOB_MARKDOWN,
|
|
2730
2881
|
GLOB_MARKDOWN_CODE,
|
|
2731
2882
|
GLOB_MARKDOWN_IN_MARKDOWN,
|
|
2883
|
+
GLOB_POSTCSS,
|
|
2884
|
+
GLOB_SCSS,
|
|
2732
2885
|
GLOB_SRC,
|
|
2733
2886
|
GLOB_SRC_EXT,
|
|
2887
|
+
GLOB_STYLE,
|
|
2734
2888
|
GLOB_TESTS,
|
|
2735
2889
|
GLOB_TS,
|
|
2736
2890
|
GLOB_TSX,
|
|
2737
2891
|
GLOB_VUE,
|
|
2738
2892
|
GLOB_YAML,
|
|
2893
|
+
STYLISTIC_CONFIG_DEFAULTS,
|
|
2739
2894
|
combineConfigs,
|
|
2740
2895
|
comments,
|
|
2741
2896
|
ignores,
|
|
@@ -2746,6 +2901,7 @@ export {
|
|
|
2746
2901
|
jsonc,
|
|
2747
2902
|
markdown,
|
|
2748
2903
|
node,
|
|
2904
|
+
parserPlain,
|
|
2749
2905
|
default3 as pluginComments,
|
|
2750
2906
|
pluginImport,
|
|
2751
2907
|
default4 as pluginNode,
|
|
@@ -2759,6 +2915,7 @@ export {
|
|
|
2759
2915
|
sortTsconfig,
|
|
2760
2916
|
stylistic,
|
|
2761
2917
|
test,
|
|
2918
|
+
toArray,
|
|
2762
2919
|
typescript,
|
|
2763
2920
|
unicorn,
|
|
2764
2921
|
unocss,
|