Skip to content

Commit 76915f6

Browse files
committed
Remove now-outdated esm-helpers.mjs file.
1 parent 23538d1 commit 76915f6

7 files changed

Lines changed: 25 additions & 46 deletions

demo/webpack.config.mjs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
import webpack from "webpack";
44
import TerserPlugin from "terser-webpack-plugin";
5-
import { importWithTypeJson } from "../test/esm-helpers.mjs";
6-
const libraryPackageJson = await importWithTypeJson(import.meta, "../package.json");
5+
import libraryPackageJson from "../package.json" with { "type": "json" };
76

8-
// eslint-disable-next-line jsdoc/require-jsdoc
9-
function config(options) {
7+
// eslint-disable-next-line jsdoc/require-jsdoc, jsdoc/reject-any-type
8+
function config(/** @type {any} */ options) {
109
const { entry, filename, mode, optimization, packageJson } = options;
1110
const { name, version, homepage, license } = packageJson;
1211
return {
@@ -21,7 +20,7 @@ function config(options) {
2120
"output": {
2221
"filename": filename,
2322
"library": {
24-
"name": name.replace(/(-\w)/g, (m) => m.slice(1).toUpperCase()),
23+
"name": name.replace(/(-\w)/g, (/** @type {string} */ m) => m.slice(1).toUpperCase()),
2524
"type": "var"
2625
},
2726
"path": import.meta.dirname

schema/build-config-example.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import fs from "node:fs/promises";
44
import path from "node:path";
55
import yaml from "js-yaml";
6-
import { importWithTypeJson } from "../test/esm-helpers.mjs";
7-
const configSchema = await importWithTypeJson(import.meta, "../schema/markdownlint-config-schema.json");
6+
import configSchema from "../schema/markdownlint-config-schema.json" with { "type": "json" };
87

98
/** @type {import("markdownlint").Configuration} */
109
const configExample = {};
1110
for (const rule in configSchema.properties) {
1211
if (/^(?:MD\d{3}|default|extends)$/.test(rule)) {
12+
// @ts-ignore
1313
const properties = configSchema.properties[rule];
1414
configExample[rule + "-description"] = properties.description;
1515
configExample[rule] = properties.default;

test/esm-helpers.mjs

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

test/markdownlint-test-custom-rules.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { lint as lintPromise } from "markdownlint/promise";
1010
import { lint as lintSync } from "markdownlint/sync";
1111
import customRules from "./rules/rules.cjs";
1212
import { newLineRe } from "../helpers/helpers.cjs";
13-
import { importWithTypeJson } from "./esm-helpers.mjs";
14-
const packageJson = await importWithTypeJson(import.meta, "../package.json");
13+
import packageJson from "../package.json" with { "type": "json" };
1514
const { homepage, version } = packageJson;
1615

1716
const markdownItFactory = () => markdownIt({ "html": true });

test/markdownlint-test-exports.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { createRequire } from "node:module";
44
const require = createRequire(import.meta.url);
55
import test from "ava";
66
import spawn from "nano-spawn";
7-
import { importWithTypeJson } from "./esm-helpers.mjs";
8-
const packageJson = await importWithTypeJson(import.meta, "../package.json");
7+
import packageJson from "../package.json" with { "type": "json" };
98

109
const exportMappings = new Map([
1110
[ ".", "../lib/exports.mjs" ],
@@ -47,6 +46,7 @@ for (const [ exportName, exportPath ] of exportMappings) {
4746

4847
test(`exported names`, async(t) => {
4948
t.plan(1);
49+
/** @type {Object.<string, string[]>} */
5050
const exportedNames = {};
5151
for (const [ exportName, exportPath ] of exportMappings) {
5252
const exportByName = exportName.replace(/^\./u, packageJson.name);

test/markdownlint-test-result-object.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { lint as lintAsync } from "markdownlint/async";
55
import { lint as lintPromise } from "markdownlint/promise";
66
import { lint as lintSync } from "markdownlint/sync";
77
import { convertToResultVersion0, convertToResultVersion1, convertToResultVersion2 } from "markdownlint/helpers";
8-
import { importWithTypeJson } from "./esm-helpers.mjs";
9-
const packageJson = await importWithTypeJson(import.meta, "../package.json");
8+
import packageJson from "../package.json" with { "type": "json" };
109
const { homepage, version } = packageJson;
1110

1211
test("resultObjectToStringNotEnumerable", (t) => new Promise((resolve) => {

test/markdownlint-test.mjs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ import * as cache from "../lib/cache.mjs";
2121
import * as constants from "../lib/constants.mjs";
2222
import rules from "../lib/rules.mjs";
2323
import customRules from "./rules/rules.cjs";
24-
import { importWithTypeJson } from "./esm-helpers.mjs";
2524
/** @type {{exports: Object.<string, string>, homepage: string, version: string}} */
26-
const packageJson = await importWithTypeJson(import.meta, "../package.json");
25+
import packageJson from "../package.json" with { "type": "json" };
2726
/** @type {{$id: string, properties: Object<string, Object>}} */
28-
const configSchema = await importWithTypeJson(import.meta, "../schema/markdownlint-config-schema.json");
29-
const configSchemaStrict = await importWithTypeJson(import.meta, "../schema/markdownlint-config-schema-strict.json");
27+
import configSchema from "../schema/markdownlint-config-schema.json" with { "type": "json" };
28+
import configSchemaStrict from "../schema/markdownlint-config-schema-strict.json" with { "type": "json" };
3029

3130
const deprecatedRuleNames = new Set(constants.deprecatedRuleNames);
3231
const ajvOptions = {
@@ -594,6 +593,7 @@ test("styleFiles", async(t) => {
594593
t.truthy(require(path.join("../style", file)), "Unable to load/parse.");
595594
const exportValue = `./style/${file}`;
596595
const exportKey = exportValue.replace(/\.json$/, "");
596+
// @ts-ignore
597597
t.is(packageJson.exports[exportKey], exportValue);
598598
}
599599
});
@@ -1449,16 +1449,18 @@ test("token-map-spans", (t) => {
14491449
);
14501450
for (const token of inlines) {
14511451
t.truthy(token.map);
1452-
for (let i = token.map[0]; i < token.map[1]; i++) {
1453-
if (tokenLines.includes(i)) {
1454-
t.true(
1455-
lastLineNumber === token.lineNumber,
1456-
`Line ${i + 1} is part of token maps from multiple lines.`
1457-
);
1458-
} else {
1459-
tokenLines.push(i);
1452+
if (token.map) {
1453+
for (let i = token.map[0]; i < token.map[1]; i++) {
1454+
if (tokenLines.includes(i)) {
1455+
t.true(
1456+
lastLineNumber === token.lineNumber,
1457+
`Line ${i + 1} is part of token maps from multiple lines.`
1458+
);
1459+
} else {
1460+
tokenLines.push(i);
1461+
}
1462+
lastLineNumber = token.lineNumber;
14601463
}
1461-
lastLineNumber = token.lineNumber;
14621464
}
14631465
}
14641466
}

0 commit comments

Comments
 (0)