@vinicunca/eslint-config 2.0.0 → 2.0.3
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 +121 -75
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +121 -75
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -91,9 +91,62 @@ __export(src_exports, {
|
|
|
91
91
|
module.exports = __toCommonJS(src_exports);
|
|
92
92
|
|
|
93
93
|
// src/base.ts
|
|
94
|
-
var
|
|
94
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
95
95
|
var import_local_pkg = require("local-pkg");
|
|
96
96
|
|
|
97
|
+
// src/flags.ts
|
|
98
|
+
var ERROR = "error";
|
|
99
|
+
var OFF = "off";
|
|
100
|
+
var WARN = "warn";
|
|
101
|
+
var CONSISTENT = "consistent";
|
|
102
|
+
var NEVER = "never";
|
|
103
|
+
var ALWAYS = "always";
|
|
104
|
+
|
|
105
|
+
// src/plugins.ts
|
|
106
|
+
var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
|
|
107
|
+
var import_eslint_plugin_vinicunca = __toESM(require("@vinicunca/eslint-plugin-vinicunca"), 1);
|
|
108
|
+
var import_eslint_plugin2 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
|
|
109
|
+
var parserTs = __toESM(require("@typescript-eslint/parser"), 1);
|
|
110
|
+
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
111
|
+
var pluginImport = __toESM(require("eslint-plugin-i"), 1);
|
|
112
|
+
var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
|
|
113
|
+
var pluginJsonc = __toESM(require("eslint-plugin-jsonc"), 1);
|
|
114
|
+
var import_eslint_plugin_markdown = __toESM(require("eslint-plugin-markdown"), 1);
|
|
115
|
+
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
116
|
+
var import_eslint_plugin_no_only_tests = __toESM(require("eslint-plugin-no-only-tests"), 1);
|
|
117
|
+
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
118
|
+
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
119
|
+
var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1);
|
|
120
|
+
var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1);
|
|
121
|
+
var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
|
|
122
|
+
var pluginYaml = __toESM(require("eslint-plugin-yml"), 1);
|
|
123
|
+
var import_eslint_plugin_vitest = __toESM(require("eslint-plugin-vitest"), 1);
|
|
124
|
+
var import_jsonc_eslint_parser = __toESM(require("jsonc-eslint-parser"), 1);
|
|
125
|
+
var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
|
|
126
|
+
var import_yaml_eslint_parser = __toESM(require("yaml-eslint-parser"), 1);
|
|
127
|
+
|
|
128
|
+
// src/configs/comments.ts
|
|
129
|
+
function comments() {
|
|
130
|
+
return [
|
|
131
|
+
{
|
|
132
|
+
name: "vinicunca:eslint-comments",
|
|
133
|
+
plugins: {
|
|
134
|
+
"eslint-comments": import_eslint_plugin_eslint_comments.default
|
|
135
|
+
},
|
|
136
|
+
rules: {
|
|
137
|
+
"eslint-comments/no-aggregating-enable": ERROR,
|
|
138
|
+
"eslint-comments/no-duplicate-disable": ERROR,
|
|
139
|
+
"eslint-comments/no-unlimited-disable": ERROR,
|
|
140
|
+
"eslint-comments/no-unused-enable": ERROR
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/configs/ignores.ts
|
|
147
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
148
|
+
var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
149
|
+
|
|
97
150
|
// ../node_modules/.pnpm/@vinicunca+perkakas@0.0.10/node_modules/@vinicunca/perkakas/dist/index.js
|
|
98
151
|
function purry(fn, args, lazy) {
|
|
99
152
|
const diff = fn.length - args.length;
|
|
@@ -111,8 +164,8 @@ function purry(fn, args, lazy) {
|
|
|
111
164
|
}
|
|
112
165
|
throw new Error("Wrong number of arguments");
|
|
113
166
|
}
|
|
114
|
-
function
|
|
115
|
-
return
|
|
167
|
+
function isArray(data) {
|
|
168
|
+
return Array.isArray(data);
|
|
116
169
|
}
|
|
117
170
|
function isDefined(data) {
|
|
118
171
|
return typeof data !== "undefined" && data !== null;
|
|
@@ -123,6 +176,27 @@ function isDefined(data) {
|
|
|
123
176
|
}
|
|
124
177
|
isDefined2.strict = strict;
|
|
125
178
|
})(isDefined || (isDefined = {}));
|
|
179
|
+
function toString(value) {
|
|
180
|
+
return Object.prototype.toString.call(value);
|
|
181
|
+
}
|
|
182
|
+
function isObject(data) {
|
|
183
|
+
return toString(data) === "[object Object]";
|
|
184
|
+
}
|
|
185
|
+
function isString(data) {
|
|
186
|
+
return typeof data === "string";
|
|
187
|
+
}
|
|
188
|
+
function isEmpty(data) {
|
|
189
|
+
if (isArray(data) || isString(data)) {
|
|
190
|
+
return data.length === 0;
|
|
191
|
+
}
|
|
192
|
+
if (isObject(data)) {
|
|
193
|
+
for (const _ in data) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
return !(data instanceof RegExp);
|
|
197
|
+
}
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
126
200
|
function _countBy(indexed) {
|
|
127
201
|
return (array, fn) => {
|
|
128
202
|
return array.reduce((ret, item, index) => {
|
|
@@ -1047,59 +1121,6 @@ function toPairs(object) {
|
|
|
1047
1121
|
toPairs2.strict = strict;
|
|
1048
1122
|
})(toPairs || (toPairs = {}));
|
|
1049
1123
|
|
|
1050
|
-
// src/flags.ts
|
|
1051
|
-
var ERROR = "error";
|
|
1052
|
-
var OFF = "off";
|
|
1053
|
-
var WARN = "warn";
|
|
1054
|
-
var CONSISTENT = "consistent";
|
|
1055
|
-
var NEVER = "never";
|
|
1056
|
-
var ALWAYS = "always";
|
|
1057
|
-
|
|
1058
|
-
// src/plugins.ts
|
|
1059
|
-
var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
|
|
1060
|
-
var import_eslint_plugin_vinicunca = __toESM(require("@vinicunca/eslint-plugin-vinicunca"), 1);
|
|
1061
|
-
var import_eslint_plugin2 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
|
|
1062
|
-
var parserTs = __toESM(require("@typescript-eslint/parser"), 1);
|
|
1063
|
-
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
1064
|
-
var pluginImport = __toESM(require("eslint-plugin-i"), 1);
|
|
1065
|
-
var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
|
|
1066
|
-
var pluginJsonc = __toESM(require("eslint-plugin-jsonc"), 1);
|
|
1067
|
-
var import_eslint_plugin_markdown = __toESM(require("eslint-plugin-markdown"), 1);
|
|
1068
|
-
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
1069
|
-
var import_eslint_plugin_no_only_tests = __toESM(require("eslint-plugin-no-only-tests"), 1);
|
|
1070
|
-
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
1071
|
-
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
1072
|
-
var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1);
|
|
1073
|
-
var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1);
|
|
1074
|
-
var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
|
|
1075
|
-
var pluginYaml = __toESM(require("eslint-plugin-yml"), 1);
|
|
1076
|
-
var import_eslint_plugin_vitest = __toESM(require("eslint-plugin-vitest"), 1);
|
|
1077
|
-
var import_jsonc_eslint_parser = __toESM(require("jsonc-eslint-parser"), 1);
|
|
1078
|
-
var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
|
|
1079
|
-
var import_yaml_eslint_parser = __toESM(require("yaml-eslint-parser"), 1);
|
|
1080
|
-
|
|
1081
|
-
// src/configs/comments.ts
|
|
1082
|
-
function comments() {
|
|
1083
|
-
return [
|
|
1084
|
-
{
|
|
1085
|
-
name: "vinicunca:eslint-comments",
|
|
1086
|
-
plugins: {
|
|
1087
|
-
"eslint-comments": import_eslint_plugin_eslint_comments.default
|
|
1088
|
-
},
|
|
1089
|
-
rules: {
|
|
1090
|
-
"eslint-comments/no-aggregating-enable": ERROR,
|
|
1091
|
-
"eslint-comments/no-duplicate-disable": ERROR,
|
|
1092
|
-
"eslint-comments/no-unlimited-disable": ERROR,
|
|
1093
|
-
"eslint-comments/no-unused-enable": ERROR
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
];
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
// src/configs/ignores.ts
|
|
1100
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
1101
|
-
var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
1102
|
-
|
|
1103
1124
|
// src/globs.ts
|
|
1104
1125
|
var GLOB_JS = "**/*.?([cm])js";
|
|
1105
1126
|
var GLOB_JSX = "**/*.?([cm])jsx";
|
|
@@ -1772,6 +1793,7 @@ function react(options = {}) {
|
|
|
1772
1793
|
singleline: "consistent"
|
|
1773
1794
|
}],
|
|
1774
1795
|
"react/jsx-newline": ERROR,
|
|
1796
|
+
"react/react-in-jsx-scope": OFF,
|
|
1775
1797
|
...overrides
|
|
1776
1798
|
}
|
|
1777
1799
|
}
|
|
@@ -2120,6 +2142,12 @@ function stylistic() {
|
|
|
2120
2142
|
"vinicunca/if-newline": ERROR,
|
|
2121
2143
|
"vinicunca/top-level-function": ERROR
|
|
2122
2144
|
}
|
|
2145
|
+
},
|
|
2146
|
+
{
|
|
2147
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
2148
|
+
rules: {
|
|
2149
|
+
"vinicunca/consistent-list-newline": OFF
|
|
2150
|
+
}
|
|
2123
2151
|
}
|
|
2124
2152
|
];
|
|
2125
2153
|
}
|
|
@@ -2184,7 +2212,7 @@ function typescript(options) {
|
|
|
2184
2212
|
componentExts = [],
|
|
2185
2213
|
overrides = {},
|
|
2186
2214
|
parserOptions = {},
|
|
2187
|
-
tsconfigPath
|
|
2215
|
+
tsconfigPath = []
|
|
2188
2216
|
} = options ?? {};
|
|
2189
2217
|
const typeAwareRules = {
|
|
2190
2218
|
"dot-notation": OFF,
|
|
@@ -2197,16 +2225,19 @@ function typescript(options) {
|
|
|
2197
2225
|
"ts/no-implied-eval": ERROR,
|
|
2198
2226
|
"ts/no-misused-promises": ERROR,
|
|
2199
2227
|
"ts/no-throw-literal": ERROR,
|
|
2200
|
-
"ts/no-unnecessary-type-assertion": ERROR,
|
|
2201
|
-
"ts/no-unsafe-argument": ERROR,
|
|
2202
|
-
"ts/no-unsafe-assignment": ERROR,
|
|
2203
|
-
"ts/no-unsafe-call": ERROR,
|
|
2204
|
-
"ts/no-unsafe-member-access": ERROR,
|
|
2205
|
-
"ts/no-unsafe-return": ERROR,
|
|
2206
2228
|
"ts/restrict-plus-operands": ERROR,
|
|
2207
2229
|
"ts/restrict-template-expressions": ERROR,
|
|
2208
2230
|
"ts/unbound-method": ERROR
|
|
2209
2231
|
};
|
|
2232
|
+
let tsConfigOptions = {};
|
|
2233
|
+
let additionalTypeAwareRules = {};
|
|
2234
|
+
if (!isEmpty(tsconfigPath)) {
|
|
2235
|
+
tsConfigOptions = {
|
|
2236
|
+
project: tsconfigPath,
|
|
2237
|
+
tsconfigRootDir: import_node_process.default.cwd()
|
|
2238
|
+
};
|
|
2239
|
+
additionalTypeAwareRules = typeAwareRules;
|
|
2240
|
+
}
|
|
2210
2241
|
return [
|
|
2211
2242
|
{
|
|
2212
2243
|
// Install the plugins without globs, so they can be configured separately.
|
|
@@ -2227,10 +2258,7 @@ function typescript(options) {
|
|
|
2227
2258
|
parser: parserTs,
|
|
2228
2259
|
parserOptions: {
|
|
2229
2260
|
sourceType: "module",
|
|
2230
|
-
...
|
|
2231
|
-
project: [tsconfigPath],
|
|
2232
|
-
tsconfigRootDir: import_node_process.default.cwd()
|
|
2233
|
-
} : {},
|
|
2261
|
+
...tsConfigOptions,
|
|
2234
2262
|
...parserOptions
|
|
2235
2263
|
}
|
|
2236
2264
|
},
|
|
@@ -2284,7 +2312,7 @@ function typescript(options) {
|
|
|
2284
2312
|
"vinicunca/named-tuple-spacing": ERROR,
|
|
2285
2313
|
"vinicunca/no-cjs-exports": ERROR,
|
|
2286
2314
|
"vinicunca/no-ts-export-equal": ERROR,
|
|
2287
|
-
...
|
|
2315
|
+
...additionalTypeAwareRules,
|
|
2288
2316
|
...overrides
|
|
2289
2317
|
}
|
|
2290
2318
|
},
|
|
@@ -2347,10 +2375,20 @@ function unicorn(options = {}) {
|
|
|
2347
2375
|
}
|
|
2348
2376
|
|
|
2349
2377
|
// src/configs/vue.ts
|
|
2378
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
2350
2379
|
function vue(options = {}) {
|
|
2351
2380
|
const {
|
|
2381
|
+
typescript: typescript2 = {},
|
|
2352
2382
|
overrides = {}
|
|
2353
2383
|
} = options;
|
|
2384
|
+
let tsConfigOptions = {};
|
|
2385
|
+
const tsconfigPath = typescript2.tsconfigPath ?? [];
|
|
2386
|
+
if (!isEmpty(tsconfigPath)) {
|
|
2387
|
+
tsConfigOptions = {
|
|
2388
|
+
project: tsconfigPath,
|
|
2389
|
+
tsconfigRootDir: import_node_process2.default.cwd()
|
|
2390
|
+
};
|
|
2391
|
+
}
|
|
2354
2392
|
return [
|
|
2355
2393
|
{
|
|
2356
2394
|
name: "vinicunca:vue:setup",
|
|
@@ -2368,8 +2406,9 @@ function vue(options = {}) {
|
|
|
2368
2406
|
jsx: true
|
|
2369
2407
|
},
|
|
2370
2408
|
extraFileExtensions: [".vue"],
|
|
2371
|
-
parser:
|
|
2372
|
-
sourceType: "module"
|
|
2409
|
+
parser: typescript2.enabled ? parserTs : void 0,
|
|
2410
|
+
sourceType: "module",
|
|
2411
|
+
...tsConfigOptions
|
|
2373
2412
|
}
|
|
2374
2413
|
},
|
|
2375
2414
|
processor: import_eslint_plugin_vue.default.processors[".vue"],
|
|
@@ -2522,9 +2561,9 @@ var VuePackages = [
|
|
|
2522
2561
|
];
|
|
2523
2562
|
function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
2524
2563
|
const {
|
|
2525
|
-
isInEditor = !!((
|
|
2564
|
+
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
|
|
2526
2565
|
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i)),
|
|
2527
|
-
typescript:
|
|
2566
|
+
typescript: tsOptions = {},
|
|
2528
2567
|
stylistic: enableStylistic = true,
|
|
2529
2568
|
test: enableTest = true,
|
|
2530
2569
|
jsonc: enableJsonc = true,
|
|
@@ -2549,9 +2588,13 @@ function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
|
2549
2588
|
if (enableVue) {
|
|
2550
2589
|
componentExts.push("vue");
|
|
2551
2590
|
}
|
|
2552
|
-
|
|
2591
|
+
const {
|
|
2592
|
+
enabled: tsEnabled = (0, import_local_pkg.isPackageExists)("typescript"),
|
|
2593
|
+
...tsParams
|
|
2594
|
+
} = tsOptions;
|
|
2595
|
+
if (tsEnabled) {
|
|
2553
2596
|
configs.push(typescript({
|
|
2554
|
-
|
|
2597
|
+
...tsParams,
|
|
2555
2598
|
componentExts,
|
|
2556
2599
|
overrides: overrides.typescript
|
|
2557
2600
|
}));
|
|
@@ -2568,7 +2611,10 @@ function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
|
2568
2611
|
;
|
|
2569
2612
|
if (enableVue) {
|
|
2570
2613
|
configs.push(vue({
|
|
2571
|
-
typescript:
|
|
2614
|
+
typescript: {
|
|
2615
|
+
enabled: tsEnabled,
|
|
2616
|
+
...tsParams
|
|
2617
|
+
},
|
|
2572
2618
|
overrides: overrides.vue
|
|
2573
2619
|
}));
|
|
2574
2620
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -57,7 +57,9 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
57
57
|
*
|
|
58
58
|
* @default auto-detect based on the dependencies
|
|
59
59
|
*/
|
|
60
|
-
typescript?:
|
|
60
|
+
typescript?: OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & {
|
|
61
|
+
enabled?: boolean;
|
|
62
|
+
};
|
|
61
63
|
/**
|
|
62
64
|
* Enable JSX related rules.
|
|
63
65
|
*
|
|
@@ -159,10 +161,10 @@ interface OptionsTypeScriptWithTypes {
|
|
|
159
161
|
* When this options is provided, type aware rules will be enabled.
|
|
160
162
|
* @see https://typescript-eslint.io/linting/typed-linting/
|
|
161
163
|
*/
|
|
162
|
-
tsconfigPath?: string;
|
|
164
|
+
tsconfigPath?: string[];
|
|
163
165
|
}
|
|
164
166
|
interface OptionsHasTypeScript {
|
|
165
|
-
typescript?:
|
|
167
|
+
typescript?: OptionsConfig['typescript'];
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
declare function vinicuncaESLint({ options, userConfigs }?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -57,7 +57,9 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
57
57
|
*
|
|
58
58
|
* @default auto-detect based on the dependencies
|
|
59
59
|
*/
|
|
60
|
-
typescript?:
|
|
60
|
+
typescript?: OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & {
|
|
61
|
+
enabled?: boolean;
|
|
62
|
+
};
|
|
61
63
|
/**
|
|
62
64
|
* Enable JSX related rules.
|
|
63
65
|
*
|
|
@@ -159,10 +161,10 @@ interface OptionsTypeScriptWithTypes {
|
|
|
159
161
|
* When this options is provided, type aware rules will be enabled.
|
|
160
162
|
* @see https://typescript-eslint.io/linting/typed-linting/
|
|
161
163
|
*/
|
|
162
|
-
tsconfigPath?: string;
|
|
164
|
+
tsconfigPath?: string[];
|
|
163
165
|
}
|
|
164
166
|
interface OptionsHasTypeScript {
|
|
165
|
-
typescript?:
|
|
167
|
+
typescript?: OptionsConfig['typescript'];
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
declare function vinicuncaESLint({ options, userConfigs }?: {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,60 @@
|
|
|
1
1
|
// src/base.ts
|
|
2
|
-
import
|
|
2
|
+
import process3 from "process";
|
|
3
3
|
import { isPackageExists } from "local-pkg";
|
|
4
4
|
|
|
5
|
+
// src/flags.ts
|
|
6
|
+
var ERROR = "error";
|
|
7
|
+
var OFF = "off";
|
|
8
|
+
var WARN = "warn";
|
|
9
|
+
var CONSISTENT = "consistent";
|
|
10
|
+
var NEVER = "never";
|
|
11
|
+
var ALWAYS = "always";
|
|
12
|
+
|
|
13
|
+
// src/plugins.ts
|
|
14
|
+
import { default as default2 } from "@stylistic/eslint-plugin";
|
|
15
|
+
import { default as default3 } from "@vinicunca/eslint-plugin-vinicunca";
|
|
16
|
+
import { default as default4 } from "@typescript-eslint/eslint-plugin";
|
|
17
|
+
import * as parserTs from "@typescript-eslint/parser";
|
|
18
|
+
import { default as default5 } from "eslint-plugin-eslint-comments";
|
|
19
|
+
import * as pluginImport from "eslint-plugin-i";
|
|
20
|
+
import { default as default6 } from "eslint-plugin-jsdoc";
|
|
21
|
+
import * as pluginJsonc from "eslint-plugin-jsonc";
|
|
22
|
+
import { default as default7 } from "eslint-plugin-markdown";
|
|
23
|
+
import { default as default8 } from "eslint-plugin-n";
|
|
24
|
+
import { default as default9 } from "eslint-plugin-no-only-tests";
|
|
25
|
+
import { default as default10 } from "eslint-plugin-unicorn";
|
|
26
|
+
import { default as default11 } from "eslint-plugin-unused-imports";
|
|
27
|
+
import { default as default12 } from "eslint-plugin-react";
|
|
28
|
+
import { default as default13 } from "eslint-plugin-react-hooks";
|
|
29
|
+
import { default as default14 } from "eslint-plugin-vue";
|
|
30
|
+
import * as pluginYaml from "eslint-plugin-yml";
|
|
31
|
+
import { default as default15 } from "eslint-plugin-vitest";
|
|
32
|
+
import { default as default16 } from "jsonc-eslint-parser";
|
|
33
|
+
import { default as default17 } from "vue-eslint-parser";
|
|
34
|
+
import { default as default18 } from "yaml-eslint-parser";
|
|
35
|
+
|
|
36
|
+
// src/configs/comments.ts
|
|
37
|
+
function comments() {
|
|
38
|
+
return [
|
|
39
|
+
{
|
|
40
|
+
name: "vinicunca:eslint-comments",
|
|
41
|
+
plugins: {
|
|
42
|
+
"eslint-comments": default5
|
|
43
|
+
},
|
|
44
|
+
rules: {
|
|
45
|
+
"eslint-comments/no-aggregating-enable": ERROR,
|
|
46
|
+
"eslint-comments/no-duplicate-disable": ERROR,
|
|
47
|
+
"eslint-comments/no-unlimited-disable": ERROR,
|
|
48
|
+
"eslint-comments/no-unused-enable": ERROR
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/configs/ignores.ts
|
|
55
|
+
import fs from "fs";
|
|
56
|
+
import parseGitignore from "parse-gitignore";
|
|
57
|
+
|
|
5
58
|
// ../node_modules/.pnpm/@vinicunca+perkakas@0.0.10/node_modules/@vinicunca/perkakas/dist/index.js
|
|
6
59
|
function purry(fn, args, lazy) {
|
|
7
60
|
const diff = fn.length - args.length;
|
|
@@ -19,8 +72,8 @@ function purry(fn, args, lazy) {
|
|
|
19
72
|
}
|
|
20
73
|
throw new Error("Wrong number of arguments");
|
|
21
74
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
75
|
+
function isArray(data) {
|
|
76
|
+
return Array.isArray(data);
|
|
24
77
|
}
|
|
25
78
|
function isDefined(data) {
|
|
26
79
|
return typeof data !== "undefined" && data !== null;
|
|
@@ -31,6 +84,27 @@ function isDefined(data) {
|
|
|
31
84
|
}
|
|
32
85
|
isDefined2.strict = strict;
|
|
33
86
|
})(isDefined || (isDefined = {}));
|
|
87
|
+
function toString(value) {
|
|
88
|
+
return Object.prototype.toString.call(value);
|
|
89
|
+
}
|
|
90
|
+
function isObject(data) {
|
|
91
|
+
return toString(data) === "[object Object]";
|
|
92
|
+
}
|
|
93
|
+
function isString(data) {
|
|
94
|
+
return typeof data === "string";
|
|
95
|
+
}
|
|
96
|
+
function isEmpty(data) {
|
|
97
|
+
if (isArray(data) || isString(data)) {
|
|
98
|
+
return data.length === 0;
|
|
99
|
+
}
|
|
100
|
+
if (isObject(data)) {
|
|
101
|
+
for (const _ in data) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
return !(data instanceof RegExp);
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
34
108
|
function _countBy(indexed) {
|
|
35
109
|
return (array, fn) => {
|
|
36
110
|
return array.reduce((ret, item, index) => {
|
|
@@ -955,59 +1029,6 @@ function toPairs(object) {
|
|
|
955
1029
|
toPairs2.strict = strict;
|
|
956
1030
|
})(toPairs || (toPairs = {}));
|
|
957
1031
|
|
|
958
|
-
// src/flags.ts
|
|
959
|
-
var ERROR = "error";
|
|
960
|
-
var OFF = "off";
|
|
961
|
-
var WARN = "warn";
|
|
962
|
-
var CONSISTENT = "consistent";
|
|
963
|
-
var NEVER = "never";
|
|
964
|
-
var ALWAYS = "always";
|
|
965
|
-
|
|
966
|
-
// src/plugins.ts
|
|
967
|
-
import { default as default2 } from "@stylistic/eslint-plugin";
|
|
968
|
-
import { default as default3 } from "@vinicunca/eslint-plugin-vinicunca";
|
|
969
|
-
import { default as default4 } from "@typescript-eslint/eslint-plugin";
|
|
970
|
-
import * as parserTs from "@typescript-eslint/parser";
|
|
971
|
-
import { default as default5 } from "eslint-plugin-eslint-comments";
|
|
972
|
-
import * as pluginImport from "eslint-plugin-i";
|
|
973
|
-
import { default as default6 } from "eslint-plugin-jsdoc";
|
|
974
|
-
import * as pluginJsonc from "eslint-plugin-jsonc";
|
|
975
|
-
import { default as default7 } from "eslint-plugin-markdown";
|
|
976
|
-
import { default as default8 } from "eslint-plugin-n";
|
|
977
|
-
import { default as default9 } from "eslint-plugin-no-only-tests";
|
|
978
|
-
import { default as default10 } from "eslint-plugin-unicorn";
|
|
979
|
-
import { default as default11 } from "eslint-plugin-unused-imports";
|
|
980
|
-
import { default as default12 } from "eslint-plugin-react";
|
|
981
|
-
import { default as default13 } from "eslint-plugin-react-hooks";
|
|
982
|
-
import { default as default14 } from "eslint-plugin-vue";
|
|
983
|
-
import * as pluginYaml from "eslint-plugin-yml";
|
|
984
|
-
import { default as default15 } from "eslint-plugin-vitest";
|
|
985
|
-
import { default as default16 } from "jsonc-eslint-parser";
|
|
986
|
-
import { default as default17 } from "vue-eslint-parser";
|
|
987
|
-
import { default as default18 } from "yaml-eslint-parser";
|
|
988
|
-
|
|
989
|
-
// src/configs/comments.ts
|
|
990
|
-
function comments() {
|
|
991
|
-
return [
|
|
992
|
-
{
|
|
993
|
-
name: "vinicunca:eslint-comments",
|
|
994
|
-
plugins: {
|
|
995
|
-
"eslint-comments": default5
|
|
996
|
-
},
|
|
997
|
-
rules: {
|
|
998
|
-
"eslint-comments/no-aggregating-enable": ERROR,
|
|
999
|
-
"eslint-comments/no-duplicate-disable": ERROR,
|
|
1000
|
-
"eslint-comments/no-unlimited-disable": ERROR,
|
|
1001
|
-
"eslint-comments/no-unused-enable": ERROR
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
];
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
// src/configs/ignores.ts
|
|
1008
|
-
import fs from "fs";
|
|
1009
|
-
import parseGitignore from "parse-gitignore";
|
|
1010
|
-
|
|
1011
1032
|
// src/globs.ts
|
|
1012
1033
|
var GLOB_JS = "**/*.?([cm])js";
|
|
1013
1034
|
var GLOB_JSX = "**/*.?([cm])jsx";
|
|
@@ -1680,6 +1701,7 @@ function react(options = {}) {
|
|
|
1680
1701
|
singleline: "consistent"
|
|
1681
1702
|
}],
|
|
1682
1703
|
"react/jsx-newline": ERROR,
|
|
1704
|
+
"react/react-in-jsx-scope": OFF,
|
|
1683
1705
|
...overrides
|
|
1684
1706
|
}
|
|
1685
1707
|
}
|
|
@@ -2028,6 +2050,12 @@ function stylistic() {
|
|
|
2028
2050
|
"vinicunca/if-newline": ERROR,
|
|
2029
2051
|
"vinicunca/top-level-function": ERROR
|
|
2030
2052
|
}
|
|
2053
|
+
},
|
|
2054
|
+
{
|
|
2055
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
2056
|
+
rules: {
|
|
2057
|
+
"vinicunca/consistent-list-newline": OFF
|
|
2058
|
+
}
|
|
2031
2059
|
}
|
|
2032
2060
|
];
|
|
2033
2061
|
}
|
|
@@ -2092,7 +2120,7 @@ function typescript(options) {
|
|
|
2092
2120
|
componentExts = [],
|
|
2093
2121
|
overrides = {},
|
|
2094
2122
|
parserOptions = {},
|
|
2095
|
-
tsconfigPath
|
|
2123
|
+
tsconfigPath = []
|
|
2096
2124
|
} = options ?? {};
|
|
2097
2125
|
const typeAwareRules = {
|
|
2098
2126
|
"dot-notation": OFF,
|
|
@@ -2105,16 +2133,19 @@ function typescript(options) {
|
|
|
2105
2133
|
"ts/no-implied-eval": ERROR,
|
|
2106
2134
|
"ts/no-misused-promises": ERROR,
|
|
2107
2135
|
"ts/no-throw-literal": ERROR,
|
|
2108
|
-
"ts/no-unnecessary-type-assertion": ERROR,
|
|
2109
|
-
"ts/no-unsafe-argument": ERROR,
|
|
2110
|
-
"ts/no-unsafe-assignment": ERROR,
|
|
2111
|
-
"ts/no-unsafe-call": ERROR,
|
|
2112
|
-
"ts/no-unsafe-member-access": ERROR,
|
|
2113
|
-
"ts/no-unsafe-return": ERROR,
|
|
2114
2136
|
"ts/restrict-plus-operands": ERROR,
|
|
2115
2137
|
"ts/restrict-template-expressions": ERROR,
|
|
2116
2138
|
"ts/unbound-method": ERROR
|
|
2117
2139
|
};
|
|
2140
|
+
let tsConfigOptions = {};
|
|
2141
|
+
let additionalTypeAwareRules = {};
|
|
2142
|
+
if (!isEmpty(tsconfigPath)) {
|
|
2143
|
+
tsConfigOptions = {
|
|
2144
|
+
project: tsconfigPath,
|
|
2145
|
+
tsconfigRootDir: process.cwd()
|
|
2146
|
+
};
|
|
2147
|
+
additionalTypeAwareRules = typeAwareRules;
|
|
2148
|
+
}
|
|
2118
2149
|
return [
|
|
2119
2150
|
{
|
|
2120
2151
|
// Install the plugins without globs, so they can be configured separately.
|
|
@@ -2135,10 +2166,7 @@ function typescript(options) {
|
|
|
2135
2166
|
parser: parserTs,
|
|
2136
2167
|
parserOptions: {
|
|
2137
2168
|
sourceType: "module",
|
|
2138
|
-
...
|
|
2139
|
-
project: [tsconfigPath],
|
|
2140
|
-
tsconfigRootDir: process.cwd()
|
|
2141
|
-
} : {},
|
|
2169
|
+
...tsConfigOptions,
|
|
2142
2170
|
...parserOptions
|
|
2143
2171
|
}
|
|
2144
2172
|
},
|
|
@@ -2192,7 +2220,7 @@ function typescript(options) {
|
|
|
2192
2220
|
"vinicunca/named-tuple-spacing": ERROR,
|
|
2193
2221
|
"vinicunca/no-cjs-exports": ERROR,
|
|
2194
2222
|
"vinicunca/no-ts-export-equal": ERROR,
|
|
2195
|
-
...
|
|
2223
|
+
...additionalTypeAwareRules,
|
|
2196
2224
|
...overrides
|
|
2197
2225
|
}
|
|
2198
2226
|
},
|
|
@@ -2255,10 +2283,20 @@ function unicorn(options = {}) {
|
|
|
2255
2283
|
}
|
|
2256
2284
|
|
|
2257
2285
|
// src/configs/vue.ts
|
|
2286
|
+
import process2 from "process";
|
|
2258
2287
|
function vue(options = {}) {
|
|
2259
2288
|
const {
|
|
2289
|
+
typescript: typescript2 = {},
|
|
2260
2290
|
overrides = {}
|
|
2261
2291
|
} = options;
|
|
2292
|
+
let tsConfigOptions = {};
|
|
2293
|
+
const tsconfigPath = typescript2.tsconfigPath ?? [];
|
|
2294
|
+
if (!isEmpty(tsconfigPath)) {
|
|
2295
|
+
tsConfigOptions = {
|
|
2296
|
+
project: tsconfigPath,
|
|
2297
|
+
tsconfigRootDir: process2.cwd()
|
|
2298
|
+
};
|
|
2299
|
+
}
|
|
2262
2300
|
return [
|
|
2263
2301
|
{
|
|
2264
2302
|
name: "vinicunca:vue:setup",
|
|
@@ -2276,8 +2314,9 @@ function vue(options = {}) {
|
|
|
2276
2314
|
jsx: true
|
|
2277
2315
|
},
|
|
2278
2316
|
extraFileExtensions: [".vue"],
|
|
2279
|
-
parser:
|
|
2280
|
-
sourceType: "module"
|
|
2317
|
+
parser: typescript2.enabled ? parserTs : void 0,
|
|
2318
|
+
sourceType: "module",
|
|
2319
|
+
...tsConfigOptions
|
|
2281
2320
|
}
|
|
2282
2321
|
},
|
|
2283
2322
|
processor: default14.processors[".vue"],
|
|
@@ -2430,9 +2469,9 @@ var VuePackages = [
|
|
|
2430
2469
|
];
|
|
2431
2470
|
function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
2432
2471
|
const {
|
|
2433
|
-
isInEditor = !!((
|
|
2472
|
+
isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
|
|
2434
2473
|
vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
|
|
2435
|
-
typescript:
|
|
2474
|
+
typescript: tsOptions = {},
|
|
2436
2475
|
stylistic: enableStylistic = true,
|
|
2437
2476
|
test: enableTest = true,
|
|
2438
2477
|
jsonc: enableJsonc = true,
|
|
@@ -2457,9 +2496,13 @@ function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
|
2457
2496
|
if (enableVue) {
|
|
2458
2497
|
componentExts.push("vue");
|
|
2459
2498
|
}
|
|
2460
|
-
|
|
2499
|
+
const {
|
|
2500
|
+
enabled: tsEnabled = isPackageExists("typescript"),
|
|
2501
|
+
...tsParams
|
|
2502
|
+
} = tsOptions;
|
|
2503
|
+
if (tsEnabled) {
|
|
2461
2504
|
configs.push(typescript({
|
|
2462
|
-
|
|
2505
|
+
...tsParams,
|
|
2463
2506
|
componentExts,
|
|
2464
2507
|
overrides: overrides.typescript
|
|
2465
2508
|
}));
|
|
@@ -2476,7 +2519,10 @@ function vinicuncaESLint({ options = {}, userConfigs = [] } = {}) {
|
|
|
2476
2519
|
;
|
|
2477
2520
|
if (enableVue) {
|
|
2478
2521
|
configs.push(vue({
|
|
2479
|
-
typescript:
|
|
2522
|
+
typescript: {
|
|
2523
|
+
enabled: tsEnabled,
|
|
2524
|
+
...tsParams
|
|
2525
|
+
},
|
|
2480
2526
|
overrides: overrides.vue
|
|
2481
2527
|
}));
|
|
2482
2528
|
}
|