Skip to content

Commit

Permalink
🐛 fix(config/test): try to fix config test
Browse files Browse the repository at this point in the history
  • Loading branch information
pauliesnug committed May 25, 2024
1 parent a782854 commit f30293e
Show file tree
Hide file tree
Showing 6 changed files with 504 additions and 440 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"@stylistic/eslint-plugin-migrate": "^2.1.0",
"@types/node": "^20.12.12",
"bumpp": "^9.4.1",
"esbuild": "^0.21.3",
"esbuild": "^0.21.4",
"eslint": "npm:eslint-ts-patch@9.2.0-6",
"esno": "^4.7.0",
"rimraf": "^5.0.7",
"rollup": "^4.17.2",
"rollup": "^4.18.0",
"tsup": "^8.0.2",
"typescript": "^5.4.5",
"unbuild": "^2.0.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@
"eslint-plugin-command": "^0.2.3",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import-x": "^0.5.0",
"eslint-plugin-jsdoc": "^48.2.5",
"eslint-plugin-jsonc": "^2.15.1",
"eslint-plugin-jsdoc": "^48.2.6",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-markdown": "^5.0.0",
"eslint-plugin-n": "^17.7.0",
"eslint-plugin-no-only-tests": "^3.1.0",
Expand All @@ -130,7 +130,7 @@
"eslint-plugin-regexp": "^2.6.0",
"eslint-plugin-toml": "^0.11.0",
"eslint-plugin-unicorn": "^53.0.0",
"eslint-plugin-unused-imports": "^3.2.0",
"eslint-plugin-unused-imports": "^4.0.0",
"eslint-plugin-vitest": "0.5.4",
"eslint-plugin-vue": "^9.26.0",
"eslint-plugin-yml": "^1.14.0",
Expand All @@ -141,7 +141,7 @@
"toml-eslint-parser": "^0.9.3",
"typescript": "^5.4.5",
"vue-eslint-parser": "^9.4.2",
"yaml-eslint-parser": "^1.2.2"
"yaml-eslint-parser": "^1.2.3"
},
"devDependencies": {
"@eslint-react/eslint-plugin": "^1.5.12",
Expand All @@ -151,7 +151,7 @@
"@types/fs-extra": "^11.0.4",
"@unocss/eslint-plugin": "^0.60.3",
"astro-eslint-parser": "^1.0.2",
"eslint": "^9.3.0",
"eslint": "npm:eslint-ts-patch@9.2.0-6",
"eslint-plugin-astro": "^1.2.0",
"eslint-plugin-format": "^0.1.1",
"eslint-plugin-react-hooks": "^4.6.2",
Expand All @@ -162,7 +162,7 @@
"execa": "^9.1.0",
"fast-glob": "^3.3.2",
"fs-extra": "^11.2.0",
"prettier-plugin-astro": "^0.13.0",
"prettier-plugin-astro": "^0.14.0",
"prettier-plugin-slidev": "^1.0.5",
"svelte": "^4.2.17",
"svelte-eslint-parser": "^0.36.0",
Expand Down
24 changes: 18 additions & 6 deletions packages/eslint-config/test/fixtures.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { join, resolve } from 'node:path';
import { afterAll, beforeAll, it } from 'vitest';
import fs from 'fs-extra';
import { execa } from 'execa';
import fg from 'fast-glob';
import type { OptionsConfig, TypedFlatConfigItem } from '../src/types';

beforeAll(async () => {
await fs.rm('packages/eslint-config/_fixtures', { recursive: true, force: true });
await fs.rm('_fixtures', { recursive: true, force: true });
});

afterAll(async () => {
await fs.rm('packages/eslint-config/_fixtures', { recursive: true, force: true });
await fs.rm('_fixtures', { recursive: true, force: true });
});

runWithConfig('js', {
Expand Down Expand Up @@ -83,9 +84,9 @@ runWithConfig(

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

await fs.copy(from, target, {
filter: (src) => {
Expand All @@ -101,7 +102,17 @@ export default petal(
...${JSON.stringify(items) ?? []},
)
`);
await execa('pnpx', ['eslint', '.', '--fix'], {

await execa('pnpm', [
'dlx',
'--package',
'eslint',
'eslint',
'--config',
'./eslint.config.js',
'.',
'--fix',
], {
cwd: target,
stdio: 'pipe',
});
Expand All @@ -110,6 +121,7 @@ export default petal(
ignore: [
'node_modules',
'eslint.config.js',
'eslint.config.ts',
],
cwd: target,
});
Expand Down
17 changes: 17 additions & 0 deletions packages/eslint-plugin/src/rules/no-import-dist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# no-import-dist

Prevent importing modules in `dist` folder.

## Rule Details

<!-- eslint-skip -->
```js
// 👎 bad
import { Foo, Bar, Foo } from '../dist/index.js';
```

<!-- eslint-skip -->
```js
// 👍 good
import { Foo, Bar } from './index.ts';
```
Loading

0 comments on commit f30293e

Please sign in to comment.