Skip to content

Commit 23dc0c6

Browse files
authored
chore: simplify package.json import and add cjs import type test (#634)
* test: simplify `package.json` import and add cjs import type test * wip
1 parent 493de5d commit 23dc0c6

5 files changed

Lines changed: 14 additions & 20 deletions

File tree

knip.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://unpkg.com/knip@5/schema.json",
33
"workspaces": {
44
".": {
5-
"entry": ["tests/**/*.test.{js,ts}", "tests/fixtures/*.js"],
5+
"entry": ["tests/**/*.test.{js,ts,cts}", "tests/fixtures/*.js"],
66
"project": ["**"],
77
"ignore": ["src/types.ts"]
88
},

tests/plugin.test.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,12 @@ import { fileURLToPath, pathToFileURL } from "node:url";
1414
import { ESLint } from "eslint";
1515
import { LegacyESLint } from "eslint-v9/use-at-your-own-risk";
1616
import plugin from "../src/index.js";
17+
import pkg from "../package.json" with { type: "json" };
1718

1819
const __filename = fileURLToPath(import.meta.url);
1920
const __dirname = path.dirname(__filename);
2021
const rulesDir = path.resolve(__dirname, "../src/rules");
2122

22-
//-----------------------------------------------------------------------------
23-
// Data
24-
//-----------------------------------------------------------------------------
25-
26-
const pkg = JSON.parse(
27-
fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf8"),
28-
);
29-
3023
//-----------------------------------------------------------------------------
3124
// Helpers
3225
//-----------------------------------------------------------------------------

tests/processor.test.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,13 @@
88
//-----------------------------------------------------------------------------
99

1010
import assert from "node:assert";
11-
import path from "node:path";
1211
import { processor } from "../src/processor.js";
13-
import fs from "node:fs";
14-
import { fileURLToPath } from "node:url";
15-
16-
const __filename = fileURLToPath(import.meta.url);
17-
const __dirname = path.dirname(__filename);
12+
import pkg from "../package.json" with { type: "json" };
1813

1914
//-----------------------------------------------------------------------------
2015
// Data
2116
//-----------------------------------------------------------------------------
2217

23-
const pkg = JSON.parse(
24-
fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf8"),
25-
);
26-
2718
const BOM = "\uFEFF";
2819

2920
//-----------------------------------------------------------------------------

tests/types/cjs-import.test.cts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @fileoverview CommonJS type import test for ESLint Markdown Language Plugin.
3+
* @author 루밀LuMir(lumirlumir)
4+
*/
5+
6+
//-----------------------------------------------------------------------------
7+
// Imports
8+
//-----------------------------------------------------------------------------
9+
10+
import "@eslint/markdown";

tests/types/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"exactOptionalPropertyTypes": true
99
},
1010
"files": [],
11-
"include": ["**/*.test.ts", "../../dist"]
11+
"include": ["**/*.test.ts", "**/*.test.cts", "../../dist"]
1212
}

0 commit comments

Comments
 (0)