Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added remark-cli and pnpm lock file resolution logic #48

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

th-blitz
Copy link
Member

Hi, added the following with this branch:

  1. remark-cli packages for linting as dev-packages and
  2. pnpm git merge lock file resolution config in .npmrc file.

@th-blitz th-blitz requested a review from a team as a code owner February 12, 2025 22:17
Copy link

PR Preview Action v1.6.0

🚀 View preview at
https://NYU-ITS.github.io/rts-docs-dev/pr-preview/pr-48/

Built to branch gh-pages at 2025-02-12 22:18 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@th-blitz
Copy link
Member Author

th-blitz commented Feb 13, 2025

Hi @s-sajid-ali , added remark linting packages, and it's configs making use of remark-mdx and remark-preset-recommended to check for linting errors or warnings. You may find the exact configuration in the package.json file as shown below:

  "remarkConfig": {
    "plugins": [
      "remark-preset-lint-recommended",
      "remark-mdx",
      ["remark-lint-list-item-indent", false]
    ]
  },

Running the linting check with --frail option specified in the package.json's scripts as "lint": "remark --frail ." will return a fail upon warnings. Therefore this will return a fail during the .github/workflow/lint.yaml run upon warnings as well instead of only on errors.

Made changes to the .github/workflow/lint.yaml workflow file to install pixi, setup our packages with pnpm using pixi, and then to run a linting check making use of the remark installation.

This will enable a consistent use of our remark packages & configs for linting checks across development both locally and on github actions or anywhere else.

Please let me know if you have any questions.

  • Updated README.md with instructions
  • Added an option to run linting directly as pixi run lint which will make use of pnpm's --dev packages.
  • And added a .npmrc file with config git-branch-lockfile=true, this generates separate lock files for different branches avoiding merge conflicts
  • Finally need to setup a way for merging lockfiles in main branch.

@@ -22,14 +22,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install pixi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either of them works, we can use any. Please let me know.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the action provided by the pixi devs. Fewer things for us to maintain later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good !

"plugins": [
"remark-preset-lint-recommended",
"remark-mdx",
["remark-lint-list-item-indent", false]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep remark-lint-list-item-indent. We've been following it for newer files lately and it's better to have one consistent standard on list item indentation than mix multiple styles.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, We could configure remark to check for newly changed files only with our lint.yaml actions file.

Copy link
Member Author

@th-blitz th-blitz Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remark supports auto-formatting options as described here https://github.com/remarkjs/remark-lint?tab=readme-ov-file#example-check-and-format-markdown-on-the-cli

We can use --output option to automatically format markdown files based on indents and escape characters for uniformity like :

"format": "remark . --output --frail"

Running pnpm format will format all the markdown files for us.

@@ -27,6 +35,11 @@
"@docusaurus/module-type-aliases": "^3.7.0",
"@docusaurus/tsconfig": "^3.7.0",
"@docusaurus/types": "^3.7.0",
"remark-cli": "^12.0.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@th-blitz th-blitz Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We can use --save-exact option with pnpm add as specified here https://pnpm.io/cli/add#--save-exact--e . For example remove :

pnpm remove remark-cli remark-mdx remark-preset-lint-recommended

and then re-add with --save-exact:

pnpm add --save-dev --save-exact remark-cli remark-mdx remark-preset-lint-recommended

This will add fixed packages to packages.json like :

  "devDependencies": {
    "@docusaurus/module-type-aliases": "^3.7.0",
    "@docusaurus/tsconfig": "^3.7.0",
    "@docusaurus/types": "^3.7.0",
    "remark-cli": "12.0.1",
    "remark-mdx": "3.1.0",
    "remark-preset-lint-recommended": "7.0.1",
    "typescript": "~5.7.3"
  },

@th-blitz th-blitz requested a review from s-sajid-ali February 13, 2025 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants