Skip to content

Commit

Permalink
Convert scripts to mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
louischan-oursky committed Aug 30, 2024
1 parent 9746e83 commit 4de6e40
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: check-rules-are-up-to-date
check-rules-are-up-to-date:
node ./scripts/print-all-rules.js
node ./scripts/print-all-rules.mjs
git status | grep "rules"; test $$? -eq 1

.PHONY: check-all-rules-are-considered
check-all-rules-are-considered:
node ./scripts/check-all-rules-are-considered.js
node ./scripts/check-all-rules-are-considered.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fs = require("fs");
import fs from "fs";

function setDifference(a, b) {
const diffArr = [...a].filter((element) => !b.has(element));
Expand All @@ -12,7 +12,9 @@ function setDifference(a, b) {
const content = fs.readFileSync("rules/stylelint", { encoding: "utf8" });
const allRules = content.split("\n").filter((line) => line !== "");

const consideredRules = Object.keys(require("../config/stylelint").rules);
const mod = await import("../config/stylelint.mjs");

const consideredRules = Object.keys(mod.default.rules);

const allRulesSet = new Set(allRules);
const consideredRulesSet = new Set(consideredRules);
Expand Down
4 changes: 2 additions & 2 deletions scripts/print-all-rules.js → scripts/print-all-rules.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require("fs");
import fs from "fs";

const stylelint = require("stylelint");
import stylelint from "stylelint";

const ruleNames = Object.keys(stylelint.rules);
ruleNames.sort((a, b) => a.localeCompare(b));
Expand Down

0 comments on commit 4de6e40

Please sign in to comment.