@vinicunca/eslint-config 2.1.6 → 2.2.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 +61 -10
- package/dist/index.d.cts +54 -7
- package/dist/index.d.ts +54 -7
- package/dist/index.js +59 -10
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,7 @@ __export(src_exports, {
|
|
|
56
56
|
STYLISTIC_CONFIG_DEFAULTS: () => STYLISTIC_CONFIG_DEFAULTS,
|
|
57
57
|
combineConfigs: () => combineConfigs,
|
|
58
58
|
comments: () => comments,
|
|
59
|
+
defaultPluginRenaming: () => defaultPluginRenaming,
|
|
59
60
|
ignores: () => ignores,
|
|
60
61
|
imports: () => imports,
|
|
61
62
|
interopDefault: () => interopDefault,
|
|
@@ -73,6 +74,7 @@ __export(src_exports, {
|
|
|
73
74
|
pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
|
|
74
75
|
pluginVinicunca: () => import_eslint_plugin_vinicunca.default,
|
|
75
76
|
react: () => react,
|
|
77
|
+
renamePluginInConfigs: () => renamePluginInConfigs,
|
|
76
78
|
renameRules: () => renameRules,
|
|
77
79
|
sortPackageJson: () => sortPackageJson,
|
|
78
80
|
sortTsconfig: () => sortTsconfig,
|
|
@@ -118,7 +120,7 @@ var ALWAYS = "always";
|
|
|
118
120
|
// src/plugins.ts
|
|
119
121
|
var import_eslint_plugin_vinicunca = __toESM(require("@vinicunca/eslint-plugin-vinicunca"), 1);
|
|
120
122
|
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
121
|
-
var pluginImport = __toESM(require("eslint-plugin-
|
|
123
|
+
var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
|
|
122
124
|
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
123
125
|
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
124
126
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
@@ -548,17 +550,37 @@ async function combineConfigs(...configs) {
|
|
|
548
550
|
const resolved = await Promise.all(configs);
|
|
549
551
|
return resolved.flat();
|
|
550
552
|
}
|
|
551
|
-
function renameRules(rules,
|
|
553
|
+
function renameRules(rules, map) {
|
|
552
554
|
return Object.fromEntries(
|
|
553
555
|
Object.entries(rules).map(([key, value]) => {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
+
for (const [from, to] of Object.entries(map)) {
|
|
557
|
+
if (key.startsWith(`${from}/`)) {
|
|
558
|
+
return [to + key.slice(from.length), value];
|
|
559
|
+
}
|
|
556
560
|
}
|
|
557
|
-
;
|
|
558
561
|
return [key, value];
|
|
559
562
|
})
|
|
560
563
|
);
|
|
561
564
|
}
|
|
565
|
+
function renamePluginInConfigs(configs, map) {
|
|
566
|
+
return configs.map((i) => {
|
|
567
|
+
const clone = { ...i };
|
|
568
|
+
if (clone.rules) {
|
|
569
|
+
clone.rules = renameRules(clone.rules, map);
|
|
570
|
+
}
|
|
571
|
+
if (clone.plugins) {
|
|
572
|
+
clone.plugins = Object.fromEntries(
|
|
573
|
+
Object.entries(clone.plugins).map(([key, value]) => {
|
|
574
|
+
if (key in map) {
|
|
575
|
+
return [map[key], value];
|
|
576
|
+
}
|
|
577
|
+
return [key, value];
|
|
578
|
+
})
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
return clone;
|
|
582
|
+
});
|
|
583
|
+
}
|
|
562
584
|
async function interopDefault(m) {
|
|
563
585
|
const resolved = await m;
|
|
564
586
|
return resolved.default || resolved;
|
|
@@ -976,6 +998,22 @@ async function sortPackageJson() {
|
|
|
976
998
|
"default"
|
|
977
999
|
],
|
|
978
1000
|
pathPattern: "^exports.*$"
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
order: [
|
|
1004
|
+
// client hooks only
|
|
1005
|
+
"pre-commit",
|
|
1006
|
+
"prepare-commit-msg",
|
|
1007
|
+
"commit-msg",
|
|
1008
|
+
"post-commit",
|
|
1009
|
+
"pre-rebase",
|
|
1010
|
+
"post-rewrite",
|
|
1011
|
+
"post-checkout",
|
|
1012
|
+
"post-merge",
|
|
1013
|
+
"pre-push",
|
|
1014
|
+
"pre-auto-gc"
|
|
1015
|
+
],
|
|
1016
|
+
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
|
|
979
1017
|
}
|
|
980
1018
|
]
|
|
981
1019
|
}
|
|
@@ -1339,13 +1377,11 @@ async function typescript(options = {}) {
|
|
|
1339
1377
|
rules: {
|
|
1340
1378
|
...renameRules(
|
|
1341
1379
|
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
1342
|
-
"@typescript-eslint
|
|
1343
|
-
"ts/"
|
|
1380
|
+
{ "@typescript-eslint": "ts" }
|
|
1344
1381
|
),
|
|
1345
1382
|
...renameRules(
|
|
1346
1383
|
pluginTs.configs.strict.rules,
|
|
1347
|
-
"@typescript-eslint
|
|
1348
|
-
"ts/"
|
|
1384
|
+
{ "@typescript-eslint": "ts" }
|
|
1349
1385
|
),
|
|
1350
1386
|
"no-dupe-class-members": OFF,
|
|
1351
1387
|
"no-invalid-this": OFF,
|
|
@@ -1872,8 +1908,17 @@ var VuePackages = [
|
|
|
1872
1908
|
"vitepress",
|
|
1873
1909
|
"@slidev/cli"
|
|
1874
1910
|
];
|
|
1911
|
+
var defaultPluginRenaming = {
|
|
1912
|
+
"@stylistic": "style",
|
|
1913
|
+
"@typescript-eslint": "ts",
|
|
1914
|
+
"import-x": "import",
|
|
1915
|
+
"n": "node",
|
|
1916
|
+
"vitest": "test",
|
|
1917
|
+
"yml": "yaml"
|
|
1918
|
+
};
|
|
1875
1919
|
async function vinicuncaESLint(options = {}, ...userConfigs) {
|
|
1876
1920
|
const {
|
|
1921
|
+
autoRenamePlugins = true,
|
|
1877
1922
|
componentExts = [],
|
|
1878
1923
|
gitignore: enableGitignore = true,
|
|
1879
1924
|
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),
|
|
@@ -2000,10 +2045,14 @@ async function vinicuncaESLint(options = {}, ...userConfigs) {
|
|
|
2000
2045
|
configs.push([fusedConfig]);
|
|
2001
2046
|
}
|
|
2002
2047
|
;
|
|
2003
|
-
|
|
2048
|
+
const merged = await combineConfigs(
|
|
2004
2049
|
...configs,
|
|
2005
2050
|
...userConfigs
|
|
2006
2051
|
);
|
|
2052
|
+
if (autoRenamePlugins) {
|
|
2053
|
+
return renamePluginInConfigs(merged, defaultPluginRenaming);
|
|
2054
|
+
}
|
|
2055
|
+
return merged;
|
|
2007
2056
|
}
|
|
2008
2057
|
function getOverrides(options, key) {
|
|
2009
2058
|
const sub = resolveSubOptions(options, key);
|
|
@@ -2042,6 +2091,7 @@ function resolveSubOptions(options, key) {
|
|
|
2042
2091
|
STYLISTIC_CONFIG_DEFAULTS,
|
|
2043
2092
|
combineConfigs,
|
|
2044
2093
|
comments,
|
|
2094
|
+
defaultPluginRenaming,
|
|
2045
2095
|
ignores,
|
|
2046
2096
|
imports,
|
|
2047
2097
|
interopDefault,
|
|
@@ -2059,6 +2109,7 @@ function resolveSubOptions(options, key) {
|
|
|
2059
2109
|
pluginUnusedImports,
|
|
2060
2110
|
pluginVinicunca,
|
|
2061
2111
|
react,
|
|
2112
|
+
renamePluginInConfigs,
|
|
2062
2113
|
renameRules,
|
|
2063
2114
|
sortPackageJson,
|
|
2064
2115
|
sortTsconfig,
|
package/dist/index.d.cts
CHANGED
|
@@ -10,8 +10,8 @@ import { Linter } from 'eslint';
|
|
|
10
10
|
import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
|
|
11
11
|
import { Options } from 'eslint-processor-vue-blocks';
|
|
12
12
|
export { default as pluginComments } from 'eslint-plugin-eslint-comments';
|
|
13
|
-
import * as
|
|
14
|
-
export {
|
|
13
|
+
import * as eslintPluginImportX from 'eslint-plugin-import-x';
|
|
14
|
+
export { eslintPluginImportX as pluginImport };
|
|
15
15
|
export { default as pluginNode } from 'eslint-plugin-n';
|
|
16
16
|
export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist';
|
|
17
17
|
export { default as pluginUnicorn } from 'eslint-plugin-unicorn';
|
|
@@ -252,6 +252,12 @@ interface OptionsUnoCSS extends OptionsOverrides {
|
|
|
252
252
|
strict?: boolean;
|
|
253
253
|
}
|
|
254
254
|
interface OptionsConfig extends OptionsComponentExts {
|
|
255
|
+
/**
|
|
256
|
+
* Automatically rename plugins in the config.
|
|
257
|
+
*
|
|
258
|
+
* @default true
|
|
259
|
+
*/
|
|
260
|
+
autoRenamePlugins?: boolean;
|
|
255
261
|
/**
|
|
256
262
|
* Use external formatters to format files.
|
|
257
263
|
*
|
|
@@ -353,6 +359,14 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
353
359
|
yaml?: OptionsOverrides | boolean;
|
|
354
360
|
}
|
|
355
361
|
|
|
362
|
+
declare const defaultPluginRenaming: {
|
|
363
|
+
'@stylistic': string;
|
|
364
|
+
'@typescript-eslint': string;
|
|
365
|
+
'import-x': string;
|
|
366
|
+
n: string;
|
|
367
|
+
vitest: string;
|
|
368
|
+
yml: string;
|
|
369
|
+
};
|
|
356
370
|
declare function vinicuncaESLint(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Array<Awaitable<Array<UserConfigItem> | UserConfigItem>>): Promise<Array<UserConfigItem>>;
|
|
357
371
|
|
|
358
372
|
declare function comments(): Promise<FlatConfigItem[]>;
|
|
@@ -378,20 +392,20 @@ declare function react(options?: OptionsHasTypeScript & OptionsOverrides & Optio
|
|
|
378
392
|
*
|
|
379
393
|
* Requires `jsonc` config
|
|
380
394
|
*/
|
|
381
|
-
declare function sortPackageJson(): Promise<FlatConfigItem
|
|
395
|
+
declare function sortPackageJson(): Promise<Array<FlatConfigItem>>;
|
|
382
396
|
/**
|
|
383
397
|
* Sort tsconfig.json
|
|
384
398
|
*
|
|
385
399
|
* Requires `jsonc` config
|
|
386
400
|
*/
|
|
387
|
-
declare function sortTsconfig(): FlatConfigItem
|
|
401
|
+
declare function sortTsconfig(): Array<FlatConfigItem>;
|
|
388
402
|
|
|
389
403
|
declare const STYLISTIC_CONFIG_DEFAULTS: StylisticConfig;
|
|
390
404
|
declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
391
405
|
|
|
392
406
|
declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
393
407
|
|
|
394
|
-
declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<FlatConfigItem
|
|
408
|
+
declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<Array<FlatConfigItem>>;
|
|
395
409
|
|
|
396
410
|
declare function unicorn(): Promise<FlatConfigItem[]>;
|
|
397
411
|
|
|
@@ -405,9 +419,42 @@ declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFil
|
|
|
405
419
|
* Combine array and non-array configs into a single array.
|
|
406
420
|
*/
|
|
407
421
|
declare function combineConfigs(...configs: Array<Awaitable<Array<UserConfigItem> | UserConfigItem>>): Promise<Array<UserConfigItem>>;
|
|
408
|
-
|
|
422
|
+
/**
|
|
423
|
+
* Rename plugin prefixes in a rule object.
|
|
424
|
+
* Accepts a map of prefixes to rename.
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```ts
|
|
428
|
+
* import { renameRules } from '@vinicunca/eslint-config'
|
|
429
|
+
*
|
|
430
|
+
* export default [{
|
|
431
|
+
* rules: renameRules(
|
|
432
|
+
* {
|
|
433
|
+
* '@typescript-eslint/indent': 'error'
|
|
434
|
+
* },
|
|
435
|
+
* { '@typescript-eslint': 'ts' }
|
|
436
|
+
* )
|
|
437
|
+
* }]
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
declare function renameRules(rules: Record<string, any>, map: Record<string, string>): {
|
|
409
441
|
[k: string]: any;
|
|
410
442
|
};
|
|
443
|
+
/**
|
|
444
|
+
* Rename plugin names a flat configs array
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```ts
|
|
448
|
+
* import { renamePluginInConfigs } from '@vinicunca/eslint-config'
|
|
449
|
+
* import someConfigs from './some-configs'
|
|
450
|
+
*
|
|
451
|
+
* export default renamePluginInConfigs(someConfigs, {
|
|
452
|
+
* '@typescript-eslint': 'ts',
|
|
453
|
+
* 'import-x': 'import',
|
|
454
|
+
* })
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
declare function renamePluginInConfigs(configs: Array<UserConfigItem>, map: Record<string, string>): Array<UserConfigItem>;
|
|
411
458
|
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
412
459
|
default: infer U;
|
|
413
460
|
} ? U : T>;
|
|
@@ -462,4 +509,4 @@ declare const GLOB_TESTS: string[];
|
|
|
462
509
|
declare const GLOB_ALL_SRC: string[];
|
|
463
510
|
declare const GLOB_EXCLUDE: string[];
|
|
464
511
|
|
|
465
|
-
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type Rules, STYLISTIC_CONFIG_DEFAULTS, type StylisticConfig, type UserConfigItem, type WrapRuleConfig, combineConfigs, comments, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vinicuncaESLint, vue, yaml };
|
|
512
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type Rules, STYLISTIC_CONFIG_DEFAULTS, type StylisticConfig, type UserConfigItem, type WrapRuleConfig, combineConfigs, comments, defaultPluginRenaming, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, react, renamePluginInConfigs, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vinicuncaESLint, vue, yaml };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ import { Linter } from 'eslint';
|
|
|
10
10
|
import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
|
|
11
11
|
import { Options } from 'eslint-processor-vue-blocks';
|
|
12
12
|
export { default as pluginComments } from 'eslint-plugin-eslint-comments';
|
|
13
|
-
import * as
|
|
14
|
-
export {
|
|
13
|
+
import * as eslintPluginImportX from 'eslint-plugin-import-x';
|
|
14
|
+
export { eslintPluginImportX as pluginImport };
|
|
15
15
|
export { default as pluginNode } from 'eslint-plugin-n';
|
|
16
16
|
export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist';
|
|
17
17
|
export { default as pluginUnicorn } from 'eslint-plugin-unicorn';
|
|
@@ -252,6 +252,12 @@ interface OptionsUnoCSS extends OptionsOverrides {
|
|
|
252
252
|
strict?: boolean;
|
|
253
253
|
}
|
|
254
254
|
interface OptionsConfig extends OptionsComponentExts {
|
|
255
|
+
/**
|
|
256
|
+
* Automatically rename plugins in the config.
|
|
257
|
+
*
|
|
258
|
+
* @default true
|
|
259
|
+
*/
|
|
260
|
+
autoRenamePlugins?: boolean;
|
|
255
261
|
/**
|
|
256
262
|
* Use external formatters to format files.
|
|
257
263
|
*
|
|
@@ -353,6 +359,14 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
353
359
|
yaml?: OptionsOverrides | boolean;
|
|
354
360
|
}
|
|
355
361
|
|
|
362
|
+
declare const defaultPluginRenaming: {
|
|
363
|
+
'@stylistic': string;
|
|
364
|
+
'@typescript-eslint': string;
|
|
365
|
+
'import-x': string;
|
|
366
|
+
n: string;
|
|
367
|
+
vitest: string;
|
|
368
|
+
yml: string;
|
|
369
|
+
};
|
|
356
370
|
declare function vinicuncaESLint(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Array<Awaitable<Array<UserConfigItem> | UserConfigItem>>): Promise<Array<UserConfigItem>>;
|
|
357
371
|
|
|
358
372
|
declare function comments(): Promise<FlatConfigItem[]>;
|
|
@@ -378,20 +392,20 @@ declare function react(options?: OptionsHasTypeScript & OptionsOverrides & Optio
|
|
|
378
392
|
*
|
|
379
393
|
* Requires `jsonc` config
|
|
380
394
|
*/
|
|
381
|
-
declare function sortPackageJson(): Promise<FlatConfigItem
|
|
395
|
+
declare function sortPackageJson(): Promise<Array<FlatConfigItem>>;
|
|
382
396
|
/**
|
|
383
397
|
* Sort tsconfig.json
|
|
384
398
|
*
|
|
385
399
|
* Requires `jsonc` config
|
|
386
400
|
*/
|
|
387
|
-
declare function sortTsconfig(): FlatConfigItem
|
|
401
|
+
declare function sortTsconfig(): Array<FlatConfigItem>;
|
|
388
402
|
|
|
389
403
|
declare const STYLISTIC_CONFIG_DEFAULTS: StylisticConfig;
|
|
390
404
|
declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
391
405
|
|
|
392
406
|
declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
393
407
|
|
|
394
|
-
declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<FlatConfigItem
|
|
408
|
+
declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<Array<FlatConfigItem>>;
|
|
395
409
|
|
|
396
410
|
declare function unicorn(): Promise<FlatConfigItem[]>;
|
|
397
411
|
|
|
@@ -405,9 +419,42 @@ declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFil
|
|
|
405
419
|
* Combine array and non-array configs into a single array.
|
|
406
420
|
*/
|
|
407
421
|
declare function combineConfigs(...configs: Array<Awaitable<Array<UserConfigItem> | UserConfigItem>>): Promise<Array<UserConfigItem>>;
|
|
408
|
-
|
|
422
|
+
/**
|
|
423
|
+
* Rename plugin prefixes in a rule object.
|
|
424
|
+
* Accepts a map of prefixes to rename.
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```ts
|
|
428
|
+
* import { renameRules } from '@vinicunca/eslint-config'
|
|
429
|
+
*
|
|
430
|
+
* export default [{
|
|
431
|
+
* rules: renameRules(
|
|
432
|
+
* {
|
|
433
|
+
* '@typescript-eslint/indent': 'error'
|
|
434
|
+
* },
|
|
435
|
+
* { '@typescript-eslint': 'ts' }
|
|
436
|
+
* )
|
|
437
|
+
* }]
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
declare function renameRules(rules: Record<string, any>, map: Record<string, string>): {
|
|
409
441
|
[k: string]: any;
|
|
410
442
|
};
|
|
443
|
+
/**
|
|
444
|
+
* Rename plugin names a flat configs array
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```ts
|
|
448
|
+
* import { renamePluginInConfigs } from '@vinicunca/eslint-config'
|
|
449
|
+
* import someConfigs from './some-configs'
|
|
450
|
+
*
|
|
451
|
+
* export default renamePluginInConfigs(someConfigs, {
|
|
452
|
+
* '@typescript-eslint': 'ts',
|
|
453
|
+
* 'import-x': 'import',
|
|
454
|
+
* })
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
declare function renamePluginInConfigs(configs: Array<UserConfigItem>, map: Record<string, string>): Array<UserConfigItem>;
|
|
411
458
|
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
412
459
|
default: infer U;
|
|
413
460
|
} ? U : T>;
|
|
@@ -462,4 +509,4 @@ declare const GLOB_TESTS: string[];
|
|
|
462
509
|
declare const GLOB_ALL_SRC: string[];
|
|
463
510
|
declare const GLOB_EXCLUDE: string[];
|
|
464
511
|
|
|
465
|
-
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type Rules, STYLISTIC_CONFIG_DEFAULTS, type StylisticConfig, type UserConfigItem, type WrapRuleConfig, combineConfigs, comments, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vinicuncaESLint, vue, yaml };
|
|
512
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type Rules, STYLISTIC_CONFIG_DEFAULTS, type StylisticConfig, type UserConfigItem, type WrapRuleConfig, combineConfigs, comments, defaultPluginRenaming, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, react, renamePluginInConfigs, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vinicuncaESLint, vue, yaml };
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var ALWAYS = "always";
|
|
|
28
28
|
// src/plugins.ts
|
|
29
29
|
import { default as default2 } from "@vinicunca/eslint-plugin-vinicunca";
|
|
30
30
|
import { default as default3 } from "eslint-plugin-eslint-comments";
|
|
31
|
-
import * as pluginImport from "eslint-plugin-
|
|
31
|
+
import * as pluginImport from "eslint-plugin-import-x";
|
|
32
32
|
import { default as default4 } from "eslint-plugin-n";
|
|
33
33
|
import { default as default5 } from "eslint-plugin-perfectionist";
|
|
34
34
|
import { default as default6 } from "eslint-plugin-unicorn";
|
|
@@ -458,17 +458,37 @@ async function combineConfigs(...configs) {
|
|
|
458
458
|
const resolved = await Promise.all(configs);
|
|
459
459
|
return resolved.flat();
|
|
460
460
|
}
|
|
461
|
-
function renameRules(rules,
|
|
461
|
+
function renameRules(rules, map) {
|
|
462
462
|
return Object.fromEntries(
|
|
463
463
|
Object.entries(rules).map(([key, value]) => {
|
|
464
|
-
|
|
465
|
-
|
|
464
|
+
for (const [from, to] of Object.entries(map)) {
|
|
465
|
+
if (key.startsWith(`${from}/`)) {
|
|
466
|
+
return [to + key.slice(from.length), value];
|
|
467
|
+
}
|
|
466
468
|
}
|
|
467
|
-
;
|
|
468
469
|
return [key, value];
|
|
469
470
|
})
|
|
470
471
|
);
|
|
471
472
|
}
|
|
473
|
+
function renamePluginInConfigs(configs, map) {
|
|
474
|
+
return configs.map((i) => {
|
|
475
|
+
const clone = { ...i };
|
|
476
|
+
if (clone.rules) {
|
|
477
|
+
clone.rules = renameRules(clone.rules, map);
|
|
478
|
+
}
|
|
479
|
+
if (clone.plugins) {
|
|
480
|
+
clone.plugins = Object.fromEntries(
|
|
481
|
+
Object.entries(clone.plugins).map(([key, value]) => {
|
|
482
|
+
if (key in map) {
|
|
483
|
+
return [map[key], value];
|
|
484
|
+
}
|
|
485
|
+
return [key, value];
|
|
486
|
+
})
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
return clone;
|
|
490
|
+
});
|
|
491
|
+
}
|
|
472
492
|
async function interopDefault(m) {
|
|
473
493
|
const resolved = await m;
|
|
474
494
|
return resolved.default || resolved;
|
|
@@ -886,6 +906,22 @@ async function sortPackageJson() {
|
|
|
886
906
|
"default"
|
|
887
907
|
],
|
|
888
908
|
pathPattern: "^exports.*$"
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
order: [
|
|
912
|
+
// client hooks only
|
|
913
|
+
"pre-commit",
|
|
914
|
+
"prepare-commit-msg",
|
|
915
|
+
"commit-msg",
|
|
916
|
+
"post-commit",
|
|
917
|
+
"pre-rebase",
|
|
918
|
+
"post-rewrite",
|
|
919
|
+
"post-checkout",
|
|
920
|
+
"post-merge",
|
|
921
|
+
"pre-push",
|
|
922
|
+
"pre-auto-gc"
|
|
923
|
+
],
|
|
924
|
+
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
|
|
889
925
|
}
|
|
890
926
|
]
|
|
891
927
|
}
|
|
@@ -1249,13 +1285,11 @@ async function typescript(options = {}) {
|
|
|
1249
1285
|
rules: {
|
|
1250
1286
|
...renameRules(
|
|
1251
1287
|
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
1252
|
-
"@typescript-eslint
|
|
1253
|
-
"ts/"
|
|
1288
|
+
{ "@typescript-eslint": "ts" }
|
|
1254
1289
|
),
|
|
1255
1290
|
...renameRules(
|
|
1256
1291
|
pluginTs.configs.strict.rules,
|
|
1257
|
-
"@typescript-eslint
|
|
1258
|
-
"ts/"
|
|
1292
|
+
{ "@typescript-eslint": "ts" }
|
|
1259
1293
|
),
|
|
1260
1294
|
"no-dupe-class-members": OFF,
|
|
1261
1295
|
"no-invalid-this": OFF,
|
|
@@ -1782,8 +1816,17 @@ var VuePackages = [
|
|
|
1782
1816
|
"vitepress",
|
|
1783
1817
|
"@slidev/cli"
|
|
1784
1818
|
];
|
|
1819
|
+
var defaultPluginRenaming = {
|
|
1820
|
+
"@stylistic": "style",
|
|
1821
|
+
"@typescript-eslint": "ts",
|
|
1822
|
+
"import-x": "import",
|
|
1823
|
+
"n": "node",
|
|
1824
|
+
"vitest": "test",
|
|
1825
|
+
"yml": "yaml"
|
|
1826
|
+
};
|
|
1785
1827
|
async function vinicuncaESLint(options = {}, ...userConfigs) {
|
|
1786
1828
|
const {
|
|
1829
|
+
autoRenamePlugins = true,
|
|
1787
1830
|
componentExts = [],
|
|
1788
1831
|
gitignore: enableGitignore = true,
|
|
1789
1832
|
isInEditor = !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE || process2.env.VIM) && !process2.env.CI),
|
|
@@ -1910,10 +1953,14 @@ async function vinicuncaESLint(options = {}, ...userConfigs) {
|
|
|
1910
1953
|
configs.push([fusedConfig]);
|
|
1911
1954
|
}
|
|
1912
1955
|
;
|
|
1913
|
-
|
|
1956
|
+
const merged = await combineConfigs(
|
|
1914
1957
|
...configs,
|
|
1915
1958
|
...userConfigs
|
|
1916
1959
|
);
|
|
1960
|
+
if (autoRenamePlugins) {
|
|
1961
|
+
return renamePluginInConfigs(merged, defaultPluginRenaming);
|
|
1962
|
+
}
|
|
1963
|
+
return merged;
|
|
1917
1964
|
}
|
|
1918
1965
|
function getOverrides(options, key) {
|
|
1919
1966
|
const sub = resolveSubOptions(options, key);
|
|
@@ -1951,6 +1998,7 @@ export {
|
|
|
1951
1998
|
STYLISTIC_CONFIG_DEFAULTS,
|
|
1952
1999
|
combineConfigs,
|
|
1953
2000
|
comments,
|
|
2001
|
+
defaultPluginRenaming,
|
|
1954
2002
|
ignores,
|
|
1955
2003
|
imports,
|
|
1956
2004
|
interopDefault,
|
|
@@ -1968,6 +2016,7 @@ export {
|
|
|
1968
2016
|
default7 as pluginUnusedImports,
|
|
1969
2017
|
default2 as pluginVinicunca,
|
|
1970
2018
|
react,
|
|
2019
|
+
renamePluginInConfigs,
|
|
1971
2020
|
renameRules,
|
|
1972
2021
|
sortPackageJson,
|
|
1973
2022
|
sortTsconfig,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vinicunca/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"description": "Vinicunca ESLint config",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "praburangki",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"eslint-merge-processors": "^0.1.0",
|
|
72
72
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
73
73
|
"eslint-plugin-format": "^0.1.0",
|
|
74
|
-
"eslint-plugin-
|
|
74
|
+
"eslint-plugin-import-x": "^0.4.1",
|
|
75
75
|
"eslint-plugin-jsdoc": "^48.2.1",
|
|
76
76
|
"eslint-plugin-jsonc": "^2.13.0",
|
|
77
77
|
"eslint-plugin-markdown": "^4.0.1",
|