@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.cjs +447 -282
- package/dist/index.d.cts +239 -45
- package/dist/index.d.ts +239 -45
- package/dist/index.js +437 -282
- package/package.json +28 -22
package/dist/index.cjs
CHANGED
|
@@ -30,22 +30,30 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
GLOB_ALL_SRC: () => GLOB_ALL_SRC,
|
|
34
|
+
GLOB_CSS: () => GLOB_CSS,
|
|
33
35
|
GLOB_EXCLUDE: () => GLOB_EXCLUDE,
|
|
36
|
+
GLOB_HTML: () => GLOB_HTML,
|
|
34
37
|
GLOB_JS: () => GLOB_JS,
|
|
35
38
|
GLOB_JSON: () => GLOB_JSON,
|
|
36
39
|
GLOB_JSON5: () => GLOB_JSON5,
|
|
37
40
|
GLOB_JSONC: () => GLOB_JSONC,
|
|
38
41
|
GLOB_JSX: () => GLOB_JSX,
|
|
42
|
+
GLOB_LESS: () => GLOB_LESS,
|
|
39
43
|
GLOB_MARKDOWN: () => GLOB_MARKDOWN,
|
|
40
44
|
GLOB_MARKDOWN_CODE: () => GLOB_MARKDOWN_CODE,
|
|
41
45
|
GLOB_MARKDOWN_IN_MARKDOWN: () => GLOB_MARKDOWN_IN_MARKDOWN,
|
|
46
|
+
GLOB_POSTCSS: () => GLOB_POSTCSS,
|
|
47
|
+
GLOB_SCSS: () => GLOB_SCSS,
|
|
42
48
|
GLOB_SRC: () => GLOB_SRC,
|
|
43
49
|
GLOB_SRC_EXT: () => GLOB_SRC_EXT,
|
|
50
|
+
GLOB_STYLE: () => GLOB_STYLE,
|
|
44
51
|
GLOB_TESTS: () => GLOB_TESTS,
|
|
45
52
|
GLOB_TS: () => GLOB_TS,
|
|
46
53
|
GLOB_TSX: () => GLOB_TSX,
|
|
47
54
|
GLOB_VUE: () => GLOB_VUE,
|
|
48
55
|
GLOB_YAML: () => GLOB_YAML,
|
|
56
|
+
STYLISTIC_CONFIG_DEFAULTS: () => STYLISTIC_CONFIG_DEFAULTS,
|
|
49
57
|
combineConfigs: () => combineConfigs,
|
|
50
58
|
comments: () => comments,
|
|
51
59
|
ignores: () => ignores,
|
|
@@ -56,6 +64,7 @@ __export(src_exports, {
|
|
|
56
64
|
jsonc: () => jsonc,
|
|
57
65
|
markdown: () => markdown,
|
|
58
66
|
node: () => node,
|
|
67
|
+
parserPlain: () => parserPlain,
|
|
59
68
|
pluginComments: () => import_eslint_plugin_eslint_comments.default,
|
|
60
69
|
pluginImport: () => pluginImport,
|
|
61
70
|
pluginNode: () => import_eslint_plugin_n.default,
|
|
@@ -69,6 +78,7 @@ __export(src_exports, {
|
|
|
69
78
|
sortTsconfig: () => sortTsconfig,
|
|
70
79
|
stylistic: () => stylistic,
|
|
71
80
|
test: () => test,
|
|
81
|
+
toArray: () => toArray,
|
|
72
82
|
typescript: () => typescript,
|
|
73
83
|
unicorn: () => unicorn,
|
|
74
84
|
unocss: () => unocss,
|
|
@@ -95,9 +105,6 @@ function purry(fn, args, lazy) {
|
|
|
95
105
|
}
|
|
96
106
|
throw new Error("Wrong number of arguments");
|
|
97
107
|
}
|
|
98
|
-
function isArray(data) {
|
|
99
|
-
return Array.isArray(data);
|
|
100
|
-
}
|
|
101
108
|
function isBoolean(data) {
|
|
102
109
|
return typeof data === "boolean";
|
|
103
110
|
}
|
|
@@ -116,21 +123,6 @@ function toString(value) {
|
|
|
116
123
|
function isObject(data) {
|
|
117
124
|
return toString(data) === "[object Object]";
|
|
118
125
|
}
|
|
119
|
-
function isString(data) {
|
|
120
|
-
return typeof data === "string";
|
|
121
|
-
}
|
|
122
|
-
function isEmpty(data) {
|
|
123
|
-
if (isArray(data) || isString(data)) {
|
|
124
|
-
return data.length === 0;
|
|
125
|
-
}
|
|
126
|
-
if (isObject(data)) {
|
|
127
|
-
for (const _ in data) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
return !(data instanceof RegExp);
|
|
131
|
-
}
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
126
|
function _countBy(indexed) {
|
|
135
127
|
return (array, fn) => {
|
|
136
128
|
return array.reduce((ret, item, index) => {
|
|
@@ -1057,7 +1049,7 @@ function toPairs(object) {
|
|
|
1057
1049
|
|
|
1058
1050
|
// src/base.ts
|
|
1059
1051
|
var import_local_pkg = require("local-pkg");
|
|
1060
|
-
var
|
|
1052
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
1061
1053
|
|
|
1062
1054
|
// src/flags.ts
|
|
1063
1055
|
var ERROR = "error";
|
|
@@ -1099,16 +1091,50 @@ var import_node_fs = __toESM(require("fs"), 1);
|
|
|
1099
1091
|
var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
1100
1092
|
|
|
1101
1093
|
// src/globs.ts
|
|
1094
|
+
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
1095
|
+
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
1102
1096
|
var GLOB_JS = "**/*.?([cm])js";
|
|
1103
1097
|
var GLOB_JSX = "**/*.?([cm])jsx";
|
|
1104
1098
|
var GLOB_TS = "**/*.?([cm])ts";
|
|
1105
1099
|
var GLOB_TSX = "**/*.?([cm])tsx";
|
|
1100
|
+
var GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
1101
|
+
var GLOB_CSS = "**/*.css";
|
|
1102
|
+
var GLOB_POSTCSS = "**/*.{p,post}css";
|
|
1103
|
+
var GLOB_LESS = "**/*.less";
|
|
1104
|
+
var GLOB_SCSS = "**/*.scss";
|
|
1105
|
+
var GLOB_JSON = "**/*.json";
|
|
1106
|
+
var GLOB_JSON5 = "**/*.json5";
|
|
1107
|
+
var GLOB_JSONC = "**/*.jsonc";
|
|
1108
|
+
var GLOB_MARKDOWN = "**/*.md";
|
|
1109
|
+
var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
1110
|
+
var GLOB_VUE = "**/*.vue";
|
|
1111
|
+
var GLOB_YAML = "**/*.y?(a)ml";
|
|
1112
|
+
var GLOB_HTML = "**/*.htm?(l)";
|
|
1113
|
+
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
1114
|
+
var GLOB_TESTS = [
|
|
1115
|
+
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
1116
|
+
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
1117
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
1118
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
1119
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
1120
|
+
];
|
|
1121
|
+
var GLOB_ALL_SRC = [
|
|
1122
|
+
GLOB_SRC,
|
|
1123
|
+
GLOB_STYLE,
|
|
1124
|
+
GLOB_JSON,
|
|
1125
|
+
GLOB_JSON5,
|
|
1126
|
+
GLOB_MARKDOWN,
|
|
1127
|
+
GLOB_VUE,
|
|
1128
|
+
GLOB_YAML,
|
|
1129
|
+
GLOB_HTML
|
|
1130
|
+
];
|
|
1106
1131
|
var GLOB_EXCLUDE = [
|
|
1107
1132
|
"**/node_modules",
|
|
1108
1133
|
"**/dist",
|
|
1109
1134
|
"**/package-lock.json",
|
|
1110
1135
|
"**/yarn.lock",
|
|
1111
1136
|
"**/pnpm-lock.yaml",
|
|
1137
|
+
"**/bun.lockb",
|
|
1112
1138
|
"**/output",
|
|
1113
1139
|
"**/coverage",
|
|
1114
1140
|
"**/temp",
|
|
@@ -1132,23 +1158,6 @@ var GLOB_EXCLUDE = [
|
|
|
1132
1158
|
"**/auto-import?(s).d.ts",
|
|
1133
1159
|
"**/components.d.ts"
|
|
1134
1160
|
];
|
|
1135
|
-
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
1136
|
-
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
1137
|
-
var GLOB_TESTS = [
|
|
1138
|
-
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
1139
|
-
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
1140
|
-
`**/*.test.${GLOB_SRC_EXT}`,
|
|
1141
|
-
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
1142
|
-
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
1143
|
-
];
|
|
1144
|
-
var GLOB_VUE = "**/*.vue";
|
|
1145
|
-
var GLOB_JSON = "**/*.json";
|
|
1146
|
-
var GLOB_JSON5 = "**/*.json5";
|
|
1147
|
-
var GLOB_JSONC = "**/*.jsonc";
|
|
1148
|
-
var GLOB_YAML = "**/*.y?(a)ml";
|
|
1149
|
-
var GLOB_MARKDOWN = "**/*.md";
|
|
1150
|
-
var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
1151
|
-
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
1152
1161
|
|
|
1153
1162
|
// src/configs/ignores.ts
|
|
1154
1163
|
async function ignores({
|
|
@@ -1224,6 +1233,7 @@ async function javascript(options = {}) {
|
|
|
1224
1233
|
languageOptions: {
|
|
1225
1234
|
ecmaVersion: 2022,
|
|
1226
1235
|
globals: {
|
|
1236
|
+
...import_globals.default.browser,
|
|
1227
1237
|
...import_globals.default.es2021,
|
|
1228
1238
|
...import_globals.default.node,
|
|
1229
1239
|
document: "readonly",
|
|
@@ -1506,8 +1516,8 @@ async function javascript(options = {}) {
|
|
|
1506
1516
|
|
|
1507
1517
|
// src/utils.ts
|
|
1508
1518
|
async function combineConfigs(...configs) {
|
|
1509
|
-
const
|
|
1510
|
-
return
|
|
1519
|
+
const resolved = await Promise.all(configs);
|
|
1520
|
+
return resolved.flat();
|
|
1511
1521
|
}
|
|
1512
1522
|
function renameRules(rules, from, to) {
|
|
1513
1523
|
return Object.fromEntries(
|
|
@@ -1524,9 +1534,35 @@ async function interopDefault(m) {
|
|
|
1524
1534
|
const resolved = await m;
|
|
1525
1535
|
return resolved.default || resolved;
|
|
1526
1536
|
}
|
|
1537
|
+
var parserPlain = {
|
|
1538
|
+
meta: {
|
|
1539
|
+
name: "parser-plain"
|
|
1540
|
+
},
|
|
1541
|
+
parseForESLint: (code) => ({
|
|
1542
|
+
ast: {
|
|
1543
|
+
body: [],
|
|
1544
|
+
comments: [],
|
|
1545
|
+
loc: { end: code.length, start: 0 },
|
|
1546
|
+
range: [0, code.length],
|
|
1547
|
+
tokens: [],
|
|
1548
|
+
type: "Program"
|
|
1549
|
+
},
|
|
1550
|
+
scopeManager: null,
|
|
1551
|
+
services: { isPlain: true },
|
|
1552
|
+
visitorKeys: {
|
|
1553
|
+
Program: []
|
|
1554
|
+
}
|
|
1555
|
+
})
|
|
1556
|
+
};
|
|
1557
|
+
function toArray(value) {
|
|
1558
|
+
return Array.isArray(value) ? value : [value];
|
|
1559
|
+
}
|
|
1527
1560
|
|
|
1528
1561
|
// src/configs/jsdoc.ts
|
|
1529
|
-
async function jsdoc() {
|
|
1562
|
+
async function jsdoc(options = {}) {
|
|
1563
|
+
const {
|
|
1564
|
+
stylistic: stylistic2 = true
|
|
1565
|
+
} = options;
|
|
1530
1566
|
return [
|
|
1531
1567
|
{
|
|
1532
1568
|
name: "vinicunca:jsdoc",
|
|
@@ -1553,7 +1589,11 @@ async function jsdoc() {
|
|
|
1553
1589
|
"jsdoc/require-returns-check": WARN,
|
|
1554
1590
|
"jsdoc/require-returns-description": WARN,
|
|
1555
1591
|
"jsdoc/require-yields-check": WARN,
|
|
1556
|
-
"jsdoc/valid-types": WARN
|
|
1592
|
+
"jsdoc/valid-types": WARN,
|
|
1593
|
+
...stylistic2 ? {
|
|
1594
|
+
"jsdoc/check-alignment": "warn",
|
|
1595
|
+
"jsdoc/multiline-blocks": "warn"
|
|
1596
|
+
} : {}
|
|
1557
1597
|
}
|
|
1558
1598
|
}
|
|
1559
1599
|
];
|
|
@@ -1635,30 +1675,41 @@ async function jsonc(options = {}) {
|
|
|
1635
1675
|
}
|
|
1636
1676
|
|
|
1637
1677
|
// src/configs/markdown.ts
|
|
1678
|
+
var import_eslint_merge_processors = require("eslint-merge-processors");
|
|
1638
1679
|
async function markdown(options = {}) {
|
|
1639
1680
|
const {
|
|
1640
1681
|
componentExts = [],
|
|
1641
1682
|
files = [GLOB_MARKDOWN],
|
|
1642
1683
|
overrides = {}
|
|
1643
1684
|
} = options;
|
|
1685
|
+
const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
|
|
1644
1686
|
return [
|
|
1645
1687
|
{
|
|
1646
1688
|
name: "vinicunca:markdown:setup",
|
|
1647
1689
|
plugins: {
|
|
1648
|
-
|
|
1649
|
-
markdown: await interopDefault(import("eslint-plugin-markdown"))
|
|
1690
|
+
markdown: markdown2
|
|
1650
1691
|
}
|
|
1651
1692
|
},
|
|
1652
1693
|
{
|
|
1653
1694
|
files,
|
|
1654
1695
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
1655
1696
|
name: "vinicunca:markdown:processor",
|
|
1656
|
-
|
|
1697
|
+
/**
|
|
1698
|
+
* `eslint-plugin-markdown` only creates virtual files for code blocks,
|
|
1699
|
+
* but not the markdown file itself. We use `eslint-merge-processors` to
|
|
1700
|
+
* add a pass-through processor for the markdown file itself.
|
|
1701
|
+
*/
|
|
1702
|
+
processor: (0, import_eslint_merge_processors.mergeProcessors)([
|
|
1703
|
+
markdown2.processors.markdown,
|
|
1704
|
+
import_eslint_merge_processors.processorPassThrough
|
|
1705
|
+
])
|
|
1657
1706
|
},
|
|
1658
1707
|
{
|
|
1659
|
-
files
|
|
1660
|
-
|
|
1661
|
-
|
|
1708
|
+
files,
|
|
1709
|
+
languageOptions: {
|
|
1710
|
+
parser: parserPlain
|
|
1711
|
+
},
|
|
1712
|
+
name: "vinicunca:markdown:parser"
|
|
1662
1713
|
},
|
|
1663
1714
|
{
|
|
1664
1715
|
files: [
|
|
@@ -1712,7 +1763,6 @@ async function markdown(options = {}) {
|
|
|
1712
1763
|
"ts/restrict-template-expressions": OFF,
|
|
1713
1764
|
"ts/unbound-method": OFF
|
|
1714
1765
|
},
|
|
1715
|
-
"vinicunca/no-cjs-exports": OFF,
|
|
1716
1766
|
"vinicunca/no-ts-export-equal": OFF,
|
|
1717
1767
|
...overrides
|
|
1718
1768
|
}
|
|
@@ -2081,6 +2131,8 @@ var STYLISTIC_CONFIG_DEFAULTS = {
|
|
|
2081
2131
|
async function stylistic(options = {}) {
|
|
2082
2132
|
const {
|
|
2083
2133
|
indent,
|
|
2134
|
+
jsx,
|
|
2135
|
+
overrides = {},
|
|
2084
2136
|
quotes,
|
|
2085
2137
|
semi
|
|
2086
2138
|
} = {
|
|
@@ -2088,6 +2140,14 @@ async function stylistic(options = {}) {
|
|
|
2088
2140
|
...options
|
|
2089
2141
|
};
|
|
2090
2142
|
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
2143
|
+
const config = pluginStylistic.configs.customize({
|
|
2144
|
+
flat: true,
|
|
2145
|
+
indent,
|
|
2146
|
+
jsx,
|
|
2147
|
+
pluginName: "style",
|
|
2148
|
+
quotes,
|
|
2149
|
+
semi
|
|
2150
|
+
});
|
|
2091
2151
|
return [
|
|
2092
2152
|
{
|
|
2093
2153
|
name: "vinicunca:stylistic",
|
|
@@ -2096,83 +2156,15 @@ async function stylistic(options = {}) {
|
|
|
2096
2156
|
vinicunca: import_eslint_plugin_vinicunca.default
|
|
2097
2157
|
},
|
|
2098
2158
|
rules: {
|
|
2159
|
+
...config.rules,
|
|
2099
2160
|
"curly": [ERROR, "all"],
|
|
2100
2161
|
"style/array-bracket-newline": [ERROR, CONSISTENT],
|
|
2101
2162
|
"style/array-bracket-spacing": [ERROR, NEVER],
|
|
2102
2163
|
"style/array-element-newline": [ERROR, CONSISTENT],
|
|
2103
2164
|
"style/arrow-parens": [ERROR, ALWAYS],
|
|
2104
|
-
"style/arrow-spacing": [ERROR, { after: true, before: true }],
|
|
2105
|
-
"style/block-spacing": [ERROR, ALWAYS],
|
|
2106
2165
|
"style/brace-style": [ERROR],
|
|
2107
|
-
"style/comma-dangle": [ERROR, "always-multiline"],
|
|
2108
|
-
"style/comma-spacing": [ERROR, { after: true, before: false }],
|
|
2109
|
-
"style/comma-style": [ERROR, "last"],
|
|
2110
|
-
"style/computed-property-spacing": [ERROR, NEVER, { enforceForClassMembers: true }],
|
|
2111
|
-
"style/dot-location": [ERROR, "property"],
|
|
2112
|
-
"style/eol-last": ERROR,
|
|
2113
2166
|
"style/func-call-spacing": [ERROR, NEVER],
|
|
2114
|
-
"style/indent": [ERROR, indent, {
|
|
2115
|
-
ArrayExpression: 1,
|
|
2116
|
-
CallExpression: { arguments: 1 },
|
|
2117
|
-
FunctionDeclaration: { body: 1, parameters: 1 },
|
|
2118
|
-
FunctionExpression: { body: 1, parameters: 1 },
|
|
2119
|
-
ImportDeclaration: 1,
|
|
2120
|
-
MemberExpression: 1,
|
|
2121
|
-
ObjectExpression: 1,
|
|
2122
|
-
SwitchCase: 1,
|
|
2123
|
-
VariableDeclarator: 1,
|
|
2124
|
-
flatTernaryExpressions: false,
|
|
2125
|
-
ignoreComments: false,
|
|
2126
|
-
ignoredNodes: [
|
|
2127
|
-
"TemplateLiteral *",
|
|
2128
|
-
"JSXElement",
|
|
2129
|
-
"JSXElement > *",
|
|
2130
|
-
"JSXAttribute",
|
|
2131
|
-
"JSXIdentifier",
|
|
2132
|
-
"JSXNamespacedName",
|
|
2133
|
-
"JSXMemberExpression",
|
|
2134
|
-
"JSXSpreadAttribute",
|
|
2135
|
-
"JSXExpressionContainer",
|
|
2136
|
-
"JSXOpeningElement",
|
|
2137
|
-
"JSXClosingElement",
|
|
2138
|
-
"JSXFragment",
|
|
2139
|
-
"JSXOpeningFragment",
|
|
2140
|
-
"JSXClosingFragment",
|
|
2141
|
-
"JSXText",
|
|
2142
|
-
"JSXEmptyExpression",
|
|
2143
|
-
"JSXSpreadChild",
|
|
2144
|
-
"TSTypeParameterInstantiation",
|
|
2145
|
-
"FunctionExpression > .params[decorators.length > 0]",
|
|
2146
|
-
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
|
|
2147
|
-
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
|
|
2148
|
-
],
|
|
2149
|
-
offsetTernaryExpressions: true,
|
|
2150
|
-
outerIIFEBody: 1
|
|
2151
|
-
}],
|
|
2152
|
-
"style/indent-binary-ops": [ERROR, indent],
|
|
2153
|
-
"style/key-spacing": [ERROR, { afterColon: true, beforeColon: false }],
|
|
2154
|
-
"style/keyword-spacing": [ERROR, { after: true, before: true }],
|
|
2155
|
-
"style/lines-between-class-members": [ERROR, ALWAYS, { exceptAfterSingleLine: true }],
|
|
2156
|
-
"style/max-statements-per-line": [ERROR, { max: 1 }],
|
|
2157
2167
|
"style/member-delimiter-style": [ERROR],
|
|
2158
|
-
"style/multiline-ternary": [ERROR, "always-multiline"],
|
|
2159
|
-
"style/new-parens": ERROR,
|
|
2160
|
-
"style/no-extra-parens": [ERROR, "functions"],
|
|
2161
|
-
"style/no-floating-decimal": ERROR,
|
|
2162
|
-
"style/no-mixed-operators": [ERROR, {
|
|
2163
|
-
allowSamePrecedence: true,
|
|
2164
|
-
groups: [
|
|
2165
|
-
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
|
|
2166
|
-
["&&", "||"],
|
|
2167
|
-
["in", "instanceof"]
|
|
2168
|
-
]
|
|
2169
|
-
}],
|
|
2170
|
-
"style/no-mixed-spaces-and-tabs": ERROR,
|
|
2171
|
-
"style/no-multi-spaces": ERROR,
|
|
2172
|
-
"style/no-multiple-empty-lines": [ERROR, { max: 1, maxBOF: 0, maxEOF: 1 }],
|
|
2173
|
-
"style/no-tabs": ERROR,
|
|
2174
|
-
"style/no-trailing-spaces": ERROR,
|
|
2175
|
-
"style/no-whitespace-before-property": ERROR,
|
|
2176
2168
|
"style/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
|
|
2177
2169
|
"style/object-curly-spacing": [ERROR, ALWAYS],
|
|
2178
2170
|
"style/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
|
|
@@ -2183,36 +2175,10 @@ async function stylistic(options = {}) {
|
|
|
2183
2175
|
"style/rest-spread-spacing": [ERROR, NEVER],
|
|
2184
2176
|
"style/semi": [ERROR, semi ? ALWAYS : NEVER],
|
|
2185
2177
|
"style/semi-spacing": [ERROR, { after: true, before: false }],
|
|
2186
|
-
"style/space-before-blocks": [ERROR, ALWAYS],
|
|
2187
|
-
"style/space-before-function-paren": [ERROR, {
|
|
2188
|
-
anonymous: NEVER,
|
|
2189
|
-
asyncArrow: ALWAYS,
|
|
2190
|
-
named: NEVER
|
|
2191
|
-
}],
|
|
2192
|
-
"style/space-in-parens": [ERROR, NEVER],
|
|
2193
|
-
"style/space-infix-ops": ERROR,
|
|
2194
|
-
"style/space-unary-ops": [ERROR, { nonwords: false, words: true }],
|
|
2195
|
-
"style/spaced-comment": [ERROR, "always", {
|
|
2196
|
-
block: {
|
|
2197
|
-
balanced: true,
|
|
2198
|
-
exceptions: ["*"],
|
|
2199
|
-
markers: ["!"]
|
|
2200
|
-
},
|
|
2201
|
-
line: {
|
|
2202
|
-
exceptions: ["/", "#"],
|
|
2203
|
-
markers: ["/"]
|
|
2204
|
-
}
|
|
2205
|
-
}],
|
|
2206
|
-
"style/template-curly-spacing": ERROR,
|
|
2207
|
-
"style/template-tag-spacing": [ERROR, NEVER],
|
|
2208
|
-
"style/type-annotation-spacing": [ERROR, {}],
|
|
2209
|
-
"style/wrap-iife": [ERROR, "any", {
|
|
2210
|
-
functionPrototypeMethods: true
|
|
2211
|
-
}],
|
|
2212
|
-
"style/yield-star-spacing": [ERROR, "both"],
|
|
2213
2178
|
"vinicunca/consistent-list-newline": ERROR,
|
|
2214
2179
|
"vinicunca/if-newline": ERROR,
|
|
2215
|
-
"vinicunca/top-level-function": ERROR
|
|
2180
|
+
"vinicunca/top-level-function": ERROR,
|
|
2181
|
+
...overrides
|
|
2216
2182
|
}
|
|
2217
2183
|
},
|
|
2218
2184
|
{
|
|
@@ -2257,6 +2223,7 @@ async function test(options = {}) {
|
|
|
2257
2223
|
files,
|
|
2258
2224
|
name: "vinicunca:test:rules",
|
|
2259
2225
|
rules: {
|
|
2226
|
+
"node/prefer-global/process": OFF,
|
|
2260
2227
|
"test/consistent-test-it": [ERROR, { fn: "it", withinDescribe: "it" }],
|
|
2261
2228
|
"test/no-identical-title": ERROR,
|
|
2262
2229
|
"test/no-only-tests": isInEditor ? OFF : ERROR,
|
|
@@ -2274,13 +2241,13 @@ async function typescript(options = {}) {
|
|
|
2274
2241
|
const {
|
|
2275
2242
|
componentExts = [],
|
|
2276
2243
|
overrides = {},
|
|
2277
|
-
parserOptions = {}
|
|
2278
|
-
tsconfigPath = []
|
|
2244
|
+
parserOptions = {}
|
|
2279
2245
|
} = options ?? {};
|
|
2280
2246
|
const files = options.files ?? [
|
|
2281
2247
|
GLOB_SRC,
|
|
2282
2248
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
2283
2249
|
];
|
|
2250
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
2284
2251
|
const typeAwareRules = {
|
|
2285
2252
|
"dot-notation": OFF,
|
|
2286
2253
|
"no-implied-eval": OFF,
|
|
@@ -2296,31 +2263,19 @@ async function typescript(options = {}) {
|
|
|
2296
2263
|
"ts/restrict-plus-operands": ERROR,
|
|
2297
2264
|
"ts/restrict-template-expressions": ERROR
|
|
2298
2265
|
};
|
|
2299
|
-
|
|
2300
|
-
let additionalTypeAwareRules = {};
|
|
2301
|
-
if (!isEmpty(tsconfigPath)) {
|
|
2302
|
-
tsConfigOptions = {
|
|
2303
|
-
project: tsconfigPath,
|
|
2304
|
-
tsconfigRootDir: import_node_process.default.cwd()
|
|
2305
|
-
};
|
|
2306
|
-
additionalTypeAwareRules = typeAwareRules;
|
|
2307
|
-
}
|
|
2266
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
2308
2267
|
const [
|
|
2309
2268
|
pluginTs,
|
|
2310
|
-
parserTs
|
|
2311
|
-
pluginStylistic
|
|
2269
|
+
parserTs
|
|
2312
2270
|
] = await Promise.all([
|
|
2313
2271
|
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
2314
|
-
interopDefault(import("@typescript-eslint/parser"))
|
|
2315
|
-
interopDefault(import("@stylistic/eslint-plugin"))
|
|
2272
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
2316
2273
|
]);
|
|
2317
2274
|
return [
|
|
2318
2275
|
{
|
|
2319
2276
|
// Install the plugins without globs, so they can be configured separately.
|
|
2320
2277
|
name: "vinicunca:typescript:setup",
|
|
2321
2278
|
plugins: {
|
|
2322
|
-
import: pluginImport,
|
|
2323
|
-
style: pluginStylistic,
|
|
2324
2279
|
ts: pluginTs,
|
|
2325
2280
|
vinicunca: import_eslint_plugin_vinicunca.default
|
|
2326
2281
|
}
|
|
@@ -2332,7 +2287,10 @@ async function typescript(options = {}) {
|
|
|
2332
2287
|
parserOptions: {
|
|
2333
2288
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
2334
2289
|
sourceType: "module",
|
|
2335
|
-
...
|
|
2290
|
+
...tsconfigPath ? {
|
|
2291
|
+
project: tsconfigPath,
|
|
2292
|
+
tsconfigRootDir: import_node_process.default.cwd()
|
|
2293
|
+
} : {},
|
|
2336
2294
|
...parserOptions
|
|
2337
2295
|
}
|
|
2338
2296
|
},
|
|
@@ -2355,8 +2313,6 @@ async function typescript(options = {}) {
|
|
|
2355
2313
|
"no-unused-vars": OFF,
|
|
2356
2314
|
"no-use-before-define": OFF,
|
|
2357
2315
|
"no-useless-constructor": OFF,
|
|
2358
|
-
"style/type-generic-spacing": ERROR,
|
|
2359
|
-
"style/type-named-tuple-spacing": ERROR,
|
|
2360
2316
|
"ts/ban-ts-comment": [ERROR, { "ts-ignore": "allow-with-description" }],
|
|
2361
2317
|
"ts/ban-types": [ERROR, { types: { Function: false } }],
|
|
2362
2318
|
"ts/consistent-type-definitions": [ERROR, "interface"],
|
|
@@ -2385,9 +2341,14 @@ async function typescript(options = {}) {
|
|
|
2385
2341
|
"ts/parameter-properties": OFF,
|
|
2386
2342
|
"ts/prefer-ts-expect-error": ERROR,
|
|
2387
2343
|
"ts/triple-slash-reference": OFF,
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2344
|
+
...overrides
|
|
2345
|
+
}
|
|
2346
|
+
},
|
|
2347
|
+
{
|
|
2348
|
+
files: filesTypeAware,
|
|
2349
|
+
name: "vinicunca:typescript:rules-type-aware",
|
|
2350
|
+
rules: {
|
|
2351
|
+
...tsconfigPath ? typeAwareRules : {},
|
|
2391
2352
|
...overrides
|
|
2392
2353
|
}
|
|
2393
2354
|
},
|
|
@@ -2397,6 +2358,7 @@ async function typescript(options = {}) {
|
|
|
2397
2358
|
rules: {
|
|
2398
2359
|
"eslint-comments/no-unlimited-disable": OFF,
|
|
2399
2360
|
"import/no-duplicates": OFF,
|
|
2361
|
+
"no-restricted-syntax": "off",
|
|
2400
2362
|
"unused-imports/no-unused-vars": OFF
|
|
2401
2363
|
}
|
|
2402
2364
|
},
|
|
@@ -2419,10 +2381,7 @@ async function typescript(options = {}) {
|
|
|
2419
2381
|
}
|
|
2420
2382
|
|
|
2421
2383
|
// src/configs/unicorn.ts
|
|
2422
|
-
async function unicorn(
|
|
2423
|
-
const {
|
|
2424
|
-
overrides = {}
|
|
2425
|
-
} = options;
|
|
2384
|
+
async function unicorn() {
|
|
2426
2385
|
return [
|
|
2427
2386
|
{
|
|
2428
2387
|
name: "vinicunca:unicorn",
|
|
@@ -2442,8 +2401,7 @@ async function unicorn(options = {}) {
|
|
|
2442
2401
|
"unicorn/prefer-number-properties": ERROR,
|
|
2443
2402
|
"unicorn/prefer-string-starts-ends-with": ERROR,
|
|
2444
2403
|
"unicorn/prefer-type-error": ERROR,
|
|
2445
|
-
"unicorn/throw-new-error": ERROR
|
|
2446
|
-
...overrides
|
|
2404
|
+
"unicorn/throw-new-error": ERROR
|
|
2447
2405
|
}
|
|
2448
2406
|
}
|
|
2449
2407
|
];
|
|
@@ -2480,32 +2438,26 @@ async function unocss(options = {}) {
|
|
|
2480
2438
|
}
|
|
2481
2439
|
|
|
2482
2440
|
// src/configs/vue.ts
|
|
2483
|
-
var
|
|
2441
|
+
var import_eslint_merge_processors2 = require("eslint-merge-processors");
|
|
2484
2442
|
async function vue(options = {}) {
|
|
2485
2443
|
const {
|
|
2486
2444
|
files = [GLOB_VUE],
|
|
2487
2445
|
overrides = {},
|
|
2488
|
-
stylistic: stylistic2 = true
|
|
2489
|
-
typescript: typescript2 = {}
|
|
2446
|
+
stylistic: stylistic2 = true
|
|
2490
2447
|
} = options;
|
|
2448
|
+
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
2491
2449
|
const {
|
|
2492
2450
|
indent = 2
|
|
2493
2451
|
} = isBoolean(stylistic2) ? {} : stylistic2;
|
|
2494
|
-
let tsConfigOptions = {};
|
|
2495
|
-
const tsconfigPath = typescript2.tsconfigPath ?? [];
|
|
2496
|
-
if (!isEmpty(tsconfigPath)) {
|
|
2497
|
-
tsConfigOptions = {
|
|
2498
|
-
project: tsconfigPath,
|
|
2499
|
-
tsconfigRootDir: import_node_process2.default.cwd()
|
|
2500
|
-
};
|
|
2501
|
-
}
|
|
2502
2452
|
const [
|
|
2503
2453
|
pluginVue,
|
|
2504
|
-
parserVue
|
|
2454
|
+
parserVue,
|
|
2455
|
+
processorVueBlocks
|
|
2505
2456
|
] = await Promise.all([
|
|
2506
2457
|
// @ts-expect-error missing types
|
|
2507
2458
|
interopDefault(import("eslint-plugin-vue")),
|
|
2508
|
-
interopDefault(import("vue-eslint-parser"))
|
|
2459
|
+
interopDefault(import("vue-eslint-parser")),
|
|
2460
|
+
interopDefault(import("eslint-processor-vue-blocks"))
|
|
2509
2461
|
]);
|
|
2510
2462
|
return [
|
|
2511
2463
|
{
|
|
@@ -2523,39 +2475,30 @@ async function vue(options = {}) {
|
|
|
2523
2475
|
jsx: true
|
|
2524
2476
|
},
|
|
2525
2477
|
extraFileExtensions: [".vue"],
|
|
2526
|
-
parser:
|
|
2527
|
-
sourceType: "module"
|
|
2528
|
-
...tsConfigOptions
|
|
2478
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
2479
|
+
sourceType: "module"
|
|
2529
2480
|
}
|
|
2530
2481
|
},
|
|
2531
2482
|
name: "vinicunca:vue:rules",
|
|
2532
|
-
processor: pluginVue.processors[".vue"],
|
|
2483
|
+
processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors2.mergeProcessors)([
|
|
2484
|
+
pluginVue.processors[".vue"],
|
|
2485
|
+
processorVueBlocks({
|
|
2486
|
+
...sfcBlocks,
|
|
2487
|
+
blocks: {
|
|
2488
|
+
styles: true,
|
|
2489
|
+
...sfcBlocks.blocks
|
|
2490
|
+
}
|
|
2491
|
+
})
|
|
2492
|
+
]),
|
|
2533
2493
|
rules: {
|
|
2534
2494
|
...pluginVue.configs.base.rules,
|
|
2535
2495
|
...pluginVue.configs["vue3-essential"].rules,
|
|
2536
2496
|
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
2537
2497
|
...pluginVue.configs["vue3-recommended"].rules,
|
|
2538
2498
|
"node/prefer-global/process": OFF,
|
|
2539
|
-
"vue/array-bracket-spacing": [ERROR, NEVER],
|
|
2540
|
-
"vue/arrow-spacing": [ERROR, {
|
|
2541
|
-
after: true,
|
|
2542
|
-
before: true
|
|
2543
|
-
}],
|
|
2544
2499
|
"vue/block-order": [ERROR, {
|
|
2545
2500
|
order: ["script", "template", "style"]
|
|
2546
2501
|
}],
|
|
2547
|
-
"vue/block-spacing": [ERROR, ALWAYS],
|
|
2548
|
-
"vue/block-tag-newline": [ERROR, {
|
|
2549
|
-
multiline: ALWAYS,
|
|
2550
|
-
singleline: ALWAYS
|
|
2551
|
-
}],
|
|
2552
|
-
"vue/brace-style": [ERROR, "stroustrup", { allowSingleLine: true }],
|
|
2553
|
-
"vue/comma-dangle": [ERROR, "always-multiline"],
|
|
2554
|
-
"vue/comma-spacing": [ERROR, {
|
|
2555
|
-
after: true,
|
|
2556
|
-
before: false
|
|
2557
|
-
}],
|
|
2558
|
-
"vue/comma-style": [ERROR, "last"],
|
|
2559
2502
|
"vue/component-name-in-template-casing": [ERROR, "PascalCase"],
|
|
2560
2503
|
"vue/component-options-name-casing": [ERROR, "PascalCase"],
|
|
2561
2504
|
"vue/custom-event-name-casing": [ERROR, "camelCase"],
|
|
@@ -2565,18 +2508,7 @@ async function vue(options = {}) {
|
|
|
2565
2508
|
"vue/dot-location": [ERROR, "property"],
|
|
2566
2509
|
"vue/dot-notation": [ERROR, { allowKeywords: true }],
|
|
2567
2510
|
"vue/eqeqeq": [ERROR, "smart"],
|
|
2568
|
-
"vue/html-comment-content-spacing": [ERROR, ALWAYS, {
|
|
2569
|
-
exceptions: ["-"]
|
|
2570
|
-
}],
|
|
2571
2511
|
"vue/html-indent": [ERROR, indent],
|
|
2572
|
-
"vue/key-spacing": [ERROR, {
|
|
2573
|
-
afterColon: true,
|
|
2574
|
-
beforeColon: false
|
|
2575
|
-
}],
|
|
2576
|
-
"vue/keyword-spacing": [ERROR, {
|
|
2577
|
-
after: true,
|
|
2578
|
-
before: true
|
|
2579
|
-
}],
|
|
2580
2512
|
"vue/max-attributes-per-line": [ERROR],
|
|
2581
2513
|
"vue/multi-word-component-names": OFF,
|
|
2582
2514
|
"vue/no-constant-condition": WARN,
|
|
@@ -2599,28 +2531,58 @@ async function vue(options = {}) {
|
|
|
2599
2531
|
"vue/no-useless-v-bind": ERROR,
|
|
2600
2532
|
"vue/no-v-html": OFF,
|
|
2601
2533
|
"vue/no-v-text-v-html-on-component": OFF,
|
|
2602
|
-
"vue/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
|
|
2603
|
-
"vue/object-curly-spacing": [ERROR, ALWAYS],
|
|
2604
|
-
"vue/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
|
|
2605
2534
|
"vue/object-shorthand": [ERROR, ALWAYS, {
|
|
2606
2535
|
avoidQuotes: true,
|
|
2607
2536
|
ignoreConstructors: false
|
|
2608
2537
|
}],
|
|
2609
|
-
"vue/operator-linebreak": [ERROR, "before"],
|
|
2610
|
-
"vue/padding-line-between-blocks": [ERROR, ALWAYS],
|
|
2611
2538
|
"vue/prefer-import-from-vue": OFF,
|
|
2612
2539
|
"vue/prefer-separate-static-class": ERROR,
|
|
2613
2540
|
"vue/prefer-template": ERROR,
|
|
2614
|
-
"vue/quote-props": [ERROR, "consistent-as-needed"],
|
|
2615
2541
|
"vue/require-default-prop": OFF,
|
|
2616
2542
|
"vue/require-prop-types": OFF,
|
|
2617
|
-
"vue/space-in-parens": [ERROR, NEVER],
|
|
2618
2543
|
"vue/space-infix-ops": ERROR,
|
|
2619
2544
|
"vue/space-unary-ops": [ERROR, {
|
|
2620
2545
|
nonwords: false,
|
|
2621
2546
|
words: true
|
|
2622
2547
|
}],
|
|
2623
|
-
|
|
2548
|
+
...stylistic2 ? {
|
|
2549
|
+
"vue/array-bracket-spacing": [ERROR, NEVER],
|
|
2550
|
+
"vue/arrow-spacing": [ERROR, {
|
|
2551
|
+
after: true,
|
|
2552
|
+
before: true
|
|
2553
|
+
}],
|
|
2554
|
+
"vue/block-spacing": [ERROR, ALWAYS],
|
|
2555
|
+
"vue/block-tag-newline": [ERROR, {
|
|
2556
|
+
multiline: ALWAYS,
|
|
2557
|
+
singleline: ALWAYS
|
|
2558
|
+
}],
|
|
2559
|
+
"vue/brace-style": [ERROR, "stroustrup", { allowSingleLine: true }],
|
|
2560
|
+
"vue/comma-dangle": [ERROR, "always-multiline"],
|
|
2561
|
+
"vue/comma-spacing": [ERROR, {
|
|
2562
|
+
after: true,
|
|
2563
|
+
before: false
|
|
2564
|
+
}],
|
|
2565
|
+
"vue/comma-style": [ERROR, "last"],
|
|
2566
|
+
"vue/html-comment-content-spacing": [ERROR, ALWAYS, {
|
|
2567
|
+
exceptions: ["-"]
|
|
2568
|
+
}],
|
|
2569
|
+
"vue/key-spacing": [ERROR, {
|
|
2570
|
+
afterColon: true,
|
|
2571
|
+
beforeColon: false
|
|
2572
|
+
}],
|
|
2573
|
+
"vue/keyword-spacing": [ERROR, {
|
|
2574
|
+
after: true,
|
|
2575
|
+
before: true
|
|
2576
|
+
}],
|
|
2577
|
+
"vue/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
|
|
2578
|
+
"vue/object-curly-spacing": [ERROR, ALWAYS],
|
|
2579
|
+
"vue/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
|
|
2580
|
+
"vue/operator-linebreak": [ERROR, "before"],
|
|
2581
|
+
"vue/padding-line-between-blocks": [ERROR, ALWAYS],
|
|
2582
|
+
"vue/quote-props": [ERROR, "consistent-as-needed"],
|
|
2583
|
+
"vue/space-in-parens": [ERROR, NEVER],
|
|
2584
|
+
"vue/template-curly-spacing": ERROR
|
|
2585
|
+
} : {},
|
|
2624
2586
|
...overrides
|
|
2625
2587
|
}
|
|
2626
2588
|
}
|
|
@@ -2661,51 +2623,219 @@ async function yaml(options = {}) {
|
|
|
2661
2623
|
rules: {
|
|
2662
2624
|
"style/spaced-comment": OFF,
|
|
2663
2625
|
"yaml/block-mapping": ERROR,
|
|
2664
|
-
"yaml/block-mapping-question-indicator-newline": ERROR,
|
|
2665
2626
|
"yaml/block-sequence": ERROR,
|
|
2666
|
-
"yaml/block-sequence-hyphen-indicator-newline": ERROR,
|
|
2667
|
-
"yaml/flow-mapping-curly-newline": ERROR,
|
|
2668
|
-
"yaml/flow-mapping-curly-spacing": ERROR,
|
|
2669
|
-
"yaml/flow-sequence-bracket-newline": ERROR,
|
|
2670
|
-
"yaml/flow-sequence-bracket-spacing": ERROR,
|
|
2671
|
-
"yaml/indent": [ERROR, indent === "tab" ? 2 : indent],
|
|
2672
|
-
"yaml/key-spacing": ERROR,
|
|
2673
2627
|
"yaml/no-empty-key": ERROR,
|
|
2674
2628
|
"yaml/no-empty-sequence-entry": ERROR,
|
|
2675
2629
|
"yaml/no-irregular-whitespace": ERROR,
|
|
2676
|
-
"yaml/no-tab-indent": ERROR,
|
|
2677
2630
|
"yaml/plain-scalar": ERROR,
|
|
2678
|
-
"yaml/quotes": [ERROR, { avoidEscape: false, prefer: quotes }],
|
|
2679
|
-
"yaml/spaced-comment": ERROR,
|
|
2680
2631
|
"yaml/vue-custom-block/no-parsing-error": ERROR,
|
|
2632
|
+
...stylistic2 ? {
|
|
2633
|
+
"yaml/block-mapping-question-indicator-newline": ERROR,
|
|
2634
|
+
"yaml/block-sequence-hyphen-indicator-newline": ERROR,
|
|
2635
|
+
"yaml/flow-mapping-curly-newline": ERROR,
|
|
2636
|
+
"yaml/flow-mapping-curly-spacing": ERROR,
|
|
2637
|
+
"yaml/flow-sequence-bracket-newline": ERROR,
|
|
2638
|
+
"yaml/flow-sequence-bracket-spacing": ERROR,
|
|
2639
|
+
"yaml/indent": [ERROR, indent === "tab" ? 2 : indent],
|
|
2640
|
+
"yaml/key-spacing": ERROR,
|
|
2641
|
+
"yaml/no-tab-indent": ERROR,
|
|
2642
|
+
"yaml/quotes": [ERROR, { avoidEscape: false, prefer: quotes }],
|
|
2643
|
+
"yaml/spaced-comment": ERROR
|
|
2644
|
+
} : {},
|
|
2681
2645
|
...overrides
|
|
2682
2646
|
}
|
|
2683
2647
|
}
|
|
2684
2648
|
];
|
|
2685
2649
|
}
|
|
2686
2650
|
|
|
2651
|
+
// src/configs/formatters.ts
|
|
2652
|
+
async function formatters(options = {}, stylistic2 = {}) {
|
|
2653
|
+
if (options === true) {
|
|
2654
|
+
options = {
|
|
2655
|
+
css: true,
|
|
2656
|
+
graphql: true,
|
|
2657
|
+
html: true,
|
|
2658
|
+
markdown: true
|
|
2659
|
+
};
|
|
2660
|
+
}
|
|
2661
|
+
const {
|
|
2662
|
+
indent,
|
|
2663
|
+
quotes,
|
|
2664
|
+
semi
|
|
2665
|
+
} = {
|
|
2666
|
+
...STYLISTIC_CONFIG_DEFAULTS,
|
|
2667
|
+
...stylistic2
|
|
2668
|
+
};
|
|
2669
|
+
const prettierOptions = Object.assign(
|
|
2670
|
+
{
|
|
2671
|
+
endOfLine: "auto",
|
|
2672
|
+
semi,
|
|
2673
|
+
singleQuote: quotes === "single",
|
|
2674
|
+
tabWidth: typeof indent === "number" ? indent : 2,
|
|
2675
|
+
trailingComma: "all",
|
|
2676
|
+
useTabs: indent === "tab"
|
|
2677
|
+
},
|
|
2678
|
+
options.prettierOptions || {}
|
|
2679
|
+
);
|
|
2680
|
+
const dprintOptions = Object.assign(
|
|
2681
|
+
{
|
|
2682
|
+
indentWidth: typeof indent === "number" ? indent : 2,
|
|
2683
|
+
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
2684
|
+
useTabs: indent === "tab"
|
|
2685
|
+
},
|
|
2686
|
+
options.dprintOptions || {}
|
|
2687
|
+
);
|
|
2688
|
+
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
2689
|
+
const configs = [
|
|
2690
|
+
{
|
|
2691
|
+
name: "vinicunca:formatters:setup",
|
|
2692
|
+
plugins: {
|
|
2693
|
+
format: pluginFormat
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
];
|
|
2697
|
+
if (options.css) {
|
|
2698
|
+
configs.push(
|
|
2699
|
+
{
|
|
2700
|
+
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
2701
|
+
languageOptions: {
|
|
2702
|
+
parser: parserPlain
|
|
2703
|
+
},
|
|
2704
|
+
name: "vinicunca:formatter:css",
|
|
2705
|
+
rules: {
|
|
2706
|
+
"format/prettier": [
|
|
2707
|
+
"error",
|
|
2708
|
+
{
|
|
2709
|
+
...prettierOptions,
|
|
2710
|
+
parser: "css"
|
|
2711
|
+
}
|
|
2712
|
+
]
|
|
2713
|
+
}
|
|
2714
|
+
},
|
|
2715
|
+
{
|
|
2716
|
+
files: [GLOB_SCSS],
|
|
2717
|
+
languageOptions: {
|
|
2718
|
+
parser: parserPlain
|
|
2719
|
+
},
|
|
2720
|
+
name: "vinicunca:formatter:scss",
|
|
2721
|
+
rules: {
|
|
2722
|
+
"format/prettier": [
|
|
2723
|
+
"error",
|
|
2724
|
+
{
|
|
2725
|
+
...prettierOptions,
|
|
2726
|
+
parser: "scss"
|
|
2727
|
+
}
|
|
2728
|
+
]
|
|
2729
|
+
}
|
|
2730
|
+
},
|
|
2731
|
+
{
|
|
2732
|
+
files: [GLOB_LESS],
|
|
2733
|
+
languageOptions: {
|
|
2734
|
+
parser: parserPlain
|
|
2735
|
+
},
|
|
2736
|
+
name: "vinicunca:formatter:less",
|
|
2737
|
+
rules: {
|
|
2738
|
+
"format/prettier": [
|
|
2739
|
+
"error",
|
|
2740
|
+
{
|
|
2741
|
+
...prettierOptions,
|
|
2742
|
+
parser: "less"
|
|
2743
|
+
}
|
|
2744
|
+
]
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
);
|
|
2748
|
+
}
|
|
2749
|
+
if (options.html) {
|
|
2750
|
+
configs.push({
|
|
2751
|
+
files: ["**/*.html"],
|
|
2752
|
+
languageOptions: {
|
|
2753
|
+
parser: parserPlain
|
|
2754
|
+
},
|
|
2755
|
+
name: "vinicunca:formatter:html",
|
|
2756
|
+
rules: {
|
|
2757
|
+
"format/prettier": [
|
|
2758
|
+
"error",
|
|
2759
|
+
{
|
|
2760
|
+
...prettierOptions,
|
|
2761
|
+
parser: "html"
|
|
2762
|
+
}
|
|
2763
|
+
]
|
|
2764
|
+
}
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
if (options.markdown) {
|
|
2768
|
+
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
2769
|
+
configs.push({
|
|
2770
|
+
files: [GLOB_MARKDOWN],
|
|
2771
|
+
languageOptions: {
|
|
2772
|
+
parser: parserPlain
|
|
2773
|
+
},
|
|
2774
|
+
name: "vinicunca:formatter:markdown",
|
|
2775
|
+
rules: {
|
|
2776
|
+
[`format/${formater}`]: [
|
|
2777
|
+
"error",
|
|
2778
|
+
formater === "prettier" ? {
|
|
2779
|
+
printWidth: 120,
|
|
2780
|
+
...prettierOptions,
|
|
2781
|
+
embeddedLanguageFormatting: "off",
|
|
2782
|
+
parser: "markdown"
|
|
2783
|
+
} : {
|
|
2784
|
+
...dprintOptions,
|
|
2785
|
+
language: "markdown"
|
|
2786
|
+
}
|
|
2787
|
+
]
|
|
2788
|
+
}
|
|
2789
|
+
});
|
|
2790
|
+
}
|
|
2791
|
+
if (options.graphql) {
|
|
2792
|
+
configs.push({
|
|
2793
|
+
files: ["**/*.graphql"],
|
|
2794
|
+
languageOptions: {
|
|
2795
|
+
parser: parserPlain
|
|
2796
|
+
},
|
|
2797
|
+
name: "vinicunca:formatter:graphql",
|
|
2798
|
+
rules: {
|
|
2799
|
+
"format/prettier": [
|
|
2800
|
+
"error",
|
|
2801
|
+
{
|
|
2802
|
+
...prettierOptions,
|
|
2803
|
+
parser: "graphql"
|
|
2804
|
+
}
|
|
2805
|
+
]
|
|
2806
|
+
}
|
|
2807
|
+
});
|
|
2808
|
+
}
|
|
2809
|
+
return configs;
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2687
2812
|
// src/base.ts
|
|
2813
|
+
var flatConfigProps = [
|
|
2814
|
+
"files",
|
|
2815
|
+
"ignores",
|
|
2816
|
+
"languageOptions",
|
|
2817
|
+
"linterOptions",
|
|
2818
|
+
"processor",
|
|
2819
|
+
"plugins",
|
|
2820
|
+
"rules",
|
|
2821
|
+
"settings"
|
|
2822
|
+
];
|
|
2688
2823
|
var VuePackages = [
|
|
2689
2824
|
"vue",
|
|
2690
2825
|
"nuxt",
|
|
2691
2826
|
"vitepress",
|
|
2692
2827
|
"@slidev/cli"
|
|
2693
2828
|
];
|
|
2694
|
-
async function vinicuncaESLint(
|
|
2829
|
+
async function vinicuncaESLint(options = {}, ...userConfigs) {
|
|
2695
2830
|
const {
|
|
2696
2831
|
componentExts = [],
|
|
2697
|
-
isInEditor = !!((
|
|
2698
|
-
jsonc: enableJsonc = true,
|
|
2699
|
-
markdown: enableMarkdown = true,
|
|
2700
|
-
overrides = {},
|
|
2832
|
+
isInEditor = !!((import_node_process2.default.env.VSCODE_PID || import_node_process2.default.env.JETBRAINS_IDE || import_node_process2.default.env.VIM) && !import_node_process2.default.env.CI),
|
|
2701
2833
|
react: enableReact = false,
|
|
2702
|
-
|
|
2703
|
-
typescript: tsOptions = {},
|
|
2834
|
+
typescript: enableTypeScript = (0, import_local_pkg.isPackageExists)("typescript"),
|
|
2704
2835
|
unocss: enableUnoCSS = false,
|
|
2705
|
-
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i))
|
|
2706
|
-
yaml: enableYaml = true
|
|
2836
|
+
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i))
|
|
2707
2837
|
} = options;
|
|
2708
|
-
let stylisticOptions =
|
|
2838
|
+
let stylisticOptions = {};
|
|
2709
2839
|
if (options.stylistic === false) {
|
|
2710
2840
|
stylisticOptions = false;
|
|
2711
2841
|
} else if (isObject(options.stylistic)) {
|
|
@@ -2719,106 +2849,139 @@ async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
|
2719
2849
|
ignores(options.ignores),
|
|
2720
2850
|
javascript({
|
|
2721
2851
|
isInEditor,
|
|
2722
|
-
overrides:
|
|
2852
|
+
overrides: getOverrides(options, "javascript")
|
|
2723
2853
|
}),
|
|
2724
2854
|
comments(),
|
|
2725
2855
|
node(),
|
|
2726
|
-
jsdoc(
|
|
2856
|
+
jsdoc({
|
|
2857
|
+
stylistic: stylisticOptions
|
|
2858
|
+
}),
|
|
2727
2859
|
imports(),
|
|
2728
2860
|
unicorn()
|
|
2729
2861
|
);
|
|
2730
2862
|
if (enableVue) {
|
|
2731
2863
|
componentExts.push("vue");
|
|
2732
2864
|
}
|
|
2733
|
-
|
|
2734
|
-
enabled: tsEnabled = (0, import_local_pkg.isPackageExists)("typescript"),
|
|
2735
|
-
...tsParams
|
|
2736
|
-
} = tsOptions;
|
|
2737
|
-
if (tsEnabled) {
|
|
2865
|
+
if (enableTypeScript) {
|
|
2738
2866
|
configs.push(typescript({
|
|
2739
|
-
...
|
|
2740
|
-
componentExts
|
|
2741
|
-
overrides: overrides.typescript
|
|
2867
|
+
...resolveSubOptions(options, "typescript"),
|
|
2868
|
+
componentExts
|
|
2742
2869
|
}));
|
|
2743
2870
|
}
|
|
2744
2871
|
if (stylisticOptions) {
|
|
2745
|
-
configs.push(stylistic(
|
|
2872
|
+
configs.push(stylistic({
|
|
2873
|
+
...stylisticOptions,
|
|
2874
|
+
overrides: getOverrides(options, "stylistic")
|
|
2875
|
+
}));
|
|
2746
2876
|
}
|
|
2747
|
-
if (
|
|
2877
|
+
if (options.test ?? true) {
|
|
2748
2878
|
configs.push(test({
|
|
2749
2879
|
isInEditor,
|
|
2750
|
-
overrides:
|
|
2880
|
+
overrides: getOverrides(options, "test")
|
|
2751
2881
|
}));
|
|
2752
2882
|
}
|
|
2753
|
-
;
|
|
2754
2883
|
if (enableVue) {
|
|
2755
2884
|
configs.push(vue({
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
...tsParams
|
|
2760
|
-
}
|
|
2885
|
+
...resolveSubOptions(options, "vue"),
|
|
2886
|
+
stylistic: stylisticOptions,
|
|
2887
|
+
typescript: !!enableTypeScript
|
|
2761
2888
|
}));
|
|
2762
2889
|
}
|
|
2763
|
-
;
|
|
2764
2890
|
if (enableReact) {
|
|
2765
2891
|
configs.push(react({
|
|
2766
|
-
overrides:
|
|
2892
|
+
overrides: getOverrides(options, "react"),
|
|
2893
|
+
typescript: !!enableTypeScript
|
|
2767
2894
|
}));
|
|
2768
2895
|
}
|
|
2769
2896
|
if (enableUnoCSS) {
|
|
2770
|
-
configs.push(unocss(
|
|
2771
|
-
|
|
2772
|
-
|
|
2897
|
+
configs.push(unocss({
|
|
2898
|
+
...resolveSubOptions(options, "unocss"),
|
|
2899
|
+
overrides: getOverrides(options, "unocss")
|
|
2900
|
+
}));
|
|
2773
2901
|
}
|
|
2774
|
-
if (
|
|
2902
|
+
if (options.jsonc ?? true) {
|
|
2775
2903
|
configs.push(
|
|
2776
2904
|
jsonc({
|
|
2777
|
-
overrides:
|
|
2905
|
+
overrides: getOverrides(options, "jsonc"),
|
|
2778
2906
|
stylistic: stylisticOptions
|
|
2779
2907
|
}),
|
|
2780
2908
|
sortPackageJson(),
|
|
2781
2909
|
sortTsconfig()
|
|
2782
2910
|
);
|
|
2783
2911
|
}
|
|
2784
|
-
if (
|
|
2912
|
+
if (options.yaml ?? true) {
|
|
2785
2913
|
configs.push(yaml({
|
|
2786
|
-
overrides:
|
|
2914
|
+
overrides: getOverrides(options, "yaml"),
|
|
2787
2915
|
stylistic: stylisticOptions
|
|
2788
2916
|
}));
|
|
2789
2917
|
}
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2918
|
+
if (options.markdown ?? true) {
|
|
2919
|
+
configs.push(
|
|
2920
|
+
markdown(
|
|
2921
|
+
{
|
|
2922
|
+
componentExts,
|
|
2923
|
+
overrides: getOverrides(options, "markdown")
|
|
2924
|
+
}
|
|
2925
|
+
)
|
|
2926
|
+
);
|
|
2927
|
+
}
|
|
2928
|
+
if (options.formatters) {
|
|
2929
|
+
configs.push(formatters(
|
|
2930
|
+
options.formatters,
|
|
2931
|
+
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2932
|
+
));
|
|
2933
|
+
}
|
|
2934
|
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2935
|
+
if (key in options) {
|
|
2936
|
+
acc[key] = options[key];
|
|
2937
|
+
}
|
|
2938
|
+
;
|
|
2939
|
+
return acc;
|
|
2940
|
+
}, {});
|
|
2941
|
+
if (Object.keys(fusedConfig).length) {
|
|
2942
|
+
configs.push([fusedConfig]);
|
|
2796
2943
|
}
|
|
2797
2944
|
;
|
|
2798
|
-
configs.push(ignores(options.ignores));
|
|
2799
2945
|
return combineConfigs(
|
|
2800
2946
|
...configs,
|
|
2801
2947
|
...userConfigs
|
|
2802
2948
|
);
|
|
2803
2949
|
}
|
|
2950
|
+
function getOverrides(options, key) {
|
|
2951
|
+
const sub = resolveSubOptions(options, key);
|
|
2952
|
+
return {
|
|
2953
|
+
..."overrides" in sub ? sub.overrides : {}
|
|
2954
|
+
};
|
|
2955
|
+
}
|
|
2956
|
+
function resolveSubOptions(options, key) {
|
|
2957
|
+
return isBoolean(options[key]) ? {} : options[key] || {};
|
|
2958
|
+
}
|
|
2804
2959
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2805
2960
|
0 && (module.exports = {
|
|
2961
|
+
GLOB_ALL_SRC,
|
|
2962
|
+
GLOB_CSS,
|
|
2806
2963
|
GLOB_EXCLUDE,
|
|
2964
|
+
GLOB_HTML,
|
|
2807
2965
|
GLOB_JS,
|
|
2808
2966
|
GLOB_JSON,
|
|
2809
2967
|
GLOB_JSON5,
|
|
2810
2968
|
GLOB_JSONC,
|
|
2811
2969
|
GLOB_JSX,
|
|
2970
|
+
GLOB_LESS,
|
|
2812
2971
|
GLOB_MARKDOWN,
|
|
2813
2972
|
GLOB_MARKDOWN_CODE,
|
|
2814
2973
|
GLOB_MARKDOWN_IN_MARKDOWN,
|
|
2974
|
+
GLOB_POSTCSS,
|
|
2975
|
+
GLOB_SCSS,
|
|
2815
2976
|
GLOB_SRC,
|
|
2816
2977
|
GLOB_SRC_EXT,
|
|
2978
|
+
GLOB_STYLE,
|
|
2817
2979
|
GLOB_TESTS,
|
|
2818
2980
|
GLOB_TS,
|
|
2819
2981
|
GLOB_TSX,
|
|
2820
2982
|
GLOB_VUE,
|
|
2821
2983
|
GLOB_YAML,
|
|
2984
|
+
STYLISTIC_CONFIG_DEFAULTS,
|
|
2822
2985
|
combineConfigs,
|
|
2823
2986
|
comments,
|
|
2824
2987
|
ignores,
|
|
@@ -2829,6 +2992,7 @@ async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
|
2829
2992
|
jsonc,
|
|
2830
2993
|
markdown,
|
|
2831
2994
|
node,
|
|
2995
|
+
parserPlain,
|
|
2832
2996
|
pluginComments,
|
|
2833
2997
|
pluginImport,
|
|
2834
2998
|
pluginNode,
|
|
@@ -2842,6 +3006,7 @@ async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
|
2842
3006
|
sortTsconfig,
|
|
2843
3007
|
stylistic,
|
|
2844
3008
|
test,
|
|
3009
|
+
toArray,
|
|
2845
3010
|
typescript,
|
|
2846
3011
|
unicorn,
|
|
2847
3012
|
unocss,
|