Skip to content

Commit

Permalink
Convert to an ECMAScript module.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Dec 13, 2024
1 parent c2d7244 commit ddd2269
Show file tree
Hide file tree
Showing 80 changed files with 499 additions and 505 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
markdownlint-cli2.js eol=lf
markdownlint-cli2-bin.mjs eol=lf
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- name: Install markdownlint-cli2 dependencies locally
run: sudo npm install --no-package-lock --production
- name: Lint with formatters
run: node ./markdownlint-cli2 CONTRIBUTING.md README.md
run: node ./markdownlint-cli2-bin.mjs CONTRIBUTING.md README.md

lint-dockerfile:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sarif.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: npm install --no-package-lock
- run: node markdownlint-cli2.js --config .github/sarif.markdownlint-cli2.jsonc '**/README.md' '#node_modules'
- run: node markdownlint-cli2-bin.mjs --config .github/sarif.markdownlint-cli2.jsonc '**/README.md' '#node_modules'
continue-on-error: true
- uses: github/codeql-action/upload-sarif@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ npm-debug.log
!test/customRules/node_modules
!test/markdownItPlugins/module/node_modules
!test/outputFormatters-module/node_modules
webworker/markdownlint-cli2-webworker.js
webworker/setImmediate.js
webworker/markdownlint-cli2-webworker.cjs
webworker/setImmediate.cjs
5 changes: 1 addition & 4 deletions append-to-array.js → append-to-array.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @ts-check

"use strict";

const sliceSize = 1000;

/**
Expand All @@ -21,5 +19,4 @@ const appendToArray = (destination, source) => {
}
};

appendToArray.sliceSize = sliceSize;
module.exports = appendToArray;
export { appendToArray as default, sliceSize };
2 changes: 1 addition & 1 deletion doc/OutputFormatters.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ For a `.markdownlint-cli2.jsonc` like:
[formatter-junit]: ../formatter-junit/markdownlint-cli2-formatter-junit.js
[formatter-sarif]: ../formatter-sarif/markdownlint-cli2-formatter-sarif.js
[markdownlint-cli2-formatter]: https://www.npmjs.com/search?q=keywords:markdownlint-cli2-formatter
[markdownlint-d-ts]: https://github.com/DavidAnson/markdownlint/blob/v0.36.1/lib/markdownlint.d.ts
[markdownlint-d-ts]: https://github.com/DavidAnson/markdownlint/blob/v0.37.0/lib/markdownlint.d.mts
22 changes: 14 additions & 8 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ export default [
{
"ignores": [
"test/*/**",
"webworker/markdownlint-cli2-webworker.js",
"webworker/setImmediate.js"
"webworker/markdownlint-cli2-webworker.cjs",
"webworker/setImmediate.cjs"
]
},
{
"languageOptions": {
"sourceType": "commonjs"
},
"linterOptions": {
"reportUnusedDisableDirectives": true
},
Expand Down Expand Up @@ -60,18 +57,27 @@ export default [
"@stylistic/padded-blocks": "off",

"unicorn/no-null": "off",
"unicorn/prefer-module": "off",
"unicorn/prefer-string-raw": "off",
"unicorn/prefer-string-replace-all": "off",
"unicorn/prevent-abbreviations": "off"
}
},
{
"files": [
"**/*.mjs"
"**/*-formatter-*.js",
"webworker/*.cjs"
],
"languageOptions": {
"sourceType": "module"
"sourceType": "commonjs",
"globals": {
"__dirname": "readonly",
"__filename": "readonly",
"module": "readonly",
"require": "readonly"
}
},
"rules": {
"unicorn/prefer-module": "off"
}
}
];
5 changes: 0 additions & 5 deletions export-markdownlint-helpers.js

This file was deleted.

3 changes: 3 additions & 0 deletions export-markdownlint-helpers.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @ts-check

export { default } from "markdownlint/helpers";
3 changes: 3 additions & 0 deletions export-markdownlint-promise.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @ts-check

export * from "markdownlint/promise";
5 changes: 0 additions & 5 deletions export-markdownlint.js

This file was deleted.

3 changes: 3 additions & 0 deletions export-markdownlint.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @ts-check

export * from "markdownlint";
16 changes: 16 additions & 0 deletions markdownlint-cli2-bin.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env node

import { "main" as markdownlintCli2 } from "./markdownlint-cli2.mjs";

const params = {
"argv": process.argv.slice(2),
"logMessage": console.log,
"logError": console.error,
"allowStdin": true
};
try {
process.exitCode = await markdownlintCli2(params);
} catch (error) {
console.error(error);
process.exitCode = 2;
}
Loading

0 comments on commit ddd2269

Please sign in to comment.