Skip to content

Commit 90236af

Browse files
committed
chore: move eslint-doc-generator config to ESM
1 parent d5dbad4 commit 90236af

File tree

5 files changed

+65
-70
lines changed

5 files changed

+65
-70
lines changed

.eslint-doc-generatorrc.cjs

Lines changed: 0 additions & 19 deletions
This file was deleted.

.eslint-doc-generatorrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as prettier from 'prettier';
2+
3+
/** @type {import('eslint-doc-generator').GenerateOptions} */
4+
export default {
5+
ignoreConfig: [
6+
'flat/angular',
7+
'flat/dom',
8+
'flat/marko',
9+
'flat/react',
10+
'flat/svelte',
11+
'flat/vue',
12+
],
13+
postprocess: async (content, path) => {
14+
const prettierConfig = await prettier.resolveConfig(path);
15+
return prettier.format(content, { ...prettierConfig, parser: 'markdown' });
16+
},
17+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"@vitest/ui": "3.2.4",
6868
"eslint": "^9.35.0",
6969
"eslint-config-prettier": "^10.1.8",
70-
"eslint-doc-generator": "^2.2.2",
70+
"eslint-doc-generator": "^2.4.0",
7171
"eslint-import-resolver-typescript": "^4.4.4",
7272
"eslint-plugin-import-x": "^4.16.1",
7373
"eslint-plugin-node": "^11.1.0",

pnpm-lock.yaml

Lines changed: 44 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/generate-configs/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import type { TSESLint } from '@typescript-eslint/utils';
77

88
const __dirname = new URL('.', import.meta.url).pathname;
99

10-
const prettierConfig = prettier.resolveConfig(__dirname);
11-
1210
const addAutoGeneratedComment = (code: string) =>
1311
[
1412
'// THIS CODE WAS AUTOMATICALLY GENERATED',
@@ -25,14 +23,15 @@ export const writeConfig = async (
2523
config: TSESLint.Linter.ConfigType,
2624
configName: string
2725
): Promise<void> => {
28-
// note: we use `export =` because ESLint will import these configs via a commonjs import
2926
const code = `import type { Linter } from 'eslint';
3027
3128
export default ${JSON.stringify(config)} satisfies Linter.LegacyConfig;
3229
`;
30+
31+
const prettierConfig = await prettier.resolveConfig(__dirname);
3332
const configStr = await prettier.format(addAutoGeneratedComment(code), {
3433
parser: 'typescript',
35-
...(await prettierConfig),
34+
...prettierConfig,
3635
});
3736
const filePath = resolve(__dirname, `../../lib/configs/${configName}.ts`);
3837

0 commit comments

Comments
 (0)