Skip to content

Commit 62e3669

Browse files
committed
Progress converting from CommonJS -> ESM
1 parent cce98aa commit 62e3669

21 files changed

+132
-167
lines changed

.eslintrc.js

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

.eslintrc.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"root": true,
3+
"parserOptions": {
4+
"ecmaVersion": 2020
5+
},
6+
"env": {
7+
"es6": true,
8+
"node": true,
9+
"jest": true
10+
},
11+
"plugins": ["github"],
12+
"extends": ["plugin:github/recommended"],
13+
"rules": {
14+
"import/no-commonjs": "off",
15+
"filenames/match-regex": "off",
16+
"i18n-text/no-en": "off"
17+
}
18+
}

.markdownlint-cli2.cjs

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

.markdownlint-cli2.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// import init from "./index.js";
2+
3+
const options = {
4+
default: false,
5+
"heading-increment": true,
6+
"no-alt-text": true,
7+
"single-h1": true,
8+
"no-emphasis-as-heading": true,
9+
"first-line-heading": true,
10+
};
11+
export const config = options;
12+
export const customRules = ["./index.js"];

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14
1+
18

index.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
const _ = require("lodash");
1+
import _ from "lodash-es";
22

3-
const accessibilityRules = require("./style/accessibility.json");
4-
const base = require("./style/base.json");
5-
const gitHubCustomRules = require("./src/rules/index").rules;
6-
7-
module.exports = [...gitHubCustomRules];
3+
import * as accessibilityRules from "./style/accessibility.json";
4+
import * as base from "./style/base.json";
5+
import { githubMarkdownLint } from "./src/rules/index.js";
86

97
const offByDefault = ["no-empty-alt-text"];
8+
const foo = base;
109

11-
for (const rule of gitHubCustomRules) {
12-
const ruleName = rule.names[1];
13-
base[ruleName] = offByDefault.includes(ruleName) ? false : true;
14-
}
10+
// for (const rule of githubMarkdownLint) {
11+
// const ruleName = rule.names[1];
12+
// foo[ruleName] = offByDefault.includes(ruleName) ? false : true;
13+
// }
1514

16-
module.exports.init = function init(consumerConfig) {
15+
export function init(consumerConfig) {
1716
// left overwrites right
1817
return _.defaultsDeep(consumerConfig, accessibilityRules, base);
19-
};
18+
}

jest.config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"transform": {
3+
}
4+
}

package-lock.json

Lines changed: 24 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
{
22
"name": "@github/markdownlint-github",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "An opinionated collection of markdownlint rules used by GitHub.",
5-
"main": "index.js",
5+
"type": "module",
6+
"exports": "./index.js",
7+
"engines": {
8+
"node": ">=18"
9+
},
610
"directories": {
711
"test": "test"
812
},
913
"scripts": {
1014
"publish": "npm publish --access public --@github:registry=https://registry.npmjs.org",
11-
"test": "npm run lint && jest",
15+
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
1216
"lint": "markdownlint-cli2 \"**/*.{md,mdx}\" \"!node_modules\" \"!docs/rules\" \"!test/example.md\" && eslint .",
1317
"lint:fix": "npm run lint -- --fix"
1418
},
1519
"dependencies": {
16-
"lodash": "^4.17.15"
20+
"lodash-es": "^4.17.15"
1721
},
1822
"devDependencies": {
1923
"eslint": "^8.22.0",
2024
"eslint-plugin-github": "^5.0.1",
2125
"jest": "^29.5.0",
2226
"markdownlint": "^0.37.3",
23-
"markdownlint-cli2": "^0.16.0"
27+
"markdownlint-cli2": "^0.17.0"
2428
},
2529
"repository": {
2630
"type": "git",
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/* Downcase and strip extra whitespaces and punctuation */
2-
function stripAndDowncaseText(text) {
2+
export function stripAndDowncaseText(text) {
33
return text
44
.toLowerCase()
55
.replace(/[.,/#!$%^&*;:{}=\-_`~()]/g, "")
66
.replace(/\s+/g, " ")
77
.trim();
88
}
9-
10-
module.exports = { stripAndDowncaseText };

0 commit comments

Comments
 (0)