@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.cjs +450 -281
- package/dist/index.d.cts +239 -45
- package/dist/index.d.ts +239 -45
- package/dist/index.js +440 -281
- package/package.json +29 -23
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,14 +1534,39 @@ 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",
|
|
1533
1569
|
plugins: {
|
|
1534
|
-
// @ts-expect-error missing types
|
|
1535
1570
|
jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
|
|
1536
1571
|
},
|
|
1537
1572
|
rules: {
|
|
@@ -1553,7 +1588,11 @@ async function jsdoc() {
|
|
|
1553
1588
|
"jsdoc/require-returns-check": WARN,
|
|
1554
1589
|
"jsdoc/require-returns-description": WARN,
|
|
1555
1590
|
"jsdoc/require-yields-check": WARN,
|
|
1556
|
-
"jsdoc/valid-types": WARN
|
|
1591
|
+
"jsdoc/valid-types": WARN,
|
|
1592
|
+
...stylistic2 ? {
|
|
1593
|
+
"jsdoc/check-alignment": "warn",
|
|
1594
|
+
"jsdoc/multiline-blocks": "warn"
|
|
1595
|
+
} : {}
|
|
1557
1596
|
}
|
|
1558
1597
|
}
|
|
1559
1598
|
];
|
|
@@ -1635,30 +1674,41 @@ async function jsonc(options = {}) {
|
|
|
1635
1674
|
}
|
|
1636
1675
|
|
|
1637
1676
|
// src/configs/markdown.ts
|
|
1677
|
+
var import_eslint_merge_processors = require("eslint-merge-processors");
|
|
1638
1678
|
async function markdown(options = {}) {
|
|
1639
1679
|
const {
|
|
1640
1680
|
componentExts = [],
|
|
1641
1681
|
files = [GLOB_MARKDOWN],
|
|
1642
1682
|
overrides = {}
|
|
1643
1683
|
} = options;
|
|
1684
|
+
const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
|
|
1644
1685
|
return [
|
|
1645
1686
|
{
|
|
1646
1687
|
name: "vinicunca:markdown:setup",
|
|
1647
1688
|
plugins: {
|
|
1648
|
-
|
|
1649
|
-
markdown: await interopDefault(import("eslint-plugin-markdown"))
|
|
1689
|
+
markdown: markdown2
|
|
1650
1690
|
}
|
|
1651
1691
|
},
|
|
1652
1692
|
{
|
|
1653
1693
|
files,
|
|
1654
1694
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
1655
1695
|
name: "vinicunca:markdown:processor",
|
|
1656
|
-
|
|
1696
|
+
/**
|
|
1697
|
+
* `eslint-plugin-markdown` only creates virtual files for code blocks,
|
|
1698
|
+
* but not the markdown file itself. We use `eslint-merge-processors` to
|
|
1699
|
+
* add a pass-through processor for the markdown file itself.
|
|
1700
|
+
*/
|
|
1701
|
+
processor: (0, import_eslint_merge_processors.mergeProcessors)([
|
|
1702
|
+
markdown2.processors.markdown,
|
|
1703
|
+
import_eslint_merge_processors.processorPassThrough
|
|
1704
|
+
])
|
|
1657
1705
|
},
|
|
1658
1706
|
{
|
|
1659
|
-
files
|
|
1660
|
-
|
|
1661
|
-
|
|
1707
|
+
files,
|
|
1708
|
+
languageOptions: {
|
|
1709
|
+
parser: parserPlain
|
|
1710
|
+
},
|
|
1711
|
+
name: "vinicunca:markdown:parser"
|
|
1662
1712
|
},
|
|
1663
1713
|
{
|
|
1664
1714
|
files: [
|
|
@@ -2080,6 +2130,8 @@ var STYLISTIC_CONFIG_DEFAULTS = {
|
|
|
2080
2130
|
async function stylistic(options = {}) {
|
|
2081
2131
|
const {
|
|
2082
2132
|
indent,
|
|
2133
|
+
jsx,
|
|
2134
|
+
overrides = {},
|
|
2083
2135
|
quotes,
|
|
2084
2136
|
semi
|
|
2085
2137
|
} = {
|
|
@@ -2087,6 +2139,14 @@ async function stylistic(options = {}) {
|
|
|
2087
2139
|
...options
|
|
2088
2140
|
};
|
|
2089
2141
|
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
2142
|
+
const config = pluginStylistic.configs.customize({
|
|
2143
|
+
flat: true,
|
|
2144
|
+
indent,
|
|
2145
|
+
jsx,
|
|
2146
|
+
pluginName: "style",
|
|
2147
|
+
quotes,
|
|
2148
|
+
semi
|
|
2149
|
+
});
|
|
2090
2150
|
return [
|
|
2091
2151
|
{
|
|
2092
2152
|
name: "vinicunca:stylistic",
|
|
@@ -2095,83 +2155,15 @@ async function stylistic(options = {}) {
|
|
|
2095
2155
|
vinicunca: import_eslint_plugin_vinicunca.default
|
|
2096
2156
|
},
|
|
2097
2157
|
rules: {
|
|
2158
|
+
...config.rules,
|
|
2098
2159
|
"curly": [ERROR, "all"],
|
|
2099
2160
|
"style/array-bracket-newline": [ERROR, CONSISTENT],
|
|
2100
2161
|
"style/array-bracket-spacing": [ERROR, NEVER],
|
|
2101
2162
|
"style/array-element-newline": [ERROR, CONSISTENT],
|
|
2102
2163
|
"style/arrow-parens": [ERROR, ALWAYS],
|
|
2103
|
-
"style/arrow-spacing": [ERROR, { after: true, before: true }],
|
|
2104
|
-
"style/block-spacing": [ERROR, ALWAYS],
|
|
2105
2164
|
"style/brace-style": [ERROR],
|
|
2106
|
-
"style/comma-dangle": [ERROR, "always-multiline"],
|
|
2107
|
-
"style/comma-spacing": [ERROR, { after: true, before: false }],
|
|
2108
|
-
"style/comma-style": [ERROR, "last"],
|
|
2109
|
-
"style/computed-property-spacing": [ERROR, NEVER, { enforceForClassMembers: true }],
|
|
2110
|
-
"style/dot-location": [ERROR, "property"],
|
|
2111
|
-
"style/eol-last": ERROR,
|
|
2112
2165
|
"style/func-call-spacing": [ERROR, NEVER],
|
|
2113
|
-
"style/indent": [ERROR, indent, {
|
|
2114
|
-
ArrayExpression: 1,
|
|
2115
|
-
CallExpression: { arguments: 1 },
|
|
2116
|
-
FunctionDeclaration: { body: 1, parameters: 1 },
|
|
2117
|
-
FunctionExpression: { body: 1, parameters: 1 },
|
|
2118
|
-
ImportDeclaration: 1,
|
|
2119
|
-
MemberExpression: 1,
|
|
2120
|
-
ObjectExpression: 1,
|
|
2121
|
-
SwitchCase: 1,
|
|
2122
|
-
VariableDeclarator: 1,
|
|
2123
|
-
flatTernaryExpressions: false,
|
|
2124
|
-
ignoreComments: false,
|
|
2125
|
-
ignoredNodes: [
|
|
2126
|
-
"TemplateLiteral *",
|
|
2127
|
-
"JSXElement",
|
|
2128
|
-
"JSXElement > *",
|
|
2129
|
-
"JSXAttribute",
|
|
2130
|
-
"JSXIdentifier",
|
|
2131
|
-
"JSXNamespacedName",
|
|
2132
|
-
"JSXMemberExpression",
|
|
2133
|
-
"JSXSpreadAttribute",
|
|
2134
|
-
"JSXExpressionContainer",
|
|
2135
|
-
"JSXOpeningElement",
|
|
2136
|
-
"JSXClosingElement",
|
|
2137
|
-
"JSXFragment",
|
|
2138
|
-
"JSXOpeningFragment",
|
|
2139
|
-
"JSXClosingFragment",
|
|
2140
|
-
"JSXText",
|
|
2141
|
-
"JSXEmptyExpression",
|
|
2142
|
-
"JSXSpreadChild",
|
|
2143
|
-
"TSTypeParameterInstantiation",
|
|
2144
|
-
"FunctionExpression > .params[decorators.length > 0]",
|
|
2145
|
-
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
|
|
2146
|
-
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
|
|
2147
|
-
],
|
|
2148
|
-
offsetTernaryExpressions: true,
|
|
2149
|
-
outerIIFEBody: 1
|
|
2150
|
-
}],
|
|
2151
|
-
"style/indent-binary-ops": [ERROR, indent],
|
|
2152
|
-
"style/key-spacing": [ERROR, { afterColon: true, beforeColon: false }],
|
|
2153
|
-
"style/keyword-spacing": [ERROR, { after: true, before: true }],
|
|
2154
|
-
"style/lines-between-class-members": [ERROR, ALWAYS, { exceptAfterSingleLine: true }],
|
|
2155
|
-
"style/max-statements-per-line": [ERROR, { max: 1 }],
|
|
2156
2166
|
"style/member-delimiter-style": [ERROR],
|
|
2157
|
-
"style/multiline-ternary": [ERROR, "always-multiline"],
|
|
2158
|
-
"style/new-parens": ERROR,
|
|
2159
|
-
"style/no-extra-parens": [ERROR, "functions"],
|
|
2160
|
-
"style/no-floating-decimal": ERROR,
|
|
2161
|
-
"style/no-mixed-operators": [ERROR, {
|
|
2162
|
-
allowSamePrecedence: true,
|
|
2163
|
-
groups: [
|
|
2164
|
-
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
|
|
2165
|
-
["&&", "||"],
|
|
2166
|
-
["in", "instanceof"]
|
|
2167
|
-
]
|
|
2168
|
-
}],
|
|
2169
|
-
"style/no-mixed-spaces-and-tabs": ERROR,
|
|
2170
|
-
"style/no-multi-spaces": ERROR,
|
|
2171
|
-
"style/no-multiple-empty-lines": [ERROR, { max: 1, maxBOF: 0, maxEOF: 1 }],
|
|
2172
|
-
"style/no-tabs": ERROR,
|
|
2173
|
-
"style/no-trailing-spaces": ERROR,
|
|
2174
|
-
"style/no-whitespace-before-property": ERROR,
|
|
2175
2167
|
"style/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
|
|
2176
2168
|
"style/object-curly-spacing": [ERROR, ALWAYS],
|
|
2177
2169
|
"style/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
|
|
@@ -2182,36 +2174,10 @@ async function stylistic(options = {}) {
|
|
|
2182
2174
|
"style/rest-spread-spacing": [ERROR, NEVER],
|
|
2183
2175
|
"style/semi": [ERROR, semi ? ALWAYS : NEVER],
|
|
2184
2176
|
"style/semi-spacing": [ERROR, { after: true, before: false }],
|
|
2185
|
-
"style/space-before-blocks": [ERROR, ALWAYS],
|
|
2186
|
-
"style/space-before-function-paren": [ERROR, {
|
|
2187
|
-
anonymous: NEVER,
|
|
2188
|
-
asyncArrow: ALWAYS,
|
|
2189
|
-
named: NEVER
|
|
2190
|
-
}],
|
|
2191
|
-
"style/space-in-parens": [ERROR, NEVER],
|
|
2192
|
-
"style/space-infix-ops": ERROR,
|
|
2193
|
-
"style/space-unary-ops": [ERROR, { nonwords: false, words: true }],
|
|
2194
|
-
"style/spaced-comment": [ERROR, "always", {
|
|
2195
|
-
block: {
|
|
2196
|
-
balanced: true,
|
|
2197
|
-
exceptions: ["*"],
|
|
2198
|
-
markers: ["!"]
|
|
2199
|
-
},
|
|
2200
|
-
line: {
|
|
2201
|
-
exceptions: ["/", "#"],
|
|
2202
|
-
markers: ["/"]
|
|
2203
|
-
}
|
|
2204
|
-
}],
|
|
2205
|
-
"style/template-curly-spacing": ERROR,
|
|
2206
|
-
"style/template-tag-spacing": [ERROR, NEVER],
|
|
2207
|
-
"style/type-annotation-spacing": [ERROR, {}],
|
|
2208
|
-
"style/wrap-iife": [ERROR, "any", {
|
|
2209
|
-
functionPrototypeMethods: true
|
|
2210
|
-
}],
|
|
2211
|
-
"style/yield-star-spacing": [ERROR, "both"],
|
|
2212
2177
|
"vinicunca/consistent-list-newline": ERROR,
|
|
2213
2178
|
"vinicunca/if-newline": ERROR,
|
|
2214
|
-
"vinicunca/top-level-function": ERROR
|
|
2179
|
+
"vinicunca/top-level-function": ERROR,
|
|
2180
|
+
...overrides
|
|
2215
2181
|
}
|
|
2216
2182
|
},
|
|
2217
2183
|
{
|
|
@@ -2256,6 +2222,7 @@ async function test(options = {}) {
|
|
|
2256
2222
|
files,
|
|
2257
2223
|
name: "vinicunca:test:rules",
|
|
2258
2224
|
rules: {
|
|
2225
|
+
"node/prefer-global/process": OFF,
|
|
2259
2226
|
"test/consistent-test-it": [ERROR, { fn: "it", withinDescribe: "it" }],
|
|
2260
2227
|
"test/no-identical-title": ERROR,
|
|
2261
2228
|
"test/no-only-tests": isInEditor ? OFF : ERROR,
|
|
@@ -2273,13 +2240,13 @@ async function typescript(options = {}) {
|
|
|
2273
2240
|
const {
|
|
2274
2241
|
componentExts = [],
|
|
2275
2242
|
overrides = {},
|
|
2276
|
-
parserOptions = {}
|
|
2277
|
-
tsconfigPath = []
|
|
2243
|
+
parserOptions = {}
|
|
2278
2244
|
} = options ?? {};
|
|
2279
2245
|
const files = options.files ?? [
|
|
2280
2246
|
GLOB_SRC,
|
|
2281
2247
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
2282
2248
|
];
|
|
2249
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
2283
2250
|
const typeAwareRules = {
|
|
2284
2251
|
"dot-notation": OFF,
|
|
2285
2252
|
"no-implied-eval": OFF,
|
|
@@ -2295,31 +2262,19 @@ async function typescript(options = {}) {
|
|
|
2295
2262
|
"ts/restrict-plus-operands": ERROR,
|
|
2296
2263
|
"ts/restrict-template-expressions": ERROR
|
|
2297
2264
|
};
|
|
2298
|
-
|
|
2299
|
-
let additionalTypeAwareRules = {};
|
|
2300
|
-
if (!isEmpty(tsconfigPath)) {
|
|
2301
|
-
tsConfigOptions = {
|
|
2302
|
-
project: tsconfigPath,
|
|
2303
|
-
tsconfigRootDir: import_node_process.default.cwd()
|
|
2304
|
-
};
|
|
2305
|
-
additionalTypeAwareRules = typeAwareRules;
|
|
2306
|
-
}
|
|
2265
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
2307
2266
|
const [
|
|
2308
2267
|
pluginTs,
|
|
2309
|
-
parserTs
|
|
2310
|
-
pluginStylistic
|
|
2268
|
+
parserTs
|
|
2311
2269
|
] = await Promise.all([
|
|
2312
2270
|
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
2313
|
-
interopDefault(import("@typescript-eslint/parser"))
|
|
2314
|
-
interopDefault(import("@stylistic/eslint-plugin"))
|
|
2271
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
2315
2272
|
]);
|
|
2316
2273
|
return [
|
|
2317
2274
|
{
|
|
2318
2275
|
// Install the plugins without globs, so they can be configured separately.
|
|
2319
2276
|
name: "vinicunca:typescript:setup",
|
|
2320
2277
|
plugins: {
|
|
2321
|
-
import: pluginImport,
|
|
2322
|
-
style: pluginStylistic,
|
|
2323
2278
|
ts: pluginTs,
|
|
2324
2279
|
vinicunca: import_eslint_plugin_vinicunca.default
|
|
2325
2280
|
}
|
|
@@ -2331,7 +2286,10 @@ async function typescript(options = {}) {
|
|
|
2331
2286
|
parserOptions: {
|
|
2332
2287
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
2333
2288
|
sourceType: "module",
|
|
2334
|
-
...
|
|
2289
|
+
...tsconfigPath ? {
|
|
2290
|
+
project: tsconfigPath,
|
|
2291
|
+
tsconfigRootDir: import_node_process.default.cwd()
|
|
2292
|
+
} : {},
|
|
2335
2293
|
...parserOptions
|
|
2336
2294
|
}
|
|
2337
2295
|
},
|
|
@@ -2354,8 +2312,6 @@ async function typescript(options = {}) {
|
|
|
2354
2312
|
"no-unused-vars": OFF,
|
|
2355
2313
|
"no-use-before-define": OFF,
|
|
2356
2314
|
"no-useless-constructor": OFF,
|
|
2357
|
-
"style/type-generic-spacing": ERROR,
|
|
2358
|
-
"style/type-named-tuple-spacing": ERROR,
|
|
2359
2315
|
"ts/ban-ts-comment": [ERROR, { "ts-ignore": "allow-with-description" }],
|
|
2360
2316
|
"ts/ban-types": [ERROR, { types: { Function: false } }],
|
|
2361
2317
|
"ts/consistent-type-definitions": [ERROR, "interface"],
|
|
@@ -2378,14 +2334,21 @@ async function typescript(options = {}) {
|
|
|
2378
2334
|
"ts/no-unused-vars": [ERROR, {
|
|
2379
2335
|
argsIgnorePattern: "^_",
|
|
2380
2336
|
destructuredArrayIgnorePattern: "^_",
|
|
2381
|
-
ignoreRestSiblings: true
|
|
2337
|
+
ignoreRestSiblings: true,
|
|
2338
|
+
varsIgnorePattern: "^_"
|
|
2382
2339
|
}],
|
|
2383
2340
|
"ts/no-use-before-define": [ERROR, { classes: false, functions: false, variables: true }],
|
|
2384
2341
|
"ts/parameter-properties": OFF,
|
|
2385
2342
|
"ts/prefer-ts-expect-error": ERROR,
|
|
2386
2343
|
"ts/triple-slash-reference": OFF,
|
|
2387
|
-
|
|
2388
|
-
|
|
2344
|
+
...overrides
|
|
2345
|
+
}
|
|
2346
|
+
},
|
|
2347
|
+
{
|
|
2348
|
+
files: filesTypeAware,
|
|
2349
|
+
name: "vinicunca:typescript:rules-type-aware",
|
|
2350
|
+
rules: {
|
|
2351
|
+
...tsconfigPath ? typeAwareRules : {},
|
|
2389
2352
|
...overrides
|
|
2390
2353
|
}
|
|
2391
2354
|
},
|
|
@@ -2395,6 +2358,7 @@ async function typescript(options = {}) {
|
|
|
2395
2358
|
rules: {
|
|
2396
2359
|
"eslint-comments/no-unlimited-disable": OFF,
|
|
2397
2360
|
"import/no-duplicates": OFF,
|
|
2361
|
+
"no-restricted-syntax": "off",
|
|
2398
2362
|
"unused-imports/no-unused-vars": OFF
|
|
2399
2363
|
}
|
|
2400
2364
|
},
|
|
@@ -2417,10 +2381,7 @@ async function typescript(options = {}) {
|
|
|
2417
2381
|
}
|
|
2418
2382
|
|
|
2419
2383
|
// src/configs/unicorn.ts
|
|
2420
|
-
async function unicorn(
|
|
2421
|
-
const {
|
|
2422
|
-
overrides = {}
|
|
2423
|
-
} = options;
|
|
2384
|
+
async function unicorn() {
|
|
2424
2385
|
return [
|
|
2425
2386
|
{
|
|
2426
2387
|
name: "vinicunca:unicorn",
|
|
@@ -2440,8 +2401,7 @@ async function unicorn(options = {}) {
|
|
|
2440
2401
|
"unicorn/prefer-number-properties": ERROR,
|
|
2441
2402
|
"unicorn/prefer-string-starts-ends-with": ERROR,
|
|
2442
2403
|
"unicorn/prefer-type-error": ERROR,
|
|
2443
|
-
"unicorn/throw-new-error": ERROR
|
|
2444
|
-
...overrides
|
|
2404
|
+
"unicorn/throw-new-error": ERROR
|
|
2445
2405
|
}
|
|
2446
2406
|
}
|
|
2447
2407
|
];
|
|
@@ -2478,32 +2438,26 @@ async function unocss(options = {}) {
|
|
|
2478
2438
|
}
|
|
2479
2439
|
|
|
2480
2440
|
// src/configs/vue.ts
|
|
2481
|
-
var
|
|
2441
|
+
var import_eslint_merge_processors2 = require("eslint-merge-processors");
|
|
2482
2442
|
async function vue(options = {}) {
|
|
2483
2443
|
const {
|
|
2484
2444
|
files = [GLOB_VUE],
|
|
2485
2445
|
overrides = {},
|
|
2486
|
-
stylistic: stylistic2 = true
|
|
2487
|
-
typescript: typescript2 = {}
|
|
2446
|
+
stylistic: stylistic2 = true
|
|
2488
2447
|
} = options;
|
|
2448
|
+
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
2489
2449
|
const {
|
|
2490
2450
|
indent = 2
|
|
2491
2451
|
} = isBoolean(stylistic2) ? {} : stylistic2;
|
|
2492
|
-
let tsConfigOptions = {};
|
|
2493
|
-
const tsconfigPath = typescript2.tsconfigPath ?? [];
|
|
2494
|
-
if (!isEmpty(tsconfigPath)) {
|
|
2495
|
-
tsConfigOptions = {
|
|
2496
|
-
project: tsconfigPath,
|
|
2497
|
-
tsconfigRootDir: import_node_process2.default.cwd()
|
|
2498
|
-
};
|
|
2499
|
-
}
|
|
2500
2452
|
const [
|
|
2501
2453
|
pluginVue,
|
|
2502
|
-
parserVue
|
|
2454
|
+
parserVue,
|
|
2455
|
+
processorVueBlocks
|
|
2503
2456
|
] = await Promise.all([
|
|
2504
2457
|
// @ts-expect-error missing types
|
|
2505
2458
|
interopDefault(import("eslint-plugin-vue")),
|
|
2506
|
-
interopDefault(import("vue-eslint-parser"))
|
|
2459
|
+
interopDefault(import("vue-eslint-parser")),
|
|
2460
|
+
interopDefault(import("eslint-processor-vue-blocks"))
|
|
2507
2461
|
]);
|
|
2508
2462
|
return [
|
|
2509
2463
|
{
|
|
@@ -2521,39 +2475,30 @@ async function vue(options = {}) {
|
|
|
2521
2475
|
jsx: true
|
|
2522
2476
|
},
|
|
2523
2477
|
extraFileExtensions: [".vue"],
|
|
2524
|
-
parser:
|
|
2525
|
-
sourceType: "module"
|
|
2526
|
-
...tsConfigOptions
|
|
2478
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
2479
|
+
sourceType: "module"
|
|
2527
2480
|
}
|
|
2528
2481
|
},
|
|
2529
2482
|
name: "vinicunca:vue:rules",
|
|
2530
|
-
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
|
+
]),
|
|
2531
2493
|
rules: {
|
|
2532
2494
|
...pluginVue.configs.base.rules,
|
|
2533
2495
|
...pluginVue.configs["vue3-essential"].rules,
|
|
2534
2496
|
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
2535
2497
|
...pluginVue.configs["vue3-recommended"].rules,
|
|
2536
2498
|
"node/prefer-global/process": OFF,
|
|
2537
|
-
"vue/array-bracket-spacing": [ERROR, NEVER],
|
|
2538
|
-
"vue/arrow-spacing": [ERROR, {
|
|
2539
|
-
after: true,
|
|
2540
|
-
before: true
|
|
2541
|
-
}],
|
|
2542
2499
|
"vue/block-order": [ERROR, {
|
|
2543
2500
|
order: ["script", "template", "style"]
|
|
2544
2501
|
}],
|
|
2545
|
-
"vue/block-spacing": [ERROR, ALWAYS],
|
|
2546
|
-
"vue/block-tag-newline": [ERROR, {
|
|
2547
|
-
multiline: ALWAYS,
|
|
2548
|
-
singleline: ALWAYS
|
|
2549
|
-
}],
|
|
2550
|
-
"vue/brace-style": [ERROR, "stroustrup", { allowSingleLine: true }],
|
|
2551
|
-
"vue/comma-dangle": [ERROR, "always-multiline"],
|
|
2552
|
-
"vue/comma-spacing": [ERROR, {
|
|
2553
|
-
after: true,
|
|
2554
|
-
before: false
|
|
2555
|
-
}],
|
|
2556
|
-
"vue/comma-style": [ERROR, "last"],
|
|
2557
2502
|
"vue/component-name-in-template-casing": [ERROR, "PascalCase"],
|
|
2558
2503
|
"vue/component-options-name-casing": [ERROR, "PascalCase"],
|
|
2559
2504
|
"vue/custom-event-name-casing": [ERROR, "camelCase"],
|
|
@@ -2563,18 +2508,7 @@ async function vue(options = {}) {
|
|
|
2563
2508
|
"vue/dot-location": [ERROR, "property"],
|
|
2564
2509
|
"vue/dot-notation": [ERROR, { allowKeywords: true }],
|
|
2565
2510
|
"vue/eqeqeq": [ERROR, "smart"],
|
|
2566
|
-
"vue/html-comment-content-spacing": [ERROR, ALWAYS, {
|
|
2567
|
-
exceptions: ["-"]
|
|
2568
|
-
}],
|
|
2569
2511
|
"vue/html-indent": [ERROR, indent],
|
|
2570
|
-
"vue/key-spacing": [ERROR, {
|
|
2571
|
-
afterColon: true,
|
|
2572
|
-
beforeColon: false
|
|
2573
|
-
}],
|
|
2574
|
-
"vue/keyword-spacing": [ERROR, {
|
|
2575
|
-
after: true,
|
|
2576
|
-
before: true
|
|
2577
|
-
}],
|
|
2578
2512
|
"vue/max-attributes-per-line": [ERROR],
|
|
2579
2513
|
"vue/multi-word-component-names": OFF,
|
|
2580
2514
|
"vue/no-constant-condition": WARN,
|
|
@@ -2597,28 +2531,58 @@ async function vue(options = {}) {
|
|
|
2597
2531
|
"vue/no-useless-v-bind": ERROR,
|
|
2598
2532
|
"vue/no-v-html": OFF,
|
|
2599
2533
|
"vue/no-v-text-v-html-on-component": OFF,
|
|
2600
|
-
"vue/object-curly-newline": [ERROR, { consistent: true, multiline: true }],
|
|
2601
|
-
"vue/object-curly-spacing": [ERROR, ALWAYS],
|
|
2602
|
-
"vue/object-property-newline": [ERROR, { allowMultiplePropertiesPerLine: true }],
|
|
2603
2534
|
"vue/object-shorthand": [ERROR, ALWAYS, {
|
|
2604
2535
|
avoidQuotes: true,
|
|
2605
2536
|
ignoreConstructors: false
|
|
2606
2537
|
}],
|
|
2607
|
-
"vue/operator-linebreak": [ERROR, "before"],
|
|
2608
|
-
"vue/padding-line-between-blocks": [ERROR, ALWAYS],
|
|
2609
2538
|
"vue/prefer-import-from-vue": OFF,
|
|
2610
2539
|
"vue/prefer-separate-static-class": ERROR,
|
|
2611
2540
|
"vue/prefer-template": ERROR,
|
|
2612
|
-
"vue/quote-props": [ERROR, "consistent-as-needed"],
|
|
2613
2541
|
"vue/require-default-prop": OFF,
|
|
2614
2542
|
"vue/require-prop-types": OFF,
|
|
2615
|
-
"vue/space-in-parens": [ERROR, NEVER],
|
|
2616
2543
|
"vue/space-infix-ops": ERROR,
|
|
2617
2544
|
"vue/space-unary-ops": [ERROR, {
|
|
2618
2545
|
nonwords: false,
|
|
2619
2546
|
words: true
|
|
2620
2547
|
}],
|
|
2621
|
-
|
|
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
|
+
} : {},
|
|
2622
2586
|
...overrides
|
|
2623
2587
|
}
|
|
2624
2588
|
}
|
|
@@ -2659,51 +2623,219 @@ async function yaml(options = {}) {
|
|
|
2659
2623
|
rules: {
|
|
2660
2624
|
"style/spaced-comment": OFF,
|
|
2661
2625
|
"yaml/block-mapping": ERROR,
|
|
2662
|
-
"yaml/block-mapping-question-indicator-newline": ERROR,
|
|
2663
2626
|
"yaml/block-sequence": ERROR,
|
|
2664
|
-
"yaml/block-sequence-hyphen-indicator-newline": ERROR,
|
|
2665
|
-
"yaml/flow-mapping-curly-newline": ERROR,
|
|
2666
|
-
"yaml/flow-mapping-curly-spacing": ERROR,
|
|
2667
|
-
"yaml/flow-sequence-bracket-newline": ERROR,
|
|
2668
|
-
"yaml/flow-sequence-bracket-spacing": ERROR,
|
|
2669
|
-
"yaml/indent": [ERROR, indent === "tab" ? 2 : indent],
|
|
2670
|
-
"yaml/key-spacing": ERROR,
|
|
2671
2627
|
"yaml/no-empty-key": ERROR,
|
|
2672
2628
|
"yaml/no-empty-sequence-entry": ERROR,
|
|
2673
2629
|
"yaml/no-irregular-whitespace": ERROR,
|
|
2674
|
-
"yaml/no-tab-indent": ERROR,
|
|
2675
2630
|
"yaml/plain-scalar": ERROR,
|
|
2676
|
-
"yaml/quotes": [ERROR, { avoidEscape: false, prefer: quotes }],
|
|
2677
|
-
"yaml/spaced-comment": ERROR,
|
|
2678
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
|
+
} : {},
|
|
2679
2645
|
...overrides
|
|
2680
2646
|
}
|
|
2681
2647
|
}
|
|
2682
2648
|
];
|
|
2683
2649
|
}
|
|
2684
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
|
+
|
|
2685
2812
|
// src/base.ts
|
|
2813
|
+
var flatConfigProps = [
|
|
2814
|
+
"files",
|
|
2815
|
+
"ignores",
|
|
2816
|
+
"languageOptions",
|
|
2817
|
+
"linterOptions",
|
|
2818
|
+
"processor",
|
|
2819
|
+
"plugins",
|
|
2820
|
+
"rules",
|
|
2821
|
+
"settings"
|
|
2822
|
+
];
|
|
2686
2823
|
var VuePackages = [
|
|
2687
2824
|
"vue",
|
|
2688
2825
|
"nuxt",
|
|
2689
2826
|
"vitepress",
|
|
2690
2827
|
"@slidev/cli"
|
|
2691
2828
|
];
|
|
2692
|
-
async function vinicuncaESLint(
|
|
2829
|
+
async function vinicuncaESLint(options = {}, ...userConfigs) {
|
|
2693
2830
|
const {
|
|
2694
2831
|
componentExts = [],
|
|
2695
|
-
isInEditor = !!((
|
|
2696
|
-
jsonc: enableJsonc = true,
|
|
2697
|
-
markdown: enableMarkdown = true,
|
|
2698
|
-
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),
|
|
2699
2833
|
react: enableReact = false,
|
|
2700
|
-
|
|
2701
|
-
typescript: tsOptions = {},
|
|
2834
|
+
typescript: enableTypeScript = (0, import_local_pkg.isPackageExists)("typescript"),
|
|
2702
2835
|
unocss: enableUnoCSS = false,
|
|
2703
|
-
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i))
|
|
2704
|
-
yaml: enableYaml = true
|
|
2836
|
+
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i))
|
|
2705
2837
|
} = options;
|
|
2706
|
-
let stylisticOptions =
|
|
2838
|
+
let stylisticOptions = {};
|
|
2707
2839
|
if (options.stylistic === false) {
|
|
2708
2840
|
stylisticOptions = false;
|
|
2709
2841
|
} else if (isObject(options.stylistic)) {
|
|
@@ -2717,106 +2849,141 @@ async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
|
2717
2849
|
ignores(options.ignores),
|
|
2718
2850
|
javascript({
|
|
2719
2851
|
isInEditor,
|
|
2720
|
-
overrides:
|
|
2852
|
+
overrides: getOverrides(options, "javascript")
|
|
2721
2853
|
}),
|
|
2722
2854
|
comments(),
|
|
2723
2855
|
node(),
|
|
2724
|
-
jsdoc(
|
|
2856
|
+
jsdoc({
|
|
2857
|
+
stylistic: stylisticOptions
|
|
2858
|
+
}),
|
|
2725
2859
|
imports(),
|
|
2726
2860
|
unicorn()
|
|
2727
2861
|
);
|
|
2728
2862
|
if (enableVue) {
|
|
2729
2863
|
componentExts.push("vue");
|
|
2730
2864
|
}
|
|
2731
|
-
|
|
2732
|
-
enabled: tsEnabled = (0, import_local_pkg.isPackageExists)("typescript"),
|
|
2733
|
-
...tsParams
|
|
2734
|
-
} = tsOptions;
|
|
2735
|
-
if (tsEnabled) {
|
|
2865
|
+
if (enableTypeScript) {
|
|
2736
2866
|
configs.push(typescript({
|
|
2737
|
-
...
|
|
2867
|
+
...resolveSubOptions(options, "typescript"),
|
|
2738
2868
|
componentExts,
|
|
2739
|
-
overrides:
|
|
2869
|
+
overrides: getOverrides(options, "typescript")
|
|
2740
2870
|
}));
|
|
2741
2871
|
}
|
|
2742
2872
|
if (stylisticOptions) {
|
|
2743
|
-
configs.push(stylistic(
|
|
2873
|
+
configs.push(stylistic({
|
|
2874
|
+
...stylisticOptions,
|
|
2875
|
+
overrides: getOverrides(options, "stylistic")
|
|
2876
|
+
}));
|
|
2744
2877
|
}
|
|
2745
|
-
if (
|
|
2878
|
+
if (options.test ?? true) {
|
|
2746
2879
|
configs.push(test({
|
|
2747
2880
|
isInEditor,
|
|
2748
|
-
overrides:
|
|
2881
|
+
overrides: getOverrides(options, "test")
|
|
2749
2882
|
}));
|
|
2750
2883
|
}
|
|
2751
|
-
;
|
|
2752
2884
|
if (enableVue) {
|
|
2753
2885
|
configs.push(vue({
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
}
|
|
2886
|
+
...resolveSubOptions(options, "vue"),
|
|
2887
|
+
overrides: getOverrides(options, "vue"),
|
|
2888
|
+
stylistic: stylisticOptions,
|
|
2889
|
+
typescript: !!enableTypeScript
|
|
2759
2890
|
}));
|
|
2760
2891
|
}
|
|
2761
|
-
;
|
|
2762
2892
|
if (enableReact) {
|
|
2763
2893
|
configs.push(react({
|
|
2764
|
-
overrides:
|
|
2894
|
+
overrides: getOverrides(options, "react"),
|
|
2895
|
+
typescript: !!enableTypeScript
|
|
2765
2896
|
}));
|
|
2766
2897
|
}
|
|
2767
2898
|
if (enableUnoCSS) {
|
|
2768
|
-
configs.push(unocss(
|
|
2769
|
-
|
|
2770
|
-
|
|
2899
|
+
configs.push(unocss({
|
|
2900
|
+
...resolveSubOptions(options, "unocss"),
|
|
2901
|
+
overrides: getOverrides(options, "unocss")
|
|
2902
|
+
}));
|
|
2771
2903
|
}
|
|
2772
|
-
if (
|
|
2904
|
+
if (options.jsonc ?? true) {
|
|
2773
2905
|
configs.push(
|
|
2774
2906
|
jsonc({
|
|
2775
|
-
overrides:
|
|
2907
|
+
overrides: getOverrides(options, "jsonc"),
|
|
2776
2908
|
stylistic: stylisticOptions
|
|
2777
2909
|
}),
|
|
2778
2910
|
sortPackageJson(),
|
|
2779
2911
|
sortTsconfig()
|
|
2780
2912
|
);
|
|
2781
2913
|
}
|
|
2782
|
-
if (
|
|
2914
|
+
if (options.yaml ?? true) {
|
|
2783
2915
|
configs.push(yaml({
|
|
2784
|
-
overrides:
|
|
2916
|
+
overrides: getOverrides(options, "yaml"),
|
|
2785
2917
|
stylistic: stylisticOptions
|
|
2786
2918
|
}));
|
|
2787
2919
|
}
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2920
|
+
if (options.markdown ?? true) {
|
|
2921
|
+
configs.push(
|
|
2922
|
+
markdown(
|
|
2923
|
+
{
|
|
2924
|
+
componentExts,
|
|
2925
|
+
overrides: getOverrides(options, "markdown")
|
|
2926
|
+
}
|
|
2927
|
+
)
|
|
2928
|
+
);
|
|
2929
|
+
}
|
|
2930
|
+
if (options.formatters) {
|
|
2931
|
+
configs.push(formatters(
|
|
2932
|
+
options.formatters,
|
|
2933
|
+
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2934
|
+
));
|
|
2935
|
+
}
|
|
2936
|
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2937
|
+
if (key in options) {
|
|
2938
|
+
acc[key] = options[key];
|
|
2939
|
+
}
|
|
2940
|
+
;
|
|
2941
|
+
return acc;
|
|
2942
|
+
}, {});
|
|
2943
|
+
if (Object.keys(fusedConfig).length) {
|
|
2944
|
+
configs.push([fusedConfig]);
|
|
2794
2945
|
}
|
|
2795
2946
|
;
|
|
2796
|
-
configs.push(ignores(options.ignores));
|
|
2797
2947
|
return combineConfigs(
|
|
2798
2948
|
...configs,
|
|
2799
2949
|
...userConfigs
|
|
2800
2950
|
);
|
|
2801
2951
|
}
|
|
2952
|
+
function getOverrides(options, key) {
|
|
2953
|
+
const sub = resolveSubOptions(options, key);
|
|
2954
|
+
return {
|
|
2955
|
+
..."overrides" in sub ? sub.overrides : {}
|
|
2956
|
+
};
|
|
2957
|
+
}
|
|
2958
|
+
function resolveSubOptions(options, key) {
|
|
2959
|
+
return isBoolean(options[key]) ? {} : options[key] || {};
|
|
2960
|
+
}
|
|
2802
2961
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2803
2962
|
0 && (module.exports = {
|
|
2963
|
+
GLOB_ALL_SRC,
|
|
2964
|
+
GLOB_CSS,
|
|
2804
2965
|
GLOB_EXCLUDE,
|
|
2966
|
+
GLOB_HTML,
|
|
2805
2967
|
GLOB_JS,
|
|
2806
2968
|
GLOB_JSON,
|
|
2807
2969
|
GLOB_JSON5,
|
|
2808
2970
|
GLOB_JSONC,
|
|
2809
2971
|
GLOB_JSX,
|
|
2972
|
+
GLOB_LESS,
|
|
2810
2973
|
GLOB_MARKDOWN,
|
|
2811
2974
|
GLOB_MARKDOWN_CODE,
|
|
2812
2975
|
GLOB_MARKDOWN_IN_MARKDOWN,
|
|
2976
|
+
GLOB_POSTCSS,
|
|
2977
|
+
GLOB_SCSS,
|
|
2813
2978
|
GLOB_SRC,
|
|
2814
2979
|
GLOB_SRC_EXT,
|
|
2980
|
+
GLOB_STYLE,
|
|
2815
2981
|
GLOB_TESTS,
|
|
2816
2982
|
GLOB_TS,
|
|
2817
2983
|
GLOB_TSX,
|
|
2818
2984
|
GLOB_VUE,
|
|
2819
2985
|
GLOB_YAML,
|
|
2986
|
+
STYLISTIC_CONFIG_DEFAULTS,
|
|
2820
2987
|
combineConfigs,
|
|
2821
2988
|
comments,
|
|
2822
2989
|
ignores,
|
|
@@ -2827,6 +2994,7 @@ async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
|
2827
2994
|
jsonc,
|
|
2828
2995
|
markdown,
|
|
2829
2996
|
node,
|
|
2997
|
+
parserPlain,
|
|
2830
2998
|
pluginComments,
|
|
2831
2999
|
pluginImport,
|
|
2832
3000
|
pluginNode,
|
|
@@ -2840,6 +3008,7 @@ async function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
|
2840
3008
|
sortTsconfig,
|
|
2841
3009
|
stylistic,
|
|
2842
3010
|
test,
|
|
3011
|
+
toArray,
|
|
2843
3012
|
typescript,
|
|
2844
3013
|
unicorn,
|
|
2845
3014
|
unocss,
|