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

fix: update ineff regex #357 #410

Closed
wants to merge 1 commit into from
Closed

fix: update ineff regex #357 #410

wants to merge 1 commit into from

Conversation

Izook
Copy link
Contributor

@Izook Izook commented Jul 6, 2023

Alaska Airlines Pull Request

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes: #357

Summary:

Please summarize the scope of the changes you have submitted, what the intent of the work is and anything that describes the before/after state of the project.

Type of change:

Please delete options that are not relevant.

  • Revision of an existing capability

Checklist:

  • My update follows the CONTRIBUTING guidelines of this project
  • I have performed a self-review of my own update

By submitting this Pull Request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Pull Requests will be evaluated by their quality of update and whether it is consistent with the goals and values of this project. Any submission is to be considered a conversation between the submitter and the maintainers of this project and may require changes to your submission.

Thank you for your submission!

-- Auro Design System Team

@Izook Izook requested a review from a team as a code owner July 6, 2023 22:31
@Izook Izook linked an issue Jul 6, 2023 that may be closed by this pull request
1 task
@Izook Izook self-assigned this Jul 6, 2023
@blackfalcon blackfalcon force-pushed the izook/ineffRegEx/#357 branch from 90b4ec4 to a7e1841 Compare July 6, 2023 23:39
@blackfalcon
Copy link
Member

Using this brach, I built a test repo and this is how the demo page looks.

Screen Shot 2023-07-06 at 4 46 42 PM

@@ -59,7 +59,7 @@ function formatTemplateFileContents(content, destination) {
result = result.replace(/>(\r\n|\r|\n){2,}/g, '>\r\n'); // Remove empty lines directly after a closing html tag.
result = result.replace(/>(\r\n|\r|\n)```/g, '>\r\n\r\n```'); // Ensure an empty line before code samples.
result = result.replace(/>(\r\n|\r|\n){2,}```(\r\n|\r|\n)/g, '>\r\n```\r\n'); // Ensure no empty lines before close of code sample.
result = result.replace(/([^(\r\n|\r|\n)])(\r\n|\r|\n)+#/g, "$1\r\n\r\n#"); // Ensure empty line before header sections.
result = result.replace(/([^\r\n])([\r\n|\r|\n]+)/g, "$1\r\n\r\n#"); // Ensure empty line before header sections.
Copy link
Member

Choose a reason for hiding this comment

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

This regex will malform the output of HTML from the markdown docs.

@Izook Izook marked this pull request as draft July 7, 2023 20:19
@Izook Izook force-pushed the izook/ineffRegEx/#357 branch from a7e1841 to 5108ace Compare July 8, 2023 03:35
@blackfalcon blackfalcon force-pushed the izook/ineffRegEx/#357 branch from 5108ace to a7f7ef0 Compare July 10, 2023 15:27
fs.readFile('./demo/apiExamples.md', 'utf8', function(err, data) {
formatTemplateFileContents(data, './demo/apiExamples.md');
fs.readFile('./demo/api.md', 'utf8', function(err, data) {
formatTemplateFileContents(data, './demo/api.md');
Copy link
Member

Choose a reason for hiding this comment

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

I get the following error traced back to this update

./index.js → dist/...
created dist/ in 266ms
/Users/dalesande/src/auro/test-element/scripts/generateDocs.js:49
  result = result.replace(/\[npm]/g, nameExtractionData.npm);
                  ^

TypeError: Cannot read properties of undefined (reading 'replace')
    at formatTemplateFileContents (/Users/dalesande/src/auro/test-element/scripts/generateDocs.js:49:19)
    at ReadFileContext.callback (/Users/dalesande/src/auro/test-element/scripts/generateDocs.js:87:5)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (node:fs:325:13)

Node.js v18.15.0
ERROR: "build:docs" exited with 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In what repo/branch did you see this?

Copy link
Member

Choose a reason for hiding this comment

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

I generated a new repo using npm run build:test

@blackfalcon blackfalcon mentioned this pull request Jul 10, 2023
6 tasks
@blackfalcon blackfalcon closed this Feb 2, 2024
@blackfalcon blackfalcon deleted the izook/ineffRegEx/#357 branch February 2, 2024 18:29
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.

Fix code scanning alert - Inefficient regular expression
2 participants