Skip to content

Commit

Permalink
🐛 fix(eslint-config): testing on windows
Browse files Browse the repository at this point in the history
Signed-off-by: Pauline <[email protected]>
  • Loading branch information
pauliesnug committed Sep 7, 2024
1 parent ed1200e commit e75c77c
Show file tree
Hide file tree
Showing 95 changed files with 804 additions and 382 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@types/node": "^22.5.4",
"bumpp": "^9.5.2",
"esbuild": "^0.23.1",
"eslint": "^9.9.1",
"eslint": "^9.10.0",
"jiti": "^1.21.6",
"tsup": "^8.2.4",
"tsx": "^4.19.0",
Expand Down
5 changes: 2 additions & 3 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
"@clack/prompts": "^0.7.0",
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
"@eslint/compat": "^1.1.1",
"@eslint/markdown": "^6.1.0",
"@stylistic/eslint-plugin": "^2.7.2",
"@typescript-eslint/eslint-plugin": "^8.4.0",
"@typescript-eslint/parser": "^8.4.0",
Expand All @@ -146,7 +147,6 @@
"eslint-plugin-import-x": "^4.2.1",
"eslint-plugin-jsdoc": "^50.2.2",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-markdown": "^5.1.0",
"eslint-plugin-n": "^17.10.2",
"eslint-plugin-perfectionist": "^3.4.0",
"eslint-plugin-petal": "workspace:^",
Expand All @@ -169,12 +169,11 @@
"@tanstack/eslint-plugin-query": "^5.53.0",
"@types/eslint": "^9.6.1",
"@types/eslint-plugin-jsx-a11y": "^6.9.0",
"@types/eslint-plugin-markdown": "^2.0.2",
"@types/fs-extra": "^11.0.4",
"@types/prompts": "^2.4.9",
"@unocss/eslint-plugin": "^0.62.3",
"astro-eslint-parser": "^1.0.2",
"eslint": "^9.9.1",
"eslint": "^9.10.0",
"eslint-plugin-astro": "^1.2.3",
"eslint-plugin-format": "^0.1.2",
"eslint-plugin-json-schema-validator": "^5.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config/src/configs/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { OptionsMarkdown, TypedFlatConfigItem } from '../types';

export async function markdown(options: OptionsMarkdown = {}): Promise<TypedFlatConfigItem[]> {
const { componentExts = [], files = [GLOB_MARKDOWN], overrides = {} } = options;
const pluginMarkdown = await interopDefault(import('eslint-plugin-markdown'));
const pluginMarkdown = await interopDefault(import('@eslint/markdown'));

return [
{
Expand All @@ -18,7 +18,7 @@ export async function markdown(options: OptionsMarkdown = {}): Promise<TypedFlat
files,
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
name: 'petal/markdown/processor',
// `eslint-plugin-markdown` only creates virtual files for code blocks,
// `@eslint/markdown` only creates virtual files for code blocks,
// but not the markdown file itself. we use `eslint-merge-processors` to
// add a pass-through processor for the markdown file itself.
processor: mergeProcessors([
Expand Down
28 changes: 16 additions & 12 deletions packages/eslint-config/test/fixtures.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { join, resolve } from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import { execa } from 'execa';
import fg from 'fast-glob';
import fs from 'fs-extra';
import { join, resolve } from 'pathe';
import { afterAll, beforeAll, it } from 'vitest';
import type { OptionsConfig, TypedFlatConfigItem } from '../src/types';

beforeAll(async () => await fs.rm('./packages/eslint-config/_fixtures', { recursive: true, force: true }));
afterAll(async () => await fs.rm('./packages/eslint-config/_fixtures', { recursive: true, force: true }));
const fixturesDir = fileURLToPath(new URL('fixtures', import.meta.url));
const outputDir = fileURLToPath(new URL('_fixtures', import.meta.url));

beforeAll(async () => await fs.rm(outputDir, { recursive: true, force: true }));
afterAll(async () => await fs.rm(outputDir, { recursive: true, force: true }));

runWithConfig`js` ({
typescript: false,
Expand Down Expand Up @@ -91,11 +95,11 @@ runWithConfig`no-markdown-with-formatters` ({
});

function runWithConfig(name: TemplateStringsArray) {
return (configs: OptionsConfig, ...items: TypedFlatConfigItem[]) => {
return (configs: OptionsConfig = {}, ...items: TypedFlatConfigItem[]) => {
it.concurrent(name[0], async ({ expect }) => {
const from = resolve('./packages/eslint-config/fixtures/input');
const output = resolve('./packages/eslint-config/fixtures/output', name[0]);
const target = resolve('./packages/eslint-config/_fixtures', name[0]);
const from = resolve(fixturesDir, 'input');
const output = resolve(fixturesDir, 'output', name[0]);
const target = resolve(outputDir, name[0]);

await fs.copy(from, target, { filter: src => !src.includes('node_modules') });
await fs.writeFile(join(target, 'eslint.config.js'), `
Expand All @@ -109,8 +113,8 @@ export default defineConfig(
`, 'utf-8');

if (process.platform === 'win32')
await execa({ stdio: 'pipe', cwd: target })`npx eslint . --fix`;
else await execa({ stdio: 'pipe', cwd: target })`pnpm -c dlx eslint --config ./eslint.config.js . --fix`;
await execa({ stdio: 'pipe', cwd: target })`npx eslint . --config ${target}\\eslint.config.js --fix`;
else await execa({ stdio: 'pipe', cwd: target })`pnpm -c dlx eslint --config ${target}/eslint.config.js . --fix`;

const files = await fg('**/*', {
ignore: [
Expand All @@ -130,10 +134,10 @@ export default defineConfig(
if (content === source) {
if (fs.existsSync(outputPath))
await fs.remove(outputPath);
return;
}

await expect.soft(content).toMatchFileSnapshot(outputPath);
else {
await expect.soft(content).toMatchFileSnapshot(outputPath);
}
}));
}, 80_000);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"devDependencies": {
"@types/eslint": "^9.6.1",
"@typescript-eslint/utils": "^8.4.0",
"eslint": "^9.9.1",
"eslint": "^9.10.0",
"eslint-vitest-rule-tester": "^0.6.1",
"jsonc-eslint-parser": "^2.4.0"
},
Expand Down
Loading

0 comments on commit e75c77c

Please sign in to comment.