Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Nov 22, 2024
1 parent 0335703 commit fe18768
Show file tree
Hide file tree
Showing 40 changed files with 14,917 additions and 59 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.mjs eol=lf
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.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
File renamed without changes.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default [
{
"files": [
"**/*-formatter-*.js",
"webworker/*.cjs",
"webworker/*.js"
],
"ignores": [
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions markdownlint-cli2.js → markdownlint-cli2.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const {
"readConfig": markdownlintReadConfig
} = markdownlintPromises;
import { expandTildePath } from "markdownlint/helpers";
import appendToArray from "./append-to-array.js";
import mergeOptions from "./merge-options.js";
import resolveAndRequire from "./resolve-and-require.js";
import appendToArray from "./append-to-array.mjs";
import mergeOptions from "./merge-options.mjs";
import resolveAndRequire from "./resolve-and-require.mjs";

// Variables
const packageName = "markdownlint-cli2";
Expand All @@ -42,15 +42,15 @@ const utf8 = "utf8";
const noop = () => null;

// Gets a JSONC parser
import jsoncParse from "./parsers/jsonc-parse.js";
import jsoncParse from "./parsers/jsonc-parse.mjs";
const getJsoncParse = () => jsoncParse;

// Gets a YAML parser
import yamlParse from "./parsers/yaml-parse.js";
import yamlParse from "./parsers/yaml-parse.mjs";
const getYamlParse = () => yamlParse;

// Gets an ordered array of parsers
import parsers from "./parsers/parsers.js";
import parsers from "./parsers/parsers.mjs";
const getParsers = () => parsers;

// Negates a glob
Expand Down
File renamed without changes.
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
},
"license": "MIT",
"type": "module",
"main": "./markdownlint-cli2.js",
"main": "./markdownlint-cli2.mjs",
"exports": {
".": "./markdownlint-cli2.js",
"./markdownlint": "./export-markdownlint.js",
"./markdownlint/helpers": "./export-markdownlint-helpers.js",
"./parsers": "./parsers/parsers.js",
"./parsers/jsonc": "./parsers/jsonc-parse.js",
"./parsers/yaml": "./parsers/yaml-parse.js"
".": "./markdownlint-cli2.mjs",
"./markdownlint": "./export-markdownlint.mjs",
"./markdownlint/helpers": "./export-markdownlint-helpers.mjs",
"./parsers": "./parsers/parsers.mjs",
"./parsers/jsonc": "./parsers/jsonc-parse.mjs",
"./parsers/yaml": "./parsers/yaml-parse.mjs"
},
"bin": {
"markdownlint-cli2": "markdownlint-cli2.js"
"markdownlint-cli2": "markdownlint-cli2.mjs"
},
"homepage": "https://github.com/DavidAnson/markdownlint-cli2",
"repository": {
Expand All @@ -39,34 +39,34 @@
"playwright-test": "playwright test --config ./webworker/playwright.config.mjs",
"playwright-test-docker": "docker run --rm --volume $PWD:/home/workdir --workdir /home/workdir --ipc=host mcr.microsoft.com/playwright:v1.48.2 npm run playwright-test",
"schema": "cpy ./node_modules/markdownlint/schema/markdownlint-config-schema.json ./schema --flat",
"test": "ava --timeout=1m test/append-to-array-test.js test/fs-mock-test.js test/fs-virtual-test.js test/markdownlint-cli2-test.js test/markdownlint-cli2-test-exec.js test/markdownlint-cli2-test-exports.js test/markdownlint-cli2-test-fs.js test/markdownlint-cli2-test-main.js test/merge-options-test.js test/resolve-and-require-test.js",
"test": "ava --timeout=1m test/append-to-array-test.mjs test/fs-mock-test.mjs test/fs-virtual-test.mjs test/markdownlint-cli2-test.mjs test/markdownlint-cli2-test-exec.mjs test/markdownlint-cli2-test-exports.mjs test/markdownlint-cli2-test-fs.mjs test/markdownlint-cli2-test-main.mjs test/merge-options-test.mjs test/resolve-and-require-test.mjs",
"test-cover": "c8 --100 npm test",
"test-docker-hub-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker image rm davidanson/markdownlint-cli2:v$VERSION davidanson/markdownlint-cli2:latest || true && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:v$VERSION \"*.md\" && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:latest \"*.md\"",
"test-docker-hub-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker image rm davidanson/markdownlint-cli2-rules:v$VERSION davidanson/markdownlint-cli2-rules:latest || true && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:v$VERSION \"*.md\" && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:latest \"*.md\"",
"test-docker-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:v$VERSION \"*.md\"",
"test-docker-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:v$VERSION \"*.md\"",
"test-invoke-as-cli": "markdownlint-cli2 CHANGELOG.md",
"test-watch": "git ls-files | entr npm run test",
"update-snapshots": "ava --timeout=1m --update-snapshots test/markdownlint-cli2-test-exec.js test/markdownlint-cli2-test-fs.js test/markdownlint-cli2-test-main.js",
"update-snapshots": "ava --timeout=1m --update-snapshots test/markdownlint-cli2-test-exec.mjs test/markdownlint-cli2-test-fs.mjs test/markdownlint-cli2-test-main.mjs",
"webworker": "cd webworker && webpack --mode none",
"webworker-install": "npm install --no-package-lock --no-save path-browserify setimmediate stream-browserify util webpack-cli && cpy ./node_modules/setimmediate/setImmediate.js ./webworker --flat"
"webworker-install": "npm install --no-package-lock --no-save path-browserify setimmediate stream-browserify util webpack-cli && cpy ./node_modules/setimmediate/setImmediate.cjs ./webworker --flat"
},
"engines": {
"node": ">=18"
},
"files": [
"append-to-array.js",
"append-to-array.mjs",
"CHANGELOG.md",
"export-markdownlint.js",
"export-markdownlint-helpers.js",
"export-markdownlint.mjs",
"export-markdownlint-helpers.mjs",
"LICENSE",
"markdownlint-cli2.js",
"merge-options.js",
"parsers/parsers.js",
"parsers/jsonc-parse.js",
"parsers/yaml-parse.js",
"markdownlint-cli2.mjs",
"merge-options.mjs",
"parsers/parsers.mjs",
"parsers/jsonc-parse.mjs",
"parsers/yaml-parse.mjs",
"README.md",
"resolve-and-require.js",
"resolve-and-require.mjs",
"schema/markdownlint-cli2-config-schema.json",
"schema/markdownlint-config-schema.json",
"schema/ValidatingConfiguration.md"
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions parsers/parsers.js → parsers/parsers.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check

import jsoncParse from "./jsonc-parse.js";
import yamlParse from "./yaml-parse.js";
import jsoncParse from "./jsonc-parse.mjs";
import yamlParse from "./yaml-parse.mjs";

/**
* Array of parser objects ordered by priority.
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check

import test from "ava";
import appendToArray, { sliceSize } from "../append-to-array.js";
import appendToArray, { sliceSize } from "../append-to-array.mjs";

const makeArray = (minimum, maximum) => {
const length = maximum - minimum + 1;
Expand Down
2 changes: 1 addition & 1 deletion test/fs-mock-test.js → test/fs-mock-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fsNodePromises from "node:fs/promises";
import path from "node:path";
import { promisify } from "node:util";
import test from "ava";
import FsMock from "./fs-mock.js";
import FsMock from "./fs-mock.mjs";

const mockPath = "/mock";
const thisFile = path.basename(import.meta.filename);
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions test/fs-virtual-test.js → test/fs-virtual-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import path from "node:path";
import { promisify } from "node:util";
import test from "ava";
import FsVirtual from "../webworker/fs-virtual.js";
import FsVirtual from "../webworker/fs-virtual.mjs";

const mockPath = "/mock";
const thisFile = path.basename(import.meta.filename);
const testFile = path.join(mockPath, thisFile);
const missingFile = `${mockPath}/missing`;

const virtualFiles = [
[ "/mock/fs-virtual-test.js", "// content" ]
[ "/mock/fs-virtual-test.mjs", "// content" ]
];

test("fsVirtual.stat", async (t) => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import fs from "node:fs/promises";
import path from "node:path";
import test from "ava";
import testCases from "./markdownlint-cli2-test-cases.js";
import testCases from "./markdownlint-cli2-test-cases.mjs";

const absolute = (rootDir, file) => path.join(rootDir, file);
const repositoryPath = (name) => path.join(import.meta.dirname, "..", name);
Expand All @@ -14,7 +14,7 @@ const invoke = (directory, args, noRequire, env, script) => async () => {
return spawn(
"node",
[
repositoryPath(script || "markdownlint-cli2.js"),
repositoryPath(script || "markdownlint-cli2.mjs"),
...args
],
{
Expand Down Expand Up @@ -45,7 +45,7 @@ const invokeStdin = async (args, stdin, cwd) => {
return spawn(
"node",
[
repositoryPath("markdownlint-cli2.js"),
repositoryPath("markdownlint-cli2.mjs"),
...args
],
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import importWithTypeJson from "./import-with-type-json.mjs";
const packageJson = await importWithTypeJson("../package.json");

const exportMappings = new Map([
[ ".", "../markdownlint-cli2.js" ],
[ ".", "../markdownlint-cli2.mjs" ],
[ "./markdownlint", "markdownlint" ],
[ "./markdownlint/helpers", "markdownlint/helpers" ],
[ "./parsers", "../parsers/parsers.js" ],
[ "./parsers/jsonc", "../parsers/jsonc-parse.js" ],
[ "./parsers/yaml", "../parsers/yaml-parse.js" ]
[ "./parsers", "../parsers/parsers.mjs" ],
[ "./parsers/jsonc", "../parsers/jsonc-parse.mjs" ],
[ "./parsers/yaml", "../parsers/yaml-parse.mjs" ]
]);

test("exportMappings", (t) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @ts-check

import path from "node:path";
import { "main" as markdownlintCli2 } from "../markdownlint-cli2.js";
import testCases from "./markdownlint-cli2-test-cases.js";
import FsMock from "./fs-mock.js";
import { "main" as markdownlintCli2 } from "../markdownlint-cli2.mjs";
import testCases from "./markdownlint-cli2-test-cases.mjs";
import FsMock from "./fs-mock.mjs";
const mockDirectory = "/mock";

const linesEndingWithNewLine =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @ts-check

import path from "node:path";
import { "main" as markdownlintCli2 } from "../markdownlint-cli2.js";
import testCases from "./markdownlint-cli2-test-cases.js";
import { "main" as markdownlintCli2 } from "../markdownlint-cli2.mjs";
import testCases from "./markdownlint-cli2-test-cases.mjs";

const linesEndingWithNewLine =
(lines) => lines.map((line) => `${line}\n`).join("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import test from "ava";
import { globby } from "globby";
import importWithTypeJson from "./import-with-type-json.mjs";
const packageJson = await importWithTypeJson("../package.json");
import { "main" as markdownlintCli2 } from "../markdownlint-cli2.js";
import jsoncParse from "../parsers/jsonc-parse.js";
import yamlParse from "../parsers/yaml-parse.js";
import FsMock from "./fs-mock.js";
import FsVirtual from "../webworker/fs-virtual.js";
import { "main" as markdownlintCli2 } from "../markdownlint-cli2.mjs";
import jsoncParse from "../parsers/jsonc-parse.mjs";
import yamlParse from "../parsers/yaml-parse.mjs";
import FsMock from "./fs-mock.mjs";
import FsVirtual from "../webworker/fs-virtual.mjs";
import firstLine from "./customRules/rules/first-line.cjs";

const schemaIdVersionRe = /^.*v(?<version>\d+\.\d+\.\d+).*$/u;
Expand Down
2 changes: 1 addition & 1 deletion test/merge-options-test.js → test/merge-options-test.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check

import test from "ava";
import mergeOptions from "../merge-options.js";
import mergeOptions from "../merge-options.mjs";

test("null/null", (t) => {
t.plan(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import test from "ava";
import path from "node:path";
import resolveAndRequire from "../resolve-and-require.js";
import resolveAndRequire from "../resolve-and-require.mjs";

import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
Expand Down
Loading

0 comments on commit fe18768

Please sign in to comment.