@alauda/doom 2.5.3 → 2.5.4
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/eslint.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import { createRequire } from 'node:module';
|
|
3
|
+
import path from 'node:path';
|
|
2
4
|
import { fileURLToPath } from 'node:url';
|
|
3
5
|
import cspellRecommended from '@cspell/eslint-plugin/recommended';
|
|
4
6
|
import js from '@eslint/js';
|
|
@@ -9,14 +11,33 @@ import * as mdx from 'eslint-plugin-mdx';
|
|
|
9
11
|
import globals from 'globals';
|
|
10
12
|
import tseslint from 'typescript-eslint';
|
|
11
13
|
import { loadConfig } from './cli/load-config.js';
|
|
14
|
+
import { getGlobalComponentNames } from './plugins/global/components.js';
|
|
15
|
+
import { pkgResolve } from './utils/index.js';
|
|
12
16
|
const cjsRequire = createRequire(import.meta.url);
|
|
13
17
|
let remarkConfigPath;
|
|
18
|
+
const isLoadableRemarkConfigPath = (filepath) => ['.cjs', '.js', '.mjs'].includes(path.extname(filepath));
|
|
14
19
|
try {
|
|
15
|
-
|
|
20
|
+
const resolvedRemarkConfigPath = fileURLToPath(import.meta.resolve('./remarkrc.js'));
|
|
21
|
+
if (isLoadableRemarkConfigPath(resolvedRemarkConfigPath)) {
|
|
22
|
+
remarkConfigPath = resolvedRemarkConfigPath;
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
25
|
catch {
|
|
18
|
-
|
|
26
|
+
try {
|
|
27
|
+
const resolvedRemarkConfigPath = cjsRequire.resolve('./remarkrc.js');
|
|
28
|
+
if (isLoadableRemarkConfigPath(resolvedRemarkConfigPath)) {
|
|
29
|
+
remarkConfigPath = resolvedRemarkConfigPath;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
remarkConfigPath = undefined;
|
|
34
|
+
}
|
|
19
35
|
}
|
|
36
|
+
const builtRemarkConfigPath = pkgResolve('lib/remarkrc.js');
|
|
37
|
+
if (!remarkConfigPath && fs.existsSync(builtRemarkConfigPath)) {
|
|
38
|
+
remarkConfigPath = builtRemarkConfigPath;
|
|
39
|
+
}
|
|
40
|
+
const globalComponentGlobals = Object.fromEntries(getGlobalComponentNames().map((name) => [name, 'readonly']));
|
|
20
41
|
async function doom(userConfigOrRoot) {
|
|
21
42
|
let cspellOptions;
|
|
22
43
|
let config;
|
|
@@ -53,7 +74,7 @@ async function doom(userConfigOrRoot) {
|
|
|
53
74
|
languageOptions: {
|
|
54
75
|
globals: globals.browser,
|
|
55
76
|
parserOptions: {
|
|
56
|
-
remarkConfigPath,
|
|
77
|
+
...(remarkConfigPath && { remarkConfigPath }),
|
|
57
78
|
},
|
|
58
79
|
},
|
|
59
80
|
rules: cspellEnabled
|
|
@@ -67,6 +88,9 @@ async function doom(userConfigOrRoot) {
|
|
|
67
88
|
},
|
|
68
89
|
{
|
|
69
90
|
files: ['**/*.mdx'],
|
|
91
|
+
languageOptions: {
|
|
92
|
+
globals: globalComponentGlobals,
|
|
93
|
+
},
|
|
70
94
|
rules: {
|
|
71
95
|
'@eslint-react/jsx-no-children-prop': 'off',
|
|
72
96
|
'@eslint-react/rules-of-hooks': 'off',
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { baseResolve } from "../../utils/index.js";
|
|
4
|
+
const componentsDir = baseResolve('runtime/components');
|
|
5
|
+
const isGlobalComponentFile = (file) => {
|
|
6
|
+
const basename = path.basename(file, path.extname(file));
|
|
7
|
+
return (!basename.startsWith('_') &&
|
|
8
|
+
!basename.endsWith('.d') &&
|
|
9
|
+
basename !== 'index');
|
|
10
|
+
};
|
|
11
|
+
export const getGlobalComponentFiles = () => fs
|
|
12
|
+
.readdirSync(componentsDir)
|
|
13
|
+
.filter(isGlobalComponentFile)
|
|
14
|
+
.map((file) => path.resolve(componentsDir, file));
|
|
15
|
+
export const getGlobalComponentNames = () => fs
|
|
16
|
+
.readdirSync(componentsDir)
|
|
17
|
+
.filter(isGlobalComponentFile)
|
|
18
|
+
.map((file) => path.basename(file, path.extname(file)));
|
|
@@ -3,8 +3,8 @@ import path from 'node:path';
|
|
|
3
3
|
import { addTrailingSlash } from '@rspress/shared';
|
|
4
4
|
import { ACP_BASE } from "../../shared/index.js";
|
|
5
5
|
import { baseResolve, pkgResolve } from "../../utils/index.js";
|
|
6
|
+
import { getGlobalComponentFiles } from "./components.js";
|
|
6
7
|
const globalComponentsDir = baseResolve('global');
|
|
7
|
-
const componentsDir = baseResolve('runtime/components');
|
|
8
8
|
export const globalPlugin = ({ version, download, }) => {
|
|
9
9
|
return {
|
|
10
10
|
name: 'doom-global',
|
|
@@ -13,15 +13,7 @@ export const globalPlugin = ({ version, download, }) => {
|
|
|
13
13
|
.readdirSync(globalComponentsDir, 'utf8')
|
|
14
14
|
.map((component) => path.resolve(globalComponentsDir, component)),
|
|
15
15
|
markdown: {
|
|
16
|
-
globalComponents:
|
|
17
|
-
.readdirSync(componentsDir)
|
|
18
|
-
.filter((file) => {
|
|
19
|
-
const basename = path.basename(file, path.extname(file));
|
|
20
|
-
return (!basename.startsWith('_') &&
|
|
21
|
-
!basename.endsWith('.d') &&
|
|
22
|
-
basename !== 'index');
|
|
23
|
-
})
|
|
24
|
-
.map((file) => path.resolve(componentsDir, file)),
|
|
16
|
+
globalComponents: getGlobalComponentFiles(),
|
|
25
17
|
},
|
|
26
18
|
addRuntimeModules(config, isProd) {
|
|
27
19
|
return {
|