Skip to content

Commit

Permalink
Work around false js/useless-assignment-to-local violation from CodeQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Dec 6, 2024
1 parent 2449163 commit 0555962
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

## 0.37.0

- Convert to ECMAScript module, for guidance see:
- Convert module to ECMAScript (breaking change)
- <https://nodejs.org/docs/latest/api/esm.html>
- <https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c>
- Convert module to named exports (breaking change)

## 0.36.1

Expand Down
20 changes: 11 additions & 9 deletions test/markdownlint-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1386,17 +1386,19 @@ test("exportMappings", (t) => {
);
});

// const commonJsRe = /\.js$/u;
const jsonRe = /\.json$/u;
const importOptionsJson = { "with": { "type": "json" } };

const makeExportMappingTest = (exportName, exportPath) => async(t) => {
const json = jsonRe.test(exportPath);
const importOptions = json ? importOptionsJson : undefined;
const [ importExportName, importExportPath ] = await Promise.all([
import(exportName.replace(/^\./u, packageJson.name), importOptions),
import(exportPath, importOptions)
]);
t.is(importExportName, importExportPath);
};

for (const [ exportName, exportPath ] of exportMappings) {
test(exportName, async(t) => {
// const commonJs = !commonJsRe.test(exportPath);
const json = jsonRe.test(exportPath);
const importOptions = json ? importOptionsJson : undefined;
const importExportName = await import(exportName.replace(/^\./u, packageJson.name), importOptions);
const importExportPath = await import(exportPath, importOptions);
t.is(importExportName, importExportPath);
});
test(exportName, makeExportMappingTest(exportName, exportPath));
}

0 comments on commit 0555962

Please sign in to comment.