@bfra.me/eslint-config 0.48.0 → 0.49.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/lib/index.d.ts +165 -145
- package/lib/index.js +69 -16
- package/package.json +13 -13
- package/src/configs/markdown.ts +17 -2
- package/src/configs/pnpm.ts +73 -9
- package/src/configs/prettier.ts +23 -2
- package/src/configs/react.ts +2 -2
- package/src/configs/toml.ts +1 -1
- package/src/rules.d.ts +165 -145
package/lib/index.js
CHANGED
|
@@ -147,7 +147,7 @@ var GLOB_EXCLUDE = [
|
|
|
147
147
|
import { fileURLToPath } from "url";
|
|
148
148
|
|
|
149
149
|
// package.json
|
|
150
|
-
var version = "0.
|
|
150
|
+
var version = "0.49.0";
|
|
151
151
|
|
|
152
152
|
// src/parsers/any-parser.ts
|
|
153
153
|
var lineBreakPattern = /\r\n|[\n\r\u2028\u2029]/u;
|
|
@@ -1041,11 +1041,20 @@ async function markdown(options = {}) {
|
|
|
1041
1041
|
}
|
|
1042
1042
|
if (yaml2) {
|
|
1043
1043
|
const pluginYaml = await interopDefault(import("eslint-plugin-yml"));
|
|
1044
|
-
const standardConfigs = pluginYaml.configs["flat/standard"];
|
|
1044
|
+
const standardConfigs = pluginYaml.configs.standard ?? pluginYaml.configs["flat/standard"];
|
|
1045
|
+
const normalizedConfigs = Array.isArray(standardConfigs) ? standardConfigs : [standardConfigs];
|
|
1046
|
+
const languageSetup = normalizedConfigs.find(
|
|
1047
|
+
(c) => c != null && "language" in c && typeof c.language === "string"
|
|
1048
|
+
);
|
|
1049
|
+
const parserSetup = normalizedConfigs.find(
|
|
1050
|
+
(c) => c != null && "languageOptions" in c && c.languageOptions != null
|
|
1051
|
+
);
|
|
1045
1052
|
configs.push({
|
|
1046
1053
|
name: "@bfra.me/markdown/code-blocks/yaml",
|
|
1047
1054
|
files: GLOB_MARKDOWN_FILES.map((p) => `${p}/${GLOB_YAML}`),
|
|
1048
|
-
|
|
1055
|
+
...languageSetup ? { language: languageSetup.language } : {},
|
|
1056
|
+
...parserSetup ? { languageOptions: parserSetup.languageOptions } : {},
|
|
1057
|
+
...languageSetup && "plugins" in languageSetup ? { plugins: languageSetup.plugins } : {},
|
|
1049
1058
|
rules: {
|
|
1050
1059
|
// Examples may show incomplete YAML mappings to focus on specific concepts
|
|
1051
1060
|
"yml/no-empty-mapping-value": "off"
|
|
@@ -1247,12 +1256,28 @@ async function pnpm() {
|
|
|
1247
1256
|
interopDefault(import("eslint-plugin-pnpm")),
|
|
1248
1257
|
interopDefault(import("eslint-plugin-yml"))
|
|
1249
1258
|
]);
|
|
1250
|
-
|
|
1251
|
-
|
|
1259
|
+
const jsoncBaseConfigs = pluginJsonc.configs["flat/base"] ?? pluginJsonc.configs.base;
|
|
1260
|
+
const yamlBaseConfigs = pluginYaml.configs.standard ?? pluginYaml.configs["flat/standard"];
|
|
1261
|
+
const jsoncConfigs = Array.isArray(jsoncBaseConfigs) ? jsoncBaseConfigs : jsoncBaseConfigs ? [jsoncBaseConfigs] : [];
|
|
1262
|
+
const yamlConfigs = Array.isArray(yamlBaseConfigs) ? yamlBaseConfigs : yamlBaseConfigs ? [yamlBaseConfigs] : [];
|
|
1263
|
+
const configs = [];
|
|
1264
|
+
const jsoncLanguageSetup = jsoncConfigs.find(
|
|
1265
|
+
(config2) => config2 != null && typeof config2 === "object" && "language" in config2
|
|
1266
|
+
);
|
|
1267
|
+
const jsoncParserSetup = jsoncConfigs.find(
|
|
1268
|
+
(config2) => config2 != null && typeof config2 === "object" && "languageOptions" in config2 && config2.languageOptions != null
|
|
1269
|
+
);
|
|
1270
|
+
const jsoncPluginSetup = jsoncConfigs.find(
|
|
1271
|
+
(config2) => config2 != null && typeof config2 === "object" && "plugins" in config2 && config2.plugins != null
|
|
1272
|
+
);
|
|
1273
|
+
if (jsoncLanguageSetup ?? jsoncParserSetup ?? jsoncPluginSetup) {
|
|
1274
|
+
configs.push({
|
|
1252
1275
|
name: "@bfra.me/pnpm/package-json",
|
|
1253
1276
|
files: ["package.json", "**/package.json"],
|
|
1254
|
-
|
|
1277
|
+
...jsoncLanguageSetup ? { language: jsoncLanguageSetup.language } : {},
|
|
1278
|
+
...jsoncParserSetup ? { languageOptions: jsoncParserSetup.languageOptions } : {},
|
|
1255
1279
|
plugins: {
|
|
1280
|
+
...jsoncPluginSetup?.plugins ?? {},
|
|
1256
1281
|
pnpm: pluginPnpm
|
|
1257
1282
|
},
|
|
1258
1283
|
rules: {
|
|
@@ -1260,20 +1285,34 @@ async function pnpm() {
|
|
|
1260
1285
|
"pnpm/json-prefer-workspace-settings": "error",
|
|
1261
1286
|
"pnpm/json-valid-catalog": "error"
|
|
1262
1287
|
}
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
const yamlLanguageSetup = yamlConfigs.find(
|
|
1291
|
+
(config2) => config2 != null && typeof config2 === "object" && "language" in config2
|
|
1292
|
+
);
|
|
1293
|
+
const yamlParserSetup = yamlConfigs.find(
|
|
1294
|
+
(config2) => config2 != null && typeof config2 === "object" && "languageOptions" in config2 && config2.languageOptions != null
|
|
1295
|
+
);
|
|
1296
|
+
const yamlPluginSetup = yamlConfigs.find(
|
|
1297
|
+
(config2) => config2 != null && typeof config2 === "object" && "plugins" in config2 && config2.plugins != null
|
|
1298
|
+
);
|
|
1299
|
+
if (yamlLanguageSetup ?? yamlParserSetup ?? yamlPluginSetup) {
|
|
1300
|
+
configs.push({
|
|
1265
1301
|
name: "@bfra.me/pnpm/pnpm-workspace-yaml",
|
|
1266
1302
|
files: ["pnpm-workspace.yaml"],
|
|
1267
|
-
|
|
1303
|
+
...yamlLanguageSetup ? { language: yamlLanguageSetup.language } : {},
|
|
1304
|
+
...yamlParserSetup ? { languageOptions: yamlParserSetup.languageOptions } : {},
|
|
1268
1305
|
plugins: {
|
|
1306
|
+
...yamlPluginSetup?.plugins ?? {},
|
|
1269
1307
|
pnpm: pluginPnpm
|
|
1270
1308
|
},
|
|
1271
1309
|
rules: {
|
|
1272
1310
|
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
1273
1311
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1274
1312
|
}
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
return configs;
|
|
1277
1316
|
},
|
|
1278
1317
|
fallback
|
|
1279
1318
|
);
|
|
@@ -1282,6 +1321,18 @@ async function pnpm() {
|
|
|
1282
1321
|
// src/configs/prettier.ts
|
|
1283
1322
|
import process4 from "process";
|
|
1284
1323
|
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
1324
|
+
function getConfigRules(configs) {
|
|
1325
|
+
if (Array.isArray(configs)) {
|
|
1326
|
+
const configWithRules = [...configs].reverse().find(
|
|
1327
|
+
(config2) => typeof config2 === "object" && config2 !== null && "rules" in config2
|
|
1328
|
+
);
|
|
1329
|
+
return configWithRules?.rules;
|
|
1330
|
+
}
|
|
1331
|
+
if (typeof configs === "object" && configs !== null && "rules" in configs) {
|
|
1332
|
+
return configs.rules;
|
|
1333
|
+
}
|
|
1334
|
+
return void 0;
|
|
1335
|
+
}
|
|
1285
1336
|
async function prettier(options = {}) {
|
|
1286
1337
|
const { isInEditor, overrides } = options;
|
|
1287
1338
|
return requireOf(
|
|
@@ -1294,6 +1345,8 @@ async function prettier(options = {}) {
|
|
|
1294
1345
|
isPackageExists2("eslint-plugin-jsonc") ? interopDefault(import("eslint-plugin-jsonc")) : Promise.resolve(void 0),
|
|
1295
1346
|
isPackageExists2("eslint-plugin-yml") ? interopDefault(import("eslint-plugin-yml")) : Promise.resolve(void 0)
|
|
1296
1347
|
]);
|
|
1348
|
+
const jsoncPrettierRules = getConfigRules(pluginJsonc?.configs.prettier);
|
|
1349
|
+
const yamlPrettierRules = getConfigRules(pluginYaml?.configs.prettier);
|
|
1297
1350
|
return [
|
|
1298
1351
|
{
|
|
1299
1352
|
name: "@bfra.me/prettier",
|
|
@@ -1303,7 +1356,7 @@ async function prettier(options = {}) {
|
|
|
1303
1356
|
rules: {
|
|
1304
1357
|
"prettier/prettier": isInEditor ? "warn" : "error",
|
|
1305
1358
|
...configPrettier.rules,
|
|
1306
|
-
...
|
|
1359
|
+
...jsoncPrettierRules ?? {},
|
|
1307
1360
|
"toml/array-bracket-newline": "off",
|
|
1308
1361
|
"toml/array-bracket-spacing": "off",
|
|
1309
1362
|
"toml/array-element-newline": "off",
|
|
@@ -1311,7 +1364,7 @@ async function prettier(options = {}) {
|
|
|
1311
1364
|
"toml/inline-table-curly-spacing": "off",
|
|
1312
1365
|
"toml/key-spacing": "off",
|
|
1313
1366
|
"toml/table-bracket-spacing": "off",
|
|
1314
|
-
...
|
|
1367
|
+
...yamlPrettierRules ?? {},
|
|
1315
1368
|
...overrides
|
|
1316
1369
|
}
|
|
1317
1370
|
},
|
|
@@ -1382,7 +1435,7 @@ async function react(options = {}) {
|
|
|
1382
1435
|
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1383
1436
|
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1384
1437
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1385
|
-
|
|
1438
|
+
import("eslint-plugin-react-refresh").then((m) => m.reactRefresh)
|
|
1386
1439
|
]);
|
|
1387
1440
|
const plugins = pluginReact.configs.all.plugins;
|
|
1388
1441
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
@@ -1400,7 +1453,7 @@ async function react(options = {}) {
|
|
|
1400
1453
|
"react-hooks": pluginReactHooks,
|
|
1401
1454
|
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1402
1455
|
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1403
|
-
"react-refresh": pluginReactRefresh,
|
|
1456
|
+
"react-refresh": pluginReactRefresh.plugin,
|
|
1404
1457
|
"react-web-api": plugins["@eslint-react/web-api"]
|
|
1405
1458
|
}
|
|
1406
1459
|
},
|
|
@@ -1826,7 +1879,7 @@ async function toml(options = {}) {
|
|
|
1826
1879
|
const includeStylistic = typeof stylistic2 === "boolean" ? stylistic2 : true;
|
|
1827
1880
|
const pluginToml = await interopDefault(import("eslint-plugin-toml"));
|
|
1828
1881
|
return [
|
|
1829
|
-
...pluginToml.configs
|
|
1882
|
+
...pluginToml.configs.standard.map((config2, index) => ({
|
|
1830
1883
|
...config2,
|
|
1831
1884
|
name: config2.plugins ? `@bfra.me/toml/plugins` : `@bfra.me/${(config2.name ?? "") || `toml/unnamed${index}`}`
|
|
1832
1885
|
})),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bfra.me/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"description": "Shared ESLint configuration for bfra.me",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bfra.me",
|
|
@@ -41,26 +41,26 @@
|
|
|
41
41
|
"@eslint/markdown": "7.5.1",
|
|
42
42
|
"@stylistic/eslint-plugin": "5.8.0",
|
|
43
43
|
"eslint-config-flat-gitignore": "2.1.0",
|
|
44
|
-
"eslint-flat-config-utils": "
|
|
44
|
+
"eslint-flat-config-utils": "3.0.1",
|
|
45
45
|
"eslint-merge-processors": "2.0.0",
|
|
46
46
|
"eslint-plugin-command": "3.4.0",
|
|
47
47
|
"eslint-plugin-import-x": "4.16.1",
|
|
48
|
-
"eslint-plugin-jsdoc": "
|
|
49
|
-
"eslint-plugin-json-schema-validator": "
|
|
48
|
+
"eslint-plugin-jsdoc": "62.6.0",
|
|
49
|
+
"eslint-plugin-json-schema-validator": "6.0.3",
|
|
50
50
|
"eslint-plugin-jsonc": "2.21.1",
|
|
51
51
|
"eslint-plugin-n": "17.24.0",
|
|
52
|
-
"eslint-plugin-perfectionist": "5.
|
|
53
|
-
"eslint-plugin-regexp": "
|
|
54
|
-
"eslint-plugin-toml": "
|
|
55
|
-
"eslint-plugin-unicorn": "
|
|
52
|
+
"eslint-plugin-perfectionist": "5.6.0",
|
|
53
|
+
"eslint-plugin-regexp": "3.0.0",
|
|
54
|
+
"eslint-plugin-toml": "1.1.0",
|
|
55
|
+
"eslint-plugin-unicorn": "63.0.0",
|
|
56
56
|
"eslint-plugin-unused-imports": "4.4.1",
|
|
57
|
-
"eslint-plugin-yml": "
|
|
57
|
+
"eslint-plugin-yml": "3.2.0",
|
|
58
58
|
"globals": "17.3.0",
|
|
59
59
|
"is-in-ci": "2.0.0",
|
|
60
60
|
"local-pkg": "1.1.2",
|
|
61
61
|
"package-manager-detector": "1.6.0",
|
|
62
62
|
"sort-package-json": "3.6.1",
|
|
63
|
-
"typescript-eslint": "8.
|
|
63
|
+
"typescript-eslint": "8.56.0",
|
|
64
64
|
"@bfra.me/es": "0.1.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@next/eslint-plugin-next": "16.1.6",
|
|
71
71
|
"@types/eslint-config-prettier": "6.11.3",
|
|
72
72
|
"@types/eslint-plugin-jsx-a11y": "6.10.1",
|
|
73
|
-
"@typescript-eslint/types": "8.
|
|
73
|
+
"@typescript-eslint/types": "8.56.0",
|
|
74
74
|
"@vitest/eslint-plugin": "1.6.9",
|
|
75
75
|
"astro-eslint-parser": "1.3.0",
|
|
76
76
|
"eslint": "10.0.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"eslint-plugin-pnpm": "1.5.0",
|
|
83
83
|
"eslint-plugin-prettier": "5.5.5",
|
|
84
84
|
"eslint-plugin-react-hooks": "7.0.1",
|
|
85
|
-
"eslint-plugin-react-refresh": "0.
|
|
85
|
+
"eslint-plugin-react-refresh": "0.5.0",
|
|
86
86
|
"eslint-typegen": "2.3.0",
|
|
87
87
|
"@bfra.me/prettier-config": "0.16.7",
|
|
88
88
|
"@bfra.me/tsconfig": "0.12.2",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"eslint-plugin-jsx-a11y": ">=6.10.2",
|
|
100
100
|
"eslint-plugin-prettier": "^5.5.4",
|
|
101
101
|
"eslint-plugin-react-hooks": "^7.0.0",
|
|
102
|
-
"eslint-plugin-react-refresh": "^0.4.20"
|
|
102
|
+
"eslint-plugin-react-refresh": "^0.4.20 || ^0.5.0"
|
|
103
103
|
},
|
|
104
104
|
"peerDependenciesMeta": {
|
|
105
105
|
"@eslint-react/eslint-plugin": {
|
package/src/configs/markdown.ts
CHANGED
|
@@ -401,12 +401,27 @@ export async function markdown(options: MarkdownOptions = {}): Promise<Config[]>
|
|
|
401
401
|
const pluginYaml = await interopDefault(import('eslint-plugin-yml'))
|
|
402
402
|
|
|
403
403
|
// Use plugin's standard config to inherit parser configuration
|
|
404
|
-
const standardConfigs = pluginYaml.configs['flat/standard'] as
|
|
404
|
+
const standardConfigs = (pluginYaml.configs.standard ?? pluginYaml.configs['flat/standard']) as
|
|
405
|
+
| Config[]
|
|
406
|
+
| Config
|
|
407
|
+
const normalizedConfigs = Array.isArray(standardConfigs) ? standardConfigs : [standardConfigs]
|
|
408
|
+
|
|
409
|
+
// Find language and parser setup from normalized configs with explicit type guards
|
|
410
|
+
const languageSetup = normalizedConfigs.find(
|
|
411
|
+
(c): c is Config & {language: string} =>
|
|
412
|
+
c != null && 'language' in c && typeof c.language === 'string',
|
|
413
|
+
)
|
|
414
|
+
const parserSetup = normalizedConfigs.find(
|
|
415
|
+
(c): c is Config & {languageOptions: Record<string, unknown>} =>
|
|
416
|
+
c != null && 'languageOptions' in c && c.languageOptions != null,
|
|
417
|
+
)
|
|
405
418
|
|
|
406
419
|
configs.push({
|
|
407
420
|
name: '@bfra.me/markdown/code-blocks/yaml',
|
|
408
421
|
files: GLOB_MARKDOWN_FILES.map(p => `${p}/${GLOB_YAML}`),
|
|
409
|
-
|
|
422
|
+
...(languageSetup ? {language: languageSetup.language} : {}),
|
|
423
|
+
...(parserSetup ? {languageOptions: parserSetup.languageOptions} : {}),
|
|
424
|
+
...(languageSetup && 'plugins' in languageSetup ? {plugins: languageSetup.plugins} : {}),
|
|
410
425
|
rules: {
|
|
411
426
|
// Examples may show incomplete YAML mappings to focus on specific concepts
|
|
412
427
|
'yml/no-empty-mapping-value': 'off',
|
package/src/configs/pnpm.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {Linter} from 'eslint'
|
|
2
1
|
import type {Config} from '../config'
|
|
3
2
|
import {requireOf} from '../require-of'
|
|
4
3
|
import {interopDefault} from '../utils'
|
|
@@ -18,12 +17,51 @@ export async function pnpm(): Promise<Config[]> {
|
|
|
18
17
|
interopDefault(import('eslint-plugin-yml')),
|
|
19
18
|
])
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const jsoncBaseConfigs = (pluginJsonc.configs['flat/base'] ??
|
|
21
|
+
pluginJsonc.configs.base) as unknown as Config[] | Config | undefined
|
|
22
|
+
const yamlBaseConfigs = (pluginYaml.configs.standard ??
|
|
23
|
+
pluginYaml.configs['flat/standard']) as unknown as Config[] | Config | undefined
|
|
24
|
+
|
|
25
|
+
const jsoncConfigs = Array.isArray(jsoncBaseConfigs)
|
|
26
|
+
? jsoncBaseConfigs
|
|
27
|
+
: jsoncBaseConfigs
|
|
28
|
+
? [jsoncBaseConfigs]
|
|
29
|
+
: []
|
|
30
|
+
const yamlConfigs = Array.isArray(yamlBaseConfigs)
|
|
31
|
+
? yamlBaseConfigs
|
|
32
|
+
: yamlBaseConfigs
|
|
33
|
+
? [yamlBaseConfigs]
|
|
34
|
+
: []
|
|
35
|
+
|
|
36
|
+
const configs: Config[] = []
|
|
37
|
+
|
|
38
|
+
const jsoncLanguageSetup = jsoncConfigs.find(
|
|
39
|
+
(config): config is Config & {language: string} =>
|
|
40
|
+
config != null && typeof config === 'object' && 'language' in config,
|
|
41
|
+
)
|
|
42
|
+
const jsoncParserSetup = jsoncConfigs.find(
|
|
43
|
+
(config): config is Config & {languageOptions: Record<string, unknown>} =>
|
|
44
|
+
config != null &&
|
|
45
|
+
typeof config === 'object' &&
|
|
46
|
+
'languageOptions' in config &&
|
|
47
|
+
config.languageOptions != null,
|
|
48
|
+
)
|
|
49
|
+
const jsoncPluginSetup = jsoncConfigs.find(
|
|
50
|
+
(config): config is Config & {plugins: Record<string, unknown>} =>
|
|
51
|
+
config != null &&
|
|
52
|
+
typeof config === 'object' &&
|
|
53
|
+
'plugins' in config &&
|
|
54
|
+
config.plugins != null,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
if (jsoncLanguageSetup ?? jsoncParserSetup ?? jsoncPluginSetup) {
|
|
58
|
+
configs.push({
|
|
23
59
|
name: '@bfra.me/pnpm/package-json',
|
|
24
60
|
files: ['package.json', '**/package.json'],
|
|
25
|
-
|
|
61
|
+
...(jsoncLanguageSetup ? {language: jsoncLanguageSetup.language} : {}),
|
|
62
|
+
...(jsoncParserSetup ? {languageOptions: jsoncParserSetup.languageOptions} : {}),
|
|
26
63
|
plugins: {
|
|
64
|
+
...(jsoncPluginSetup?.plugins ?? {}),
|
|
27
65
|
pnpm: pluginPnpm,
|
|
28
66
|
},
|
|
29
67
|
rules: {
|
|
@@ -31,20 +69,46 @@ export async function pnpm(): Promise<Config[]> {
|
|
|
31
69
|
'pnpm/json-prefer-workspace-settings': 'error',
|
|
32
70
|
'pnpm/json-valid-catalog': 'error',
|
|
33
71
|
},
|
|
34
|
-
}
|
|
35
|
-
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const yamlLanguageSetup = yamlConfigs.find(
|
|
76
|
+
(config): config is Config & {language: string} =>
|
|
77
|
+
config != null && typeof config === 'object' && 'language' in config,
|
|
78
|
+
)
|
|
79
|
+
const yamlParserSetup = yamlConfigs.find(
|
|
80
|
+
(config): config is Config & {languageOptions: Record<string, unknown>} =>
|
|
81
|
+
config != null &&
|
|
82
|
+
typeof config === 'object' &&
|
|
83
|
+
'languageOptions' in config &&
|
|
84
|
+
config.languageOptions != null,
|
|
85
|
+
)
|
|
86
|
+
const yamlPluginSetup = yamlConfigs.find(
|
|
87
|
+
(config): config is Config & {plugins: Record<string, unknown>} =>
|
|
88
|
+
config != null &&
|
|
89
|
+
typeof config === 'object' &&
|
|
90
|
+
'plugins' in config &&
|
|
91
|
+
config.plugins != null,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
if (yamlLanguageSetup ?? yamlParserSetup ?? yamlPluginSetup) {
|
|
95
|
+
configs.push({
|
|
36
96
|
name: '@bfra.me/pnpm/pnpm-workspace-yaml',
|
|
37
97
|
files: ['pnpm-workspace.yaml'],
|
|
38
|
-
|
|
98
|
+
...(yamlLanguageSetup ? {language: yamlLanguageSetup.language} : {}),
|
|
99
|
+
...(yamlParserSetup ? {languageOptions: yamlParserSetup.languageOptions} : {}),
|
|
39
100
|
plugins: {
|
|
101
|
+
...(yamlPluginSetup?.plugins ?? {}),
|
|
40
102
|
pnpm: pluginPnpm,
|
|
41
103
|
},
|
|
42
104
|
rules: {
|
|
43
105
|
'pnpm/yaml-no-duplicate-catalog-item': 'error',
|
|
44
106
|
'pnpm/yaml-no-unused-catalog-item': 'error',
|
|
45
107
|
},
|
|
46
|
-
}
|
|
47
|
-
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return configs
|
|
48
112
|
},
|
|
49
113
|
fallback,
|
|
50
114
|
)
|
package/src/configs/prettier.ts
CHANGED
|
@@ -7,6 +7,25 @@ import {requireOf} from '../require-of'
|
|
|
7
7
|
import {interopDefault} from '../utils'
|
|
8
8
|
import {fallback} from './fallback'
|
|
9
9
|
|
|
10
|
+
function getConfigRules(configs: unknown): OptionsOverrides['overrides'] | undefined {
|
|
11
|
+
if (Array.isArray(configs)) {
|
|
12
|
+
const configWithRules = [...(configs as unknown[])]
|
|
13
|
+
.reverse()
|
|
14
|
+
.find(
|
|
15
|
+
(config): config is Config =>
|
|
16
|
+
typeof config === 'object' && config !== null && 'rules' in config,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
return configWithRules?.rules
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (typeof configs === 'object' && configs !== null && 'rules' in configs) {
|
|
23
|
+
return (configs as Config).rules
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return undefined
|
|
27
|
+
}
|
|
28
|
+
|
|
10
29
|
/**
|
|
11
30
|
* Represents the options for the ESLint Prettier configuration.
|
|
12
31
|
*/
|
|
@@ -34,6 +53,8 @@ export async function prettier(options: PrettierOptions = {}): Promise<Config[]>
|
|
|
34
53
|
? interopDefault(import('eslint-plugin-yml'))
|
|
35
54
|
: Promise.resolve(undefined),
|
|
36
55
|
])
|
|
56
|
+
const jsoncPrettierRules = getConfigRules(pluginJsonc?.configs.prettier)
|
|
57
|
+
const yamlPrettierRules = getConfigRules(pluginYaml?.configs.prettier)
|
|
37
58
|
|
|
38
59
|
return [
|
|
39
60
|
{
|
|
@@ -46,7 +67,7 @@ export async function prettier(options: PrettierOptions = {}): Promise<Config[]>
|
|
|
46
67
|
|
|
47
68
|
...configPrettier.rules,
|
|
48
69
|
|
|
49
|
-
...(
|
|
70
|
+
...(jsoncPrettierRules ?? {}),
|
|
50
71
|
|
|
51
72
|
'toml/array-bracket-newline': 'off',
|
|
52
73
|
'toml/array-bracket-spacing': 'off',
|
|
@@ -56,7 +77,7 @@ export async function prettier(options: PrettierOptions = {}): Promise<Config[]>
|
|
|
56
77
|
'toml/key-spacing': 'off',
|
|
57
78
|
'toml/table-bracket-spacing': 'off',
|
|
58
79
|
|
|
59
|
-
...(
|
|
80
|
+
...(yamlPrettierRules ?? {}),
|
|
60
81
|
|
|
61
82
|
...overrides,
|
|
62
83
|
},
|
package/src/configs/react.ts
CHANGED
|
@@ -82,7 +82,7 @@ export async function react(options: ReactOptions = {}): Promise<Config[]> {
|
|
|
82
82
|
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
83
83
|
interopDefault(import('@eslint-react/eslint-plugin')),
|
|
84
84
|
interopDefault(import('eslint-plugin-react-hooks')),
|
|
85
|
-
|
|
85
|
+
import('eslint-plugin-react-refresh').then(m => m.reactRefresh),
|
|
86
86
|
] as const)
|
|
87
87
|
|
|
88
88
|
const plugins = (pluginReact.configs.all as {plugins: Record<string, Plugin>}).plugins
|
|
@@ -102,7 +102,7 @@ export async function react(options: ReactOptions = {}): Promise<Config[]> {
|
|
|
102
102
|
'react-hooks': pluginReactHooks,
|
|
103
103
|
'react-hooks-extra': plugins['@eslint-react/hooks-extra'],
|
|
104
104
|
'react-naming-convention': plugins['@eslint-react/naming-convention'],
|
|
105
|
-
'react-refresh': pluginReactRefresh,
|
|
105
|
+
'react-refresh': pluginReactRefresh.plugin,
|
|
106
106
|
'react-web-api': plugins['@eslint-react/web-api'],
|
|
107
107
|
} as Config['plugins'],
|
|
108
108
|
},
|
package/src/configs/toml.ts
CHANGED
|
@@ -22,7 +22,7 @@ export async function toml(options: TomlOptions = {}): Promise<Config[]> {
|
|
|
22
22
|
const pluginToml = await interopDefault(import('eslint-plugin-toml'))
|
|
23
23
|
|
|
24
24
|
return [
|
|
25
|
-
...(pluginToml.configs
|
|
25
|
+
...(pluginToml.configs.standard as Config[]).map((config: Config, index) => ({
|
|
26
26
|
...config,
|
|
27
27
|
name: config.plugins
|
|
28
28
|
? `@bfra.me/toml/plugins`
|