Skip to content

Commit

Permalink
chore: Add Husky/lint-staged for local precommit (mdn#20397)
Browse files Browse the repository at this point in the history
* chore: Add Husky/lint-staged for local precommit

* chore: ignore non-cleaned markdown folders

* Do not run husky with Prettier on any MD file (for the moment)

Co-authored-by: Jean-Yves Perrier <[email protected]>
  • Loading branch information
nschonni and teoli2003 authored Sep 13, 2022
1 parent 94308f1 commit 63015b4
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
4 changes: 4 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*": "prettier --ignore-unknown --write",
"*.md": "markdownlint-cli2-fix"
}
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
build/

# Ignore markdown files till full pass is made on each folder
*.md

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
"lint:json": "prettier -c \"**/*.json(c)?\"",
"lint:md": "markdownlint-cli2 \"**/*.md\"",
"lint:yml": "prettier -c \"**/*.yml\"",
"prepare": "husky install",
"start": "yarn up-to-date-check && env-cmd --silent cross-env CONTENT_ROOT=files REACT_APP_DISABLE_AUTH=true BUILD_OUT_ROOT=build yari-server",
"up-to-date-check": "node scripts/up-to-date-check.js"
},
"dependencies": {
"@mdn/yari": "1.18.39",
"cross-env": "7.0.3",
"env-cmd": "10.1.0",
"husky": "8.0.1",
"lint-staged": "13.0.3",
"markdownlint-cli2": "0.5.1",
"markdownlint-rule-search-replace": "1.0.5",
"prettier": "2.7.1"
Expand Down
15 changes: 7 additions & 8 deletions scripts/update-interface-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ const idlnames = await fs
.readFile(path.join(webrefPath, "idlnames.json"), "utf-8")
.then(JSON.parse);

const idls =
await Promise.all(
Object.entries(idlnames)
.sort(([k1], [k2]) => k1.localeCompare(k2))
.map(([, { parsed: jsonIdlPath }]) =>
fs.readFile(path.join(webrefPath, jsonIdlPath), "utf-8").then(JSON.parse)
)
);
const idls = await Promise.all(
Object.entries(idlnames)
.sort(([k1], [k2]) => k1.localeCompare(k2))
.map(([, { parsed: jsonIdlPath }]) =>
fs.readFile(path.join(webrefPath, jsonIdlPath), "utf-8").then(JSON.parse)
)
);

const interfaceData = idls.reduce((interfaceData, idl) => {
if (idl.type === "interface") {
Expand Down
Loading

0 comments on commit 63015b4

Please sign in to comment.